MATLAB Function Reference    

Matrix square root



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.


Example 1. A matrix representation of the fourth difference operator is

This matrix is symmetric and positive definite. Its unique positive definite square root, Y = sqrtm(X), is a representation of the second difference operator.

Example 2. The matrix

has four square roots. Two of them are


The other two are -Y1 and -Y2. All four can be obtained from the eigenvalues and vectors of X.

The four square roots of the diagonal matrix D result from the four choices of sign in

All four Ys are of the form

The sqrtm function chooses the two plus signs and produces Y1, even though Y2 is more natural because its entries are integers.

See Also

expm, funm, logm

  sqrt squeeze