The best bet to simplify something involving complex number relations is to use expand_complex, which will put the expression into a + b*I with a, b real form. It looks like expand_complex(abs(x)**2) gives an overly complicated result, but if you call simplify, it reduces to im(x)**2 + re(x)**2, which is the same thing that expand_complex(x*x.conjugate()) gives, simplify(expand_complex()) should reduce your expression to 0.
And by the way, whenever you find something that some part of SymPy can simplify, but simplify() can't, we consider it to be a bug. simplify() should be smart enough to do the right thing for you. Aaron Meurer On Thu, Nov 14, 2013 at 6:40 PM, Bogdan Opanchuk <[email protected]> wrote: > Hello all, > > I have a complex-valued symbol z, and I would like its product with its > conjugate (z z^*) to be simplified to |z|^2. Currently sympy seems to > consider them to be different: > > from sympy import * > > init_printing() > > z = Symbol('z', complex=True) > pprint(simplify(z * z.conjugate() - abs(z) ** 2)) > > _ 2 > z⋅z - │z│ > > Besides simplify() I have also tried powsimp(), with the same result. Is > there some other simplification function that does this transformation? > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.
