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

Alexey Brazhe brazhe@gmail....
Sun Jul 11 12:31:24 CDT 2010

```Seems to be, but not for any matrix:

#-----------------

def mpower(M, p):
"Matrix exponentiation"
e,EV = linalg.eigh(M)
return dot(EV.T,
dot(diag((e)**p), EV))

m = array([[1.0,2.0], [3.0,4.0]])

then dot(m.T,m) does equal mpower(mpower(dot(m.T,m), 0.5), 2.0)

But mpower(mpower(m,0.5),2) doesn't equal m!

On Sun, Jul 11, 2010 at 9:23 PM, David Goldsmith <d.l.goldsmith@gmail.com>wrote:

> On Sun, Jul 11, 2010 at 8:26 AM, Andrew Jaffe <a.h.jaffe@gmail.com> wrote:
>
>> Although most people already know this, since nobody's actually said it
>> yet in this thread, and there seems to be some confusion, the generic
>> meaning of matrix exponentiation is usually the following.
>>
>> We can diagonalize a matrix
>>       M = R^T E R
>> where R is the matrix of eigenvectors (^T is transpose or hermitian
>> conjugate) and
>>       E = diag(lambda_1, lambda_2, ...) is the diagonal matrix of
>> eigenvalues.
>>
>> Then, we can define
>>       M^a = R^T E^a R
>> where E^a = diag(lambda_1^a, lambda_2^a, ...)
>>
>> in particular, this gives the obvious answers for integer powers and
>> even negative integers, including -1 for the inverse. (+1/2 doesn't give
>> the Cholesky decomposition, but the Hermitian square root)
>>
>
> Thanks, Andrew, I was wanting to provide something like this, but I was
> going to have to go look it up and, well, have higher priorities at the
> moment. :-)  But you left off one "intuitive" identity that one would want
> to be true, which would appear to be trivially so, unless something
> unexpected screws it up, namely: (M^a)^(1/a) = (M^(1/a))^a = M; I assume
> this is valid, correct?
>
> DG
>
>
>>
>> Andrew
>> _______________________________________________
>> SciPy-User mailing list
>> SciPy-User@scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-user
>>
>
>
>
> --
> Mathematician: noun, someone who disavows certainty when their uncertainty
> set is non-empty, even if that set has measure zero.
>
> Hope: noun, that delusive spirit which escaped Pandora's jar and, with her
> lies, prevents mankind from committing a general suicide.  (As interpreted
> by Robert Graves)
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100711/66eeedf8/attachment.html
```