>>> r, r1, r2 = symbols('r r1 r2', real=True)
>>> g1, g2, h1, h2 = symbols('g1 g2 h1 h2', cls=Function)
>>> g1=exp(I*r)
>>> h1=expand_complex(g1)
>>> h1
I*sin(r) + cos(r)
>>> h1.rewrite(exp)
exp(I*r)

>>> g2=r1*exp(I*r2)
>>> h2=expand_complex(g1)
>>> h2
I*r1*sin(r2) + r1*cos(r2)
>>> h2.rewrite(exp)
r1*(exp(I*r2)/2 + exp(-I*r2)/2) + r1*(exp(I*r2) - exp(-I*r2))/2
>>> h2.rewrite(exp).simplify()
r1*exp(I*r2)

On Saturday, October 29, 2016 at 9:25:33 PM UTC-5, chaowen guo wrote:

> Hi:
>
> I know expand_complex can translate from polar form (say e*ix) to real 
> imaginary form (cos(x)+isin(x)), however I also need to do it in the other 
> way from (cos(x)+isin(x)) to e*ix. The ugly way is to:
>
> a=cos(x)+isin(x)
> a=sympy.Abs(a)*sympy.exp(sympy.I*sympy.arg(a))
>
> I want to know is there any elegant way (just a sympy builtin function 
> call) to do that?
>
> Actually, I have a complex number expression, now I want to represent all 
> the complex symbol in the polar form |x|e^(iarg(x)), how to do that?
>

-- 
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 https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/f0bf97f0-c354-41de-8528-d73495fa8262%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to