negative base raised to fractional exponent

Karthik Gurusamy kar1107 at
Wed Oct 17 01:15:37 CEST 2007

On Oct 16, 2:48 pm, schaefer... at 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.

Use complex numbers. They are part of python (no special modules
Just write your real number r, as r+0j

e.g. square-root of -4 is 2j

>>> (-4+0j)**(0.5)
(1.2246063538223773e-16+2j)         # real part is almost zero
>>> (-4.234324+0j)**(0.5)
>>> 2.0577473119894969j ** 2


More information about the Python-list mailing list