# ExponentialAction

## Introduction

`ExponentialAction.jl`

is a lightweight package that implements the action of the Matrix exponential using the algorithm of Al-Mohy and Higham ^{[AlMohyHigham2011]}^{[Expmv]}. For details, see the docstring of `expv`

.

This is the same algorithm used by SciPy's `expm_multiply`

.

While `exp(X)`

is only defined in LinearAlgebra for `Diagonal`

, `Symmetric{<:Real}`

/`Hermitian`

, and `StridedMatrix`

, `expv`

can take an arbitrary matrix type.

## Example

`julia> using LinearAlgebra, ExponentialAction`

`julia> A = [1.0 2.0; -2.0 3.0];`

`julia> B = [1.0, 2.0];`

`julia> exp(A) * B`

`2-element Vector{Float64}: 11.445823453626826 -2.372722541157027`

`julia> expv(1, A, B)`

`2-element Vector{Float64}: 11.44582345362683 -2.3727225411570245`

`julia> exp(2A) * B`

`2-element Vector{Float64}: -81.7559133436684 -103.56648780897383`

`julia> expv(2, A, B)`

`2-element Vector{Float64}: -81.75591334366831 -103.56648780897383`

## Automatic Differentiation (AD)

Special care has been taken to ensure that `expv`

can be differentiated using `ForwardDiff.jl`

, `ReverseDiff.jl`

, `ChainRules.jl`

-compatible packages (e.g. `Zygote.jl`

), and likely others as a result.

This has been achieved by avoiding type constraints, not mutating any arrays, and marking operations only used for control flow as being non-differentiable.

## Related Packages

`ExponentialUtilities.jl`

and `Expokit.jl`

both implement an approximation to the action of the matrix exponential using Krylov subspaces. Which package is most efficient or useful depends on the choice of matrix and whether derivatives are needed. If efficiency is important, we recommend choosing from the packages by benchmarking against several of your matrices (if applicable).

The packages use different default tolerances. `ExponentialAction.jl`

is more strict. For a fair comparison, select similar tolerances.

- AlMohyHigham2011Al-Mohy, Awad H. and Higham, Nicholas J. (2011) Computing the Action of the Matrix Exponential, with an Application to Exponential Integrators. SIAM Journal on Scientific Computing, 33 (2). pp. 488-511. ISSN 1064-8275 doi: 10.1137/100788860, eprint: eprints.maths.manchester.ac.uk/id/eprint/1591
- Expmvhttps://github.com/higham/expmv