# expm

..  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>_

## Examples

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.