Documentation |
Matrix square root
X = sqrtm(A)
[X, resnorm] = sqrtm(A)
[X, alpha, condest] = sqrtm(A)
X = sqrtm(A) is the principal square root of the matrix A, i.e. X*X = A.
X is the unique square root for which every eigenvalue has nonnegative real part. If A has any eigenvalues with negative real parts then a complex result is produced. If A is singular then A may not have a square root. A warning is printed if exact singularity is detected.
[X, resnorm] = sqrtm(A) does not print any warning, and returns the residual, norm(A-X^2,'fro')/norm(A,'fro').
[X, alpha, condest] = sqrtm(A) returns a stability factor alpha and an estimate condest of the matrix square root condition number of X. The residual norm(A-X^2,'fro')/norm(A,'fro') is bounded approximately by n*alpha*eps and the Frobenius norm relative error in X is bounded approximately by n*alpha*condest*eps, where n = max(size(A)).
A matrix representation of the fourth difference operator is
A = 5 -4 1 0 0 -4 6 -4 1 0 1 -4 6 -4 1 0 1 -4 6 -4 0 0 1 -4 5
This matrix is symmetric and positive definite. Its unique positive definite square root, Y = sqrtm(A), is a representation of the second difference operator.
Y = 2 -1 -0 -0 -0 -1 2 -1 0 -0 0 -1 2 -1 0 -0 0 -1 2 -1 -0 -0 -0 -1 2
The matrix
A = 7 10 15 22
has four square roots. Two of them are
Y1 = 1.5667 1.7408 2.6112 4.1779
and
Y2 = 1 2 3 4
The other two are -Y1 and -Y2. All four can be obtained from the eigenvalues and vectors of A.
[V,D] = eig(A); D = 0.1386 0 0 28.8614
The four square roots of the diagonal matrix D result from the four choices of sign in
S = ±0.3723 0 0 ±5.3723
All four Ys are of the form
Y = V*S/V
The sqrtm function chooses the two plus signs and produces Y1, even though Y2 is more natural because its entries are integers.