sqrtm | R Documentation |
This function computes the matrix square root of a square matrix.
The sqrt of a matrix A
is S
such that A = S S
.
sqrtm(x)
x |
a square matrix. |
The matrix square root S
of M
, S = sqrtm(M)
is
defined as one (the “principal”) S
such that
S S = S^2 = M
, (in R, all.equal( S %*% S , M )
).
The method works from the Schur decomposition.
A matrix ‘as x
’ with the matrix sqrt of x
.
Michael Stadelmann wrote the first version.
Higham, N.~J. (2008). Functions of Matrices: Theory and Computation; Society for Industrial and Applied Mathematics, Philadelphia, PA, USA.
expm
, logm
m <- diag(2)
sqrtm(m) == m # TRUE
(m <- rbind(cbind(1, diag(1:3)),2))
sm <- sqrtm(m)
sm
zapsmall(sm %*% sm) # Zap entries ~= 2e-16
stopifnot(all.equal(m, sm %*% sm))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.