Skip to Main Content Skip to Search
Product Documentation

sqrtm - Matrix square root

Syntax

X = sqrtm(A)
[X, resnorm] = sqrtm(A)
[X, alpha, condest] = sqrtm(A)

Description

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

Tips

If A is real, symmetric and positive definite, or complex, Hermitian and positive definite, then so is the computed matrix square root.

Some matrices, like A = [0 1; 0 0], do not have any square roots, real or complex, and sqrtm cannot be expected to produce one.

Examples

Example 1

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 

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

See Also

expm | funm | logm

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS