Description Usage Arguments Details Value Author(s) References See Also Examples
Raises a valid Matrix to any power (even complex). Valid matrices are square matrices that are diagonalizable or whose real eigenvalues are positive.
1 2 | Matpow(M, numer, denom = 1, expmethod = "Higham08.b",
logmethod = "Higham08", tol = 1e-12)
|
M |
a square matrix |
numer |
numerator of exponent. Can be a decimal or complex number. |
denom |
denominator of exponent (1 by default). Can be a decimal or complex number. |
expmethod |
method chosen to compute the matrix exponential if matrix is known to be
non-diagonalizable. The default method is the same as in function |
logmethod |
method chosen to compute the matrix logarithm if matrix is known to be
non-diagonalizable. The default method is the same as in function |
tol |
a tolerance, 10^-12 by default. Prevents possible numerical problems. Can be set to 0 if desired. |
If the matrix is diagonalizable, the method used is based on spectral decomposition;
if the matrix is not diagonalizable, the method used is based on matrix exponentials and logarithms,
calling functions matexp
and matlog
, both from package complexplus.
The particular method used to compute the matrix exponential and logarithm may be chosen from the options available
in functions expm
and logm
respectively, both from package expm.
Note that Matpow
, by extension, allows one to compute roots and the matrix inverse (if invertible).
The solution to the exponentiation operation supplied.
For diagonalizable matrices, Matpow
returns a real-valued root whenever possible
(otherwise, the principal complex root).
Albert Dorador
For more on spectral decomposition (also known as eigendecomposition), visit http://mathworld.wolfram.com/EigenDecomposition.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | A <- matrix(1:4, ncol = 2)
Matpow(A, 3)
Matpow(A, 0.5)
Matpow(A, 0.2)
Matpow(A, 1, 5)
Matpow(A, 2, 4, expmethod = "Pade", logmethod = "Eigen") #inocuous, as A is diagonalizable
Matpow(A, -1)
Matpow(A, 2+5i)
Matpow(A, 3i)
Matpow(A, 1+2i)
Matpow(A, 3i, 2+7i)
B <- matrix(sample(1:100, 81), ncol = 9)
Matpow(B, 2)
Matpow(B, 0.5)
Matpow(B, 7+2i)
Matpow(B, 4i, 1+3i)
C <- matrix(c(1, 0, 1, 1), ncol = 2) # A non-diagonalizable matrix
Matpow(C, 3)
Matpow(C, 0.5)
Matpow(C, 4, 8, expmethod = "Taylor", logmethod = "Eigen")
Matpow(C, 0.5*pi)
Matpow(C, 0.24)
Matpow(C, -2)
Matpow(C, 3+5i)
Matpow(C, 2i, 1+9i)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.