# [SciPy-User] raising a matrix to float power

Joshua Holbrook josh.holbrook@gmail....
Sat Jul 10 18:47:04 CDT 2010

```On Sat, Jul 10, 2010 at 3:39 PM, Sturla Molden <sturla@molden.no> wrote:
> Alexey Brazhe skrev:
>> Hi,
>> I failed to find a way to raise a matrix to a non-integer power in
>> numpy/scipy
>>
>> In Octave/Matlab, one would write M^0.5 to get the result
>> whereas in numpy
>> >>> maxtrix(M, 0.5)
>> raises the "TypeError: exponent must be an integer"
>>
>> Is there a way to do matrix exponentiation to non-integer powers in
>> numpy or scipy?
>>
>> Hope the answer is positive :)
> Sure, M**0.5 is cho_factor(M). For other non-integers I am not sure what
> matrix exponentiation could possibly mean.
>
> Are you sure you don't mean array exponentiation?
>
> Sturla
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>

I don't know the answer, but I did play around with Octave, and I
figured out that the meaning of float exponentiation in octave is:

A^x = B such that B^(1/x) = A

So, for example:

octave:7> a
a =

1   2
3   4

octave:8> b=a^0.5
b =

0.55369 + 0.46439i   0.80696 - 0.21243i
1.21044 - 0.31864i   1.76413 + 0.14575i

octave:9> b^2
ans =

1.0000 - 0.0000i   2.0000 - 0.0000i
3.0000 - 0.0000i   4.0000 + 0.0000i

I'd never really heard of this before, but it does seem to work for floats.

(josef said the same while I was writing this, but whatever. >:o )

--Josh
```