powered by
A simple function to demonstrate calculating the power of a square symmetric matrix in terms of its eigenvalues and eigenvectors.
mpower(A, p, tol = sqrt(.Machine$double.eps))
A raised to the power p: A^p
A
p
A^p
a square symmetric matrix
matrix power, not necessarily a positive integer
tolerance for determining if the matrix is symmetric
The matrix power p can be a fraction or other non-integer. For example, p=1/2 and p=1/3 give a square-root and cube-root of the matrix.
p=1/2
p=1/3
Negative powers are also allowed. For example, p=-1 gives the inverse and p=-1/2 gives the inverse square-root.
p=-1
p=-1/2
The {%^%} operator in the expm package is far more efficient
{%^%}
C <- matrix(c(1,2,3,2,5,6,3,6,10), 3, 3) # nonsingular, symmetric C mpower(C, 2) zapsmall(mpower(C, -1)) solve(C) # check
Run the code above in your browser using DataLab