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

S

schaefer.mp

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?

For example, I can compute:

z1 = (-3)^-4 = 0,012345679
and
z3 = (-3)^-5 = -0,004115226

and I can get what the correct absolute value of z2 should be by
computing the real and imaginary parts:

|z2| = (-3)^-4.5 = sqrt( 3,92967E-18^2 + -0,007127781^2 ) =
0,007127781

but I need to know the sign.

Any help is appreciated.



but I can know the correct sign for this value.
 
S

schaefer.mp

Just to clarify what I'm after:

If you plot (-3)^n where n is a set of negative real numbers between 0
and -20 for example, then you get a discontinuos line due to the
problem mentioned above with fractional exponents. However, you can
compute what the correct absolute value of the the missing points
should be (see z2 above for an example), but I would like to know how
to determine what the correct sign of z2 should be so that it fits the
graph.
 
R

Roy Smith

Just to clarify what I'm after:

If you plot (-3)^n where n is a set of negative real numbers between 0
and -20 for example, then you get a discontinuos line due to the
problem mentioned above with fractional exponents. However, you can
compute what the correct absolute value of the the missing points
should be (see z2 above for an example), but I would like to know how
to determine what the correct sign of z2 should be so that it fits the
graph.

You need to ask this question on a math group. It's not a Python question
at all.
 
J

J. Robertson

Just to clarify what I'm after:

If you plot (-3)^n where n is a set of negative real numbers between 0
and -20 for example, then you get a discontinuos line due to the
problem mentioned above with fractional exponents.

..

It looks like you crash-landed in imaginary space, you may want to think
again about what you're up to :) Complex numbers are not positive or
negative, as such.

If you want to obtain a continuous curve, then take the real part of the
complex number you obtain, as in "((-3+0j)**(-x)).real", it will fit
with what you obtain for integers.
 
G

Gerard Flanagan

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).

Gerard
 
M

Matimus

Just to clarify what I'm after:

If you plot (-3)^n where n is a set of negative real numbers between 0
and -20 for example, then you get a discontinuos line due to the
problem mentioned above with fractional exponents. However, you can
compute what the correct absolute value of the the missing points
should be (see z2 above for an example), but I would like to know how
to determine what the correct sign of z2 should be so that it fits the
graph.

I know this isn't specifically what you are asking, but since you
aren't asking a Python question and this is a Python group I figure
I'm justified in giving you a slightly unrelated Python answer.

If you want to raise a negative number to a fractional exponent in
Python you simply have to make sure that you use complex numbers to
begin with:
(7.7313381458154376e-014+140.29611541307906j)

Then if you want the absolute value of that, you can simply use the
abs function:
140.29611541307906

The absolute value will always be positive. If you want the angle you
can use atan.
1.5707963267948961

I would maybe do this:
.... return math.atan(x.imag/x.real)

So, now that you have the angle and the magnitude, you can do this:
(7.0894366756400186e-014+140.29611541307906j)

Which matches our original answer. Well, there is a little rounding
error because we are using floats.

So, if you have a negative magnitude, that should be exactly the same
as adding pi (180 degrees) to the angle.
(2.5771127152718125e-014+140.29611541307906j)

Which should match our original answer. It is a little different, but
notice the magnitude of the real and imaginary parts. The real part
looks different, but is so small compared to the imaginary part that
it can almost be ignored.

Matt
 
J

Jason

Just to clarify what I'm after:

If you plot (-3)^n where n is a set of negative real numbers between 0
and -20 for example, then you get a discontinuos line due to the
problem mentioned above with fractional exponents. However, you can
compute what the correct absolute value of the the missing points
should be (see z2 above for an example), but I would like to know how
to determine what the correct sign of z2 should be so that it fits the
graph.

As Roy said, a math newsgroup may be able to help you better, as you
seem to be having fundamental issues with imaginary numbers. The
imaginary part isn't an artifact of computing (-3+0j)**(-4.5), it is
an integral part of the answer. Without the imaginary part, the
result is very, very incorrect.

Actually, the graph result of (-3)^n is not necessarily discontinuous
at the intervals you specified. You just need to graph the result
with the proper number of dimensions. If you want to plot the results
of (-3)^n for n=0 to -20, you need to make a three dimensional graph,
a two dimensional graph with two sets of lines, or a circular graph
with labeled values of n.

Complex numbers can be viewed as having a magnitude and a rotation in
the real/imaginary plane. This is called polar form. Complex numbers
can also be represented using a Cartesian form, which is how Python
displays complex numbers.

Python's complex numbers allow you to extract the real or imaginary
part separately, via the "real" and "imag" attributes. To convert to
polar form, you'll need to use the abs built-in to retrieve the
magnitude, and math.atan2 to retrieve the angle. (Remember that the
imaginary part is considered the Y-axis component.)

Depending on what you're doing, you might need the real part or the
magnitude. It sounds a little bit like you're trying to represent
something as a flatlander when you should be in Spaceland. (http://
en.wikipedia.org/wiki/Flatland)

--Jason
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top