Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

sqrtm

Matrix Square Root


Description

This function computes the matrix square root of a square matrix. The sqrt of a matrix A is S such that A = S S.

Usage

sqrtm(x)

Arguments

x

a square matrix.

Details

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.

Value

A matrix ‘as x’ with the matrix sqrt of x.

Author(s)

Michael Stadelmann wrote the first version.

References

Higham, N.~J. (2008). Functions of Matrices: Theory and Computation; Society for Industrial and Applied Mathematics, Philadelphia, PA, USA.

See Also

Examples

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))

expm

Matrix Exponential, Log, 'etc'

v0.999-6
GPL (>= 2)
Authors
Vincent Goulet, Christophe Dutang, Martin Maechler, David Firth, Marina Shapira, Michael Stadelmann
Initial release
2021-01-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.