On Oct 17, 6:51 am, [EMAIL PROTECTED] 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 -- http://mail.python.org/mailman/listinfo/python-list