Can you determine the sign of the polar form of a complex number?

Gerard Flanagan grflanagan at yahoo.co.uk
Wed Oct 17 10:29:14 EDT 2007


On Oct 17, 3:17 pm, schaefer... at gmail.com wrote:
> To compute the absolute value of a negative base raised to a
> fractional exponent such as:
>
> z = (-3)^4.5
>
> you can compute the real and imaginary parts and then convert to the
> polar form to get the correct value:
>
> real_part = ( 3^-4.5 ) * cos( -4.5 * pi )
> imag_part = ( 3^-4.5 ) * sin( -4.5 * pi )
>
> |z| = sqrt( real_part^2 + imag_part^2 )
>
> Is there any way to determine the correct sign of z, or perform this
> calculation in another way that allows you to get the correct value of
> z expressed without imaginary parts?
>


Your question is not clear. (There is a cmath module if that helps).

>>> z1 = complex(-3)**4.5
>>> z1
(7.7313381458154376e-014+140.29611541307906j)
>>> import cmath
>>> z2 = cmath.exp(4.5 * cmath.log(-3))
>>> z2
(7.7313381458154401e-014+140.29611541307909j)
>>>

Gerard




More information about the Python-list mailing list