Simplify complex expression

46 views
Skip to first unread message

bsdz

unread,
Sep 4, 2016, 12:16:31 PM9/4/16
to sympy
Hi

Can anyone recommend a way to simplify following expression?

(-1)**(1/4)*sqrt(-I)/2

I would like it to return 1/2 although various methods return different equivalent expressions.

i.e. 
  • sp.N(_) = 0.5 # note: I don't wish to evaluate it, here 
  • sp.expand_complex(_) = 0.353553390593274*sqrt(2)
  • sp.simplify(_) = 0.353553390593274*sqrt(-I)*(1 + I)
  • sp.powsimp(_) = sqrt(-I)*(0.353553390593274 + 0.353553390593274*I)
Thanks
Blair

Richard Fateman

unread,
Sep 5, 2016, 7:51:40 PM9/5/16
to sympy
There are 4 values for (-1)^(1/4) and there are 2 values for sqrt(-I).

the Maxima program has a command cabs()  that returns 1/2 for this expression.
Figure out what cabs does, and you are set. :)

Aaron Meurer

unread,
Sep 5, 2016, 9:06:23 PM9/5/16
to sy...@googlegroups.com
When you enter 1/4, Python evaluates this as a float. That's why all your expressions have floating point numbers. Use Rational(1, 4), or root(-1, 4). If you do that, then expand_complex() will give you the answer you want. See also http://docs.sympy.org/latest/tutorial/gotchas.html.

Aaron Meurer

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
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/6ea958be-131f-4f46-96b6-2d1c80ce5e9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Blair Azzopardi

unread,
Sep 7, 2016, 4:28:22 PM9/7/16
to sy...@googlegroups.com
That's great - I hadn't consider that. Thank you.

--
You received this message because you are subscribed to a topic in the Google Groups "sympy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sympy/zlwrXe6d-2g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sympy+unsubscribe@googlegroups.com.

To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
Reply all
Reply to author
Forward
0 new messages