I think you are confusing the assumptions system and the numeric classes in SymPy.
First, for the numeric classes, SymPy does not have a complex type. Rather, we just have the object I, which represents sqrt(-1). If you want 12 + 3*I, you just type exactly that. Internally, it is represented as Add(12, Mul(3, I)). One difference you'll notice here is that, because it is just an Add, things like (12 + 3*I)**2 or 1/(12 + 2*I) are not reevaluated to real + imag*I by default. You can use expand_complex() to do that (or as_real_imag if you want to pull out the real and imaginary parts). Now, for the assumptions. Symbol('x', complex=True) means that the symbol is assumed to be complex. This is in contrast to Symbol('x', real=True), which is assumed to be real. This matters for things like x.is_real, and affects how things are simplified. For example, sqrt(x**2) == x only when x is positive, so it will remain unevaluated by default, but if you create Symbol('x', positive=True), then sqrt(x**2) will simplify to just x. Symbols are assumed to be complex by default, so actually Symbol('x', complex=True) is unnecessary. Actually, this isn't entirely true; apparently Symbol('x', complex=True) is different from just Symbol('x'), which I don't entirely understand why. I think this might be a bug. Could you open an issue for it? Aaron Meurer On Sat, Jul 6, 2013 at 12:16 PM, Amit Saha <amitsaha...@gmail.com> wrote: > Hello, > > I have been playing a bit with the number classes, and I have come > across Integer, Real and Rational classes. Comparing to their "native" > counterparts in CPython, I understand they correspond to int, float > and the Fraction (from the fractions) objects respectively. Good so > far, I also looked around in the code and understand how the > comparison works. > > One thing I haven't found out (after fair searching around) is how do > I create a complex number (not a symbol as complex)? For example, I > can do this to create a SymPy floating point number: > > >>> from sympy import Float > >>> f=Float(1.4) > > How can I create a number such as 1+4j? > > Also, considering this: > > >>> f.is_complex > True > > which is fair, I understand, how do I assign the imaginary component > if that's the way i want to go about it? > > > Regarding declaring symbols as complex: > > With explicit complex assumption set: > > >>> x=Symbol('x',complex=True) > >>> x1 = x+1j > > > Generic symbol: > > >>> x=Symbol('x') > >>> x2=x+1j > > How are the above two different? I know they are: > > >>> x1==x2 > False > > Even though the structure of both the above expressions are the same, > the test evaluates to False. > > Thanks in advance for clarifying my doubts. > > Best, > Amit. > > -- > http://echorand.me > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sympy+unsubscr...@googlegroups.com. > To post to this group, send email to sympy@googlegroups.com. > Visit this group at http://groups.google.com/group/sympy. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.