MATLAB Function Reference
  Go to function:
    Search    Help Desk 
sqrtm    Examples   See Also

Matrix square root

Syntax

Description

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

Remarks

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.

Examples

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.

The matrix

has four square roots. Two of them are

and

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.

Finally, the matrix

does not have any square roots. There is no matrix Y, real or complex, for which Y*Y = X. The statement

produces several warning messages concerning accuracy and the answer

Algorithm

The 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.

See Also

expm        Matrix exponential

funm        Evaluate functions of a matrix

logm        Matrix logarithm



[ Previous | Help Desk | Next ]