negative base raised to fractional exponent

Steve Holden steve at holdenweb.com
Wed Oct 17 13:11:48 CEST 2007


John Machin wrote:
> On Oct 17, 8:03 am, Steve Holden <st... at holdenweb.com> 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.
>> A couple of questions.
>>
>> 1. How do you approximate a complex number in the reals? That doesn't
>> make sense.
>>
>> 2. x ^ -4.1111 = 1 / (x ^ 4.1111), so where do complex numbers enter
>> into this anyway?
>>
>> 3. I think you will find the complex numbers start to emerge as you
>> explore fractional exponents.
> 
> This is part of the story -- the other part is that the story differs
> depending on whether x is positive or negative.
> 
>> This being Python, and an interactive interpreter being available, you
>> can always just try it:
>>
>>  >>> -3 ** -4.1111
>> -0.010927147607830808
> 
> Steve, Trying to memorise the operator precedence table for each of
> several languages was never a good idea. I admit advanced age :-) and
> give up and use parentheses, just like the OP did:
> 
>>>> (-3)**-4.11111
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> ValueError: negative number cannot be raised to a fractional power
> 
> Best regards,
> John
> 
Well I guess I'd better admit to advances age too. Particularly since 
there was a python-dev thread about precedence, unaries and 
exponentiation not too long ago.

regards
  Steve

-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd           http://www.holdenweb.com
Skype: holdenweb      http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline so I couldn't cat it




More information about the Python-list mailing list