..  expm(A)

Compute the matrix exponential of ``A``, defined by

.. math::

   e^A = \sum_{n=0}^{\infty} \frac{A^n}{n!}.

For symmetric or Hermitian ``A``, an eigendecomposition (:func:`eigfact`) is used, otherwise the scaling and squaring algorithm (see [H05]_) is chosen.

.. [H05] Nicholas J. Higham, "The squaring and scaling method for the matrix
   exponential revisited", SIAM Journal on Matrix Analysis and Applications,
   26(4), 2005, 1179-1193.
   `doi:10.1137/090768539 <http://dx.doi.org/10.1137/090768539>`_


The expm function in Julia is used to compute the matrix exponential of a given matrix A. The matrix exponential is defined by the formula:

e^A = sum_{n=0}^{∞} (A^n / n!)

For symmetric or Hermitian matrices A, the function uses an eigendecomposition (eigfact) to compute the matrix exponential. For other matrices, it employs the scaling and squaring algorithm as described in [H05]_.

Here are some examples of using the expm function:

  1. Compute matrix exponential for a 2x2 matrix:

    julia> A = [1.0 2.0; 3.0 4.0];
    julia> expm(A)
    2×2 Array{Float64,2}:
    48.0416   71.3834
    104.195  154.079

    This example computes the matrix exponential of a 2x2 matrix A.

  2. Calculate matrix exponential for a symmetric matrix:

    julia> A = [1.0 2.0; 2.0 4.0];
    julia> expm(A)
    2×2 Array{Float64,2}:
    5.21229  10.4246
    10.4246  20.8492

    In this case, the matrix A is symmetric, so the eigendecomposition method is used.

  3. Find matrix exponential for a complex matrix:
    julia> A = [0.0 1.0; -1.0 0.0];
    julia> expm(A)
    2×2 Array{Complex{Float64},2}:
    0.540302+0.841471im   -0.841471+0.540302im
    -0.841471-0.540302im  0.540302-0.841471im

    Here, the matrix A is complex, and the scaling and squaring algorithm is used.

Please note that the examples provided assume that the LinearAlgebra module has been imported.

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.

*Required Field

Checking you are not a robot: