Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

sqrtm

Matrix square root

Syntax

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

Description

X = sqrtm(A) returns a matrix X, such that X2 = A and the eigenvalues of X are the square roots of the eigenvalues of A.

[X,resnorm] = sqrtm(A) returns a matrix X and the residual norm(A-X^2,'fro')/norm(A,'fro').

Input Arguments

A

Symbolic matrix.

Output Arguments

X

Matrix, such that X2 = A.

resnorm

Residual computed as norm(A-X^2,'fro')/norm(A,'fro').

Examples

Compute the square root of this matrix. Because these numbers are not symbolic objects, you get floating-point results.

A = [2 -2 0; -1 3 0; -1/3 5/3 2];
X = sqrtm(A)
X =
    1.3333   -0.6667    0.0000
   -0.3333    1.6667   -0.0000
   -0.0572    0.5286    1.4142

Now, convert this matrix to a symbolic object, and compute its square root again:

A = sym([2 -2 0; -1 3 0; -1/3 5/3 2]);
X = sqrtm(A)
X =
[               4/3,          -2/3,       0]
[              -1/3,           5/3,       0]
[ (2*2^(1/2))/3 - 1, 1 - 2^(1/2)/3, 2^(1/2)]

Check the correctness of the result:

isAlways(X^2 == A)
ans =
  3×3 logical array
   1   1   1
   1   1   1
   1   1   1

Use the syntax with two output arguments to return the square root of a matrix and the residual:

A = vpa(sym([0 0; 0 5/3]), 100);
[X,resnorm] = sqrtm(A)
X =
[ 0,                                 0]
[ 0, 1.2909944487358056283930884665941]
 
resnorm =
2.9387358770557187699218413430556e-40

More About

collapse all

Square Root of Matrix

The square root of a matrix A is a matrix X, such that X2 = A and the eigenvalues of X are the square roots of the eigenvalues of A.

Tips

  • Calling sqrtm for a matrix that is not a symbolic object invokes the MATLAB® sqrtm function.

  • If A has an eigenvalue 0 of algebraic multiplicity larger than its geometric multiplicity, the square root of A does not exist.

See Also

| | | | | |

Introduced in R2013a

Was this topic helpful?