[SciPy-User] raising a matrix to float power

Andrew Jaffe a.h.jaffe@gmail....
Sun Jul 11 10:26:32 CDT 2010


Hi,

On 11/07/2010 00:26, Alexey Brazhe wrote:
> 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 :)

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)

Andrew


More information about the SciPy-User mailing list