sqrtm
Matrix square root.
Syntax
Section titled “Syntax”X = sqrtm(A)[X, resnorm] = sqrtm(A)[X, alpha, condest] = sqrtm(A)Description
Section titled “Description”Returns the principal matrix square root X such that X * X = A. Uses the Schur method.
With two outputs, returns the residual norm resnorm = norm(A - X*X) / norm(A). With three outputs, returns a stability indicator alpha and a 1-norm condition estimate condest for the square-root problem.
A should not have non-positive real eigenvalues — those produce complex results that may not be the principal square root you want.
Examples
Section titled “Examples”A = [4 0; 0 9];sqrtm(A) % [2 0; 0 3]X = sqrtm(magic(3));norm(X*X - magic(3)) % near-zero