title: SymPy Imaginary Number
body: <p>I'm messing around with writing some SymPy code to handle symbolic expressions with imaginary numbers.</p>
  
  <p>To start out, I want to get it to take x and y as real numbers and find the solution where x=iy. So I can do this as follows.</p>
  
  <pre><code>x, y = sympy.symbols("x y", real=True)  
  print(sympy.solve([x-sympy.I*y]))
  </code></pre>
  
  <p>(SymPy solve takes a list of values, all of which must be 0. So x-iy=0 => x=iy). SymPy will correctly tell me</p>
  
  <pre><code>[{x: 0, y: 0}]
  </code></pre>
  
  <p>However, if I do this a (theoretically identical) way:</p>
  
  <pre><code>x, y = sympy.symbols("x y")
  print(sympy.solve([x-sympy.I*y, sympy.im(y), sympy.im(x)]))
  </code></pre>
  
  <p>Then now SymPy tells me </p>
  
  <pre><code>[{re(y): y, re(x): I*y, im(x): 0, x: I*y, im(y): 0}]
  </code></pre>
  
  <p>And this is technically correct, but hasn't done everything for me. Is this just a limitation in SymPy, or can I get it to give me x=y=0 by constraining complex x and y in this way?</p>