sqrtm
.. sqrtm(A)
If ``A`` has no negative real eigenvalues, compute the principal matrix square root of ``A``, that is the unique matrix :math:`X` with eigenvalues having positive real part such that :math:`X^2 = A`. Otherwise, a nonprincipal square root is returned.
If ``A`` is symmetric or Hermitian, its eigendecomposition (:func:`eigfact`) is used to compute the square root. Otherwise, the square root is determined by means of the Björck-Hammarling method, which computes the complex Schur form (:func:`schur`) and then the complex square root of the triangular factor.
.. [BH83] Åke Björck and Sven Hammarling, "A Schur method for the square root
of a matrix", Linear Algebra and its Applications, 52-53, 1983, 127-140.
`doi:10.1016/0024-3795(83)80010-X <http://dx.doi.org/10.1016/0024-3795(83)80010-X>`_
Examples
In the Julia programming language, the function sqrtm(A)
is used to compute the square root of a matrix A
. The behavior of this function depends on the properties of the input matrix. Here are some examples and explanations of its usage:
-
Compute the principal matrix square root of a symmetric matrix:
julia> A = [4 1; 1 3]; julia> sqrtm(A) 2×2 Array{Complex{Float64},2}: 1.73205+0.0im 0.258819+0.0im 0.258819+0.0im 1.73205+0.0im
In this example, the matrix
A
is symmetric, so its eigen decomposition is used to compute the square root. - Compute the matrix square root of a general matrix:
julia> A = [1 2; 3 4]; julia> sqrtm(A) 2×2 Array{Complex{Float64},2}: -0.37228+0.0im 0.824564-0.0im 1.02985+0.0im 0.186411+0.0im
Here, the input matrix
A
is not symmetric, so the Björck-Hammarling method is used to compute the square root.
It's important to note that sqrtm(A)
returns a complex matrix even if A
is real, as the square root of a real matrix can have complex entries.
Please refer to the [BH83] reference provided in the original documentation for further details on the algorithm used by the sqrtm
function.
See Also
Ac_ldiv_B, Ac_ldiv_Bc, Ac_mul_B, Ac_mul_Bc, Ac_rdiv_B, Ac_rdiv_Bc, At_ldiv_B, At_ldiv_Bt, At_mul_B, At_mul_Bt, At_rdiv_B, At_rdiv_Bt, A_ldiv_Bc, A_ldiv_Bt, A_mul_B!, A_mul_Bc, A_mul_Bt, A_rdiv_Bc, A_rdiv_Bt, Bidiagonal, cond, conv2, det, diag, diagind, diagm, diff, eig, eigvals, eigvecs, expm, eye, full, inv, isdiag, ishermitian, isposdef, isposdef!, issym, istril, istriu, logabsdet, logdet, lyap, norm, qrfact, rank, repmat, rot180, rotl90, rotr90, sortrows, sqrtm, SymTridiagonal, trace, Tridiagonal, tril, tril!, triu, triu!, writedlm,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.