473,287 Members | 3,228 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

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

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.

Oct 17 '07 #1
7 2351
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.

Oct 17 '07 #2
In article <11**********************@i38g2000prf.googlegroups .com>,
sc*********@gmail.com wrote:
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.
Oct 17 '07 #3
sc*********@gmail.com writes:
Just to clarify what I'm after:
If you plot (-3)^n where n is a set of negative real numbers between 0
I still can't figure out for certain what you're asking, but you might
look at the article

http://en.wikipedia.org/wiki/De_Moivre%27s_formula
Oct 17 '07 #4
sc*********@gmail.com wrote:
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.
Oct 17 '07 #5
On Oct 17, 3:17 pm, schaefer...@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

Oct 17 '07 #6
On Oct 17, 6:51 am, schaefer...@gmail.com wrote:
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:
>>(-3+0j)**4.5
(7.7313381458154376e-014+140.29611541307906j)

Then if you want the absolute value of that, you can simply use the
abs function:
>>x = (-3+0j)**4.5
abs(x)
140.29611541307906

The absolute value will always be positive. If you want the angle you
can use atan.
>>x = (-3+0j)**4.5
math.atan(x.imag/x.real)
1.5707963267948961

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

So, now that you have the angle and the magnitude, you can do this:
>>abs(x) * cmath.exp(1j * ang(x))
(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.
>>(-abs(x)) * cmath.exp(1j * (ang(x)+cmath.pi))
(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

Oct 17 '07 #7
On Oct 17, 7:51 am, schaefer...@gmail.com wrote:
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

Oct 17 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Stefan Richter | last post by:
Hi, after coding for days on stupid form validations - Like: strings (min / max length), numbers(min / max value), money(min / max value), postcodes(min / max value), telefon numbers, email...
14
by: Google Mike | last post by:
I like PHP a lot. It's my favorite programming language. That's not to say that I'd like to see it grow more or for derivatives to come from it. For me, the ideal programming language would be: ...
17
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number....
12
by: tarmat | last post by:
sorry for this silly little question, but whats the function to grab the sign of a value?
1
by: chuck | last post by:
Hello, I have to create a complex form to handle company product returns. Right now, I have some form fields to describe the product being returned, productID, productDES,ProductQTY. Thats fine. ...
10
by: Sona | last post by:
Hi, Could someone please explain what sign-extension means? If I have a hex number 0x55, how does this get sign-extended? Can a sign-extended counterpart be equal to -91? In a program I'm...
3
by: Ken Durden | last post by:
Is it possible to force positive values to have the + sign prefixed on them? double f1 = 1024.2; double f2 = -1024.2; string.Format( "{0:F}", f1 ); // +1024.2 string.Format( "{0:F}", f2 );...
27
by: artifact.one | last post by:
Hello. I want to be able to portably determine whether or not a given double value is negative. Under C99, I do: if (signbit(d)) negative = 1; Or, if the implementation doesn't provide...
0
by: yadin | last post by:
hi every one can you please can you help me to fix these polar plot in db's so that the center is at the minimun negative number in voltagedb about and the maximun is at zero how can i see...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.