主要内容

sqrtm

Matrix square root

Description

example

X = sqrtm(A)returns the principal square root of the matrixA, that is,X*X = A.

Xis the unique square root for which every eigenvalue has nonnegative real part. IfAhas any eigenvalues with negative real parts, then a complex result is produced. IfAis singular, thenA可能没有a square root. If exact singularity is detected, a warning is printed.

[X,residual] = sqrtm(A)also returns 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)returns stability factoralphaand an estimate of the matrix square root condition number ofXin 1-norm,condx. The residualnorm(A-X^2,1)/norm(A,1)is bounded approximately byn*alpha*epsand the 1-norm relative error inXis bounded approximately byn*alpha*condx*eps, wheren = max(size(A)).

Examples

collapse all

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×55 -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 ofAusingsqrtm.Xis the matrix representation of the second difference operator.

X = round(sqrtm(A))
X =5×52 -1 0 0 0 -1 2 -1 0 0 0 -1 2 -1 0 0 0 -1 2 -1 0 0 0 -1 2

Consider a matrix that has four squareroots,A.

A = [ 7 1 0 1 5 2 2 ]

Two of the squareroots ofAare given byY1andY2:

Y 1 = [ 1 . 5 6 6 7 1 . 7 4 0 8 2 . 6 1 1 2 4 . 1 7 7 9 ]

Y 2 = [ 1 2 3 4 ]

Confirm thatY1andY2are squareroots of matrixA.

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×20 0 0 0

The other two squareroots ofAare-Y1and-Y2. All four of these roots can be obtained from the eigenvalues and eigenvectors ofA. If[V,D] = eig(A), then the squareroots have the general formY = V*S/V, whereD = S*SandShas four choices of sign to produce four different values ofY:

S = [ ± 0 . 3 7 2 3 0 0 ± 5 . 3 7 2 3 ]

Calculate the squareroot ofAwithsqrtm. Thesqrtmfunction chooses the positive square roots and producesY1, even thoughY2seems to be a more natural result.

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

Input Arguments

collapse all

Input matrix, specified as a square matrix.

Data Types:single|double
Complex Number Support:Yes

Tips

  • Some matrices, likeA = [0 1; 0 0], do not have any square roots, real or complex, andsqrtmcannot be expected to produce one.

Algorithms

The algorithmsqrtmuses is described in[3].

References

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

[2] Bjorck, A. and S. Hammerling, “A Schur method for the square root of a matrix,”Linear Algebra 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,”Lecture Notes in Comput. Sci., 7782,气象出版社,页171–182, 2013

Extended Capabilities

See Also

||

Introduced before R2006a