Hi Aaron, Thank you for the explanation. Unfortunately, expand_complex() only solves the equality checking problem; it would be also nice to have some automated way of transforming z z^* -> |z|^2. I am working with equations that include a large amount of factors like |z|^2 and |z|^4 (with different variables as 'z'), and the application of expand_complex() will make them quite unreadable.
On Friday, November 15, 2013 4:10:50 PM UTC+11, Aaron Meurer wrote: > > 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]<javascript:>> > 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] <javascript:>. > > To post to this group, send email to [email protected]<javascript:>. > > > 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.
