| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
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)).
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 5This 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 22has four square roots. Two of them are
Y1 =
1.5667 1.7408
2.6112 4.1779and
Y2 =
1 2
3 4The 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.8614The four square roots of the diagonal matrix D result from the four choices of sign in
S =
±0.3723 0
0 ±5.3723All 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.
![]() | sqrt | squeeze | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |