Matrix square root - MATLAB sqrtm (2024)

Matrix square root

collapse all in page

Syntax

X = sqrtm(A)

[X,residual] = sqrtm(A)

[X,alpha,condx] = sqrtm(A)

Description

example

X = sqrtm(A) returnsthe principal square root of the matrix A, thatis, X*X = A.

X is the unique square root for which everyeigenvalue has nonnegative real part. If A hasany eigenvalues with negative real parts, then a complex result isproduced. If A is singular, then A mightnot have a square root. If exact singularity is detected, a warningis printed.

[X,residual] = sqrtm(A) alsoreturns the residual, residual = norm(A-X^2,1)/norm(A,1).This syntax does not print warnings if exact singularity is detected.

[X,alpha,condx] = sqrtm(A) returnsstability factor alpha and an estimate of the matrixsquare root condition number of X in 1-norm, condx.The residual norm(A-X^2,1)/norm(A,1) is boundedapproximately by n*alpha*eps and the 1-norm relativeerror in X is bounded approximately by n*alpha*condx*eps,where n=max(size(A)).

Examples

collapse all

Matrix Square Root of Difference Operator

Create a matrix representation of the fourth difference operator, A. This matrix is symmetric and positive definite.

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 6]
A = 5×5 5 -4 1 0 0 -4 6 -4 1 0 1 -4 6 -4 1 0 1 -4 6 -4 0 0 1 -4 6

Calculate the unique positive definite square root of A using sqrtm. X is the matrix representation of the second difference operator.

X = round(sqrtm(A))
X = 5×5 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

Matrix with Multiple Square Roots

Open Live Script

Consider a matrix that has four square roots, A.

A=[7101522]

Two of the square roots of A are given by Y1 and Y2:

Y1=[1.56671.74082.61124.1779]

Y2=[1234]

Confirm that Y1 and Y2 are square roots of matrix A.

A = [7 10; 15 22];Y1 = [1.5667 1.7408; 2.6112 4.1779];A - Y1*Y1
ans = 2×210-3 × -0.1258 -0.1997 -0.2995 -0.4254
Y2 = [1 2; 3 4];A - Y2*Y2
ans = 2×2 0 0 0 0

The other two square roots of A are -Y1 and -Y2. All four of these roots can be obtained from the eigenvalues and eigenvectors of A. If [V,D] = eig(A), then the square roots have the general form Y = V*S/V, where D = S*S and S has four choices of sign to produce four different values of Y:

S=[±0.372300±5.3723]

Calculate the square root of A with sqrtm. The sqrtm function chooses the positive square roots and produces Y1, even though Y2 seems to be a more natural result.

Y = sqrtm(A)
Y = 2×2 1.5667 1.7408 2.6112 4.1779

Input Arguments

collapse all

AInput matrix
square matrix

Input matrix, specified as a square matrix.

Data Types: single | double
Complex Number Support: Yes

Tips

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

Algorithms

The algorithm sqrtm uses is described in [3].

References

[1] N.J. Higham, “Computing real squareroots of a real matrix,” Linear Algebra and Appl.,88/89, pp. 405–430, 1987

[2] Bjorck, A. and S. Hammerling, “ASchur method for the square root of a matrix,” LinearAlgebra and Appl., 52/53, pp. 127–140, 1983

[3] Deadman, E., Higham, N. J. and R. Ralha,“Blocked Schur algorithms for computing the matrix square root,” LectureNotes in Comput. Sci., 7782, Springer-Verlag, pp. 171–182,2013

Extended Capabilities

Version History

Introduced before R2006a

See Also

expm | funm | logm

MATLAB Command

You clicked a link that corresponds to this MATLAB command:

 

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Matrix square root - MATLAB sqrtm (1)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

Contact your local office

Matrix square root - MATLAB sqrtm (2024)
Top Articles
Latest Posts
Article information

Author: Edwin Metz

Last Updated:

Views: 6001

Rating: 4.8 / 5 (58 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Edwin Metz

Birthday: 1997-04-16

Address: 51593 Leanne Light, Kuphalmouth, DE 50012-5183

Phone: +639107620957

Job: Corporate Banking Technician

Hobby: Reading, scrapbook, role-playing games, Fishing, Fishing, Scuba diving, Beekeeping

Introduction: My name is Edwin Metz, I am a fair, energetic, helpful, brave, outstanding, nice, helpful person who loves writing and wants to share my knowledge and understanding with you.