| MATLAB Function Reference | Search  Help Desk |
| sqrtm | Examples See Also |
Y = sqrtm(X) [Y,esterr] = sqrtm(X)
Y = sqrtm(X)
is the matrix square root of X. Complex results are produced if X has negative eigenvalues. A warning message is printed if the computed Y*Y is not close to X.
[Y,esterr] = sqrtm(X)
does not print any warning message, but returns an estimate of the relative residual, norm(Y*Y-X)/norm(X).
If X is real, symmetric and positive definite, or complex, Hermitian and positive definite, then so is the computed matrix square root.
Some matrices, like X = [0 1; 0 0], do not have any square roots, real or complex, and sqrtm cannot be expected to produce one.
A matrix representation of the fourth difference operator is
X =
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(X), 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
X =
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 X.
[V,D] = eig(X);
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.
Finally, the matrix
X =
0 1
0 0
does not have any square roots. There is no matrix Y, real or complex, for which Y*Y = X. The statement
Y = sqrtm(X)produces several warning messages concerning accuracy and the answer
Y = 1.0e+03 * 0.0000+ 0.0000i 4.9354- 7.6863i 0.0000+ 0.0000i 0.0000+ 0.0000iThe function
sqrtm(X) is an abbreviation for funm(X,'sqrt'). The algorithm used by funm is based on a Schur decomposition. It can fail in certain situations where X has repeated eigenvalues. See funm for details.
expm Matrix exponential
funm Evaluate functions of a matrix
logm Matrix logarithm