negative base raised to fractional exponent

Ken Schutte kschutte at csail.mit.edu
Wed Oct 17 16:00:02 CEST 2007


schaefer.mp at gmail.com wrote:
> On Oct 17, 4:05 am, Ken Schutte <kschu... at csail.mit.edu> wrote:
>> schaefer... at gmail.com wrote:
>>> Does anyone know of an approximation to raising a negative base to a
>>> fractional exponent? For example, (-3)^-4.11111 since this cannot be
>>> computed without using imaginary numbers. Any help is appreciated.
>> As others have said, you can use Python's complex numbers (just write -3
>> as -3+0j).  If for some reason you don't want to, you can do it all with
>> reals using Euler's formula,
>>
>> (-3)^-4.11111  =  (-1)^-4.11111  *  3^-4.11111
>> =
>> e^(j*pi*-4.11111)  *  3^-4.11111
>> =
>> (cos(pi*-4.11111) + j*sin(pi*-4.11111)) * 3^-4.11111
>>
>> in Python:
>>
>>  >>> import math
>>  >>> real_part = (3**-4.11111) * math.cos(-4.11111 * math.pi)
>>  >>> imaj_part = (3**-4.11111) * math.sin(-4.11111 * math.pi)
>>  >>> (real_part,imaj_part)
>> (0.01026806021211755, -0.0037372276904401318)
>>
>> Ken
> 
> Thank you for this. Now I need to somehow express this as a real
> number. For example, I can transform the real and imaginary parts into
> a polar coordinate giving me the value I want:
> 
> z = sqrt( real_part**2 + imaj_part**2 )
> 
> but this is an absolute terms. How does one determine the correct sign
> for this value?
> 

This is a complex number with non-zero imaginary part - there is no way 
to "express it as a real number".  Depending what you are trying to do, 
you may want the magnitude, z, which is by definition always positive. 
Or, maybe you just want to take real_part (which can be positive or 
negative).  Taking just the real part is the "closest" real number, in 
some sense.





More information about the Python-list mailing list