# Syntax

C# |
---|

public static void f01fd( string uplo, int n, Complex[,] a, out int ifail ) |

Visual Basic |
---|

Public Shared Sub f01fd ( _ uplo As String, _ n As Integer, _ a As Complex(,), _ <OutAttribute> ByRef ifail As Integer _ ) |

Visual C++ |
---|

public: static void f01fd( String^ uplo, int n, array<Complex,2>^ a, [OutAttribute] int% ifail ) |

F# |
---|

static member f01fd : uplo : string * n : int * a : Complex[,] * ifail : int byref -> unit |

#### Parameters

- uplo
- Type: System..::..String
*On entry*: if ${\mathbf{uplo}}=\text{"U"}$, the upper triangle of the matrix $A$ is stored.If ${\mathbf{uplo}}=\text{"L"}$, the lower triangle of the matrix $A$ is stored.*Constraint*: ${\mathbf{uplo}}=\text{"U"}$ or $\text{"L"}$.

- n
- Type: System..::..Int32
*On entry*: $n$, the order of the matrix $A$.*Constraint*: ${\mathbf{n}}\ge 0$.

- a
- Type: array<NagLibrary..::..Complex,2>[,](,)[,][,]An array of size [dim1, dim2]
**Note:**dim1 must satisfy the constraint: $\mathrm{dim1}\ge {\mathbf{n}}$*On entry*: the $n$ by $n$ Hermitian matrix $A$.- If ${\mathbf{uplo}}=\text{"U"}$, the upper triangular part of $A$ must be stored and the elements of the array below the diagonal are not referenced.
- If ${\mathbf{uplo}}=\text{"L"}$, the lower triangular part of $A$ must be stored and the elements of the array above the diagonal are not referenced.

*On exit*: if ${\mathbf{ifail}}={0}$, the upper or lower triangular part of the $n$ by $n$ matrix exponential, ${e}^{A}$.

- ifail
- Type: System..::..Int32%
*On exit*: ${\mathbf{ifail}}={0}$ unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

# Description

${e}^{A}$ is computed using a spectral factorization of $A$

where $D$ is the diagonal matrix whose diagonal elements, ${d}_{i}$, are the eigenvalues of $A$, and $Q$ is a unitary matrix whose columns are the eigenvectors of $A$. ${e}^{A}$ is then given by

where ${e}^{D}$ is the diagonal matrix whose $i$th diagonal element is ${e}^{{d}_{i}}$. See for example Section 4.5 of Higham (2008).

$$A=QD{Q}^{\mathrm{H}}\text{,}$$ |

$${e}^{A}=Q{e}^{D}{Q}^{\mathrm{H}}\text{,}$$ |

# References

Higham N J (2005) The scaling and squaring method for the matrix exponential revisited

*SIAM J. Matrix Anal. Appl.***26(4)**1179–1193Higham N J (2008)

*Functions of Matrices: Theory and Computation*SIAM, Philadelphia, PA, USAMoler C B and Van Loan C F (2003) Nineteen dubious ways to compute the exponential of a matrix, twenty-five years later

*SIAM Rev.***45**3–49# Error Indicators and Warnings

Errors or warnings detected by the method:

Some error messages may refer to parameters that are dropped from this interface
(LDA) In these
cases, an error in another parameter has usually caused an incorrect value to be inferred.

- ${\mathbf{ifail}}<0\hspace{0.17em}\text{and}\hspace{0.17em}{\mathbf{ifail}}\ne -999$
- If ${\mathbf{ifail}}={-}{i}$, the $i$th argument had an illegal value.

- ${\mathbf{ifail}}=-999$

- ${\mathbf{ifail}}=i\hspace{0.17em}\text{and}\hspace{0.17em}{\mathbf{ifail}}>0$
- The algorithm to compute the spectral factorization failed to converge; $i$ off-diagonal elements of an intermediate tridiagonal form did not converge to zero (see f08fn).
**Note:**this failure is unlikely to occur.

- ${\mathbf{ifail}}=-9000$
- An error occured, see message report.
- ${\mathbf{ifail}}=-6000$
- Invalid Parameters $\u2329\mathit{\text{value}}\u232a$
- ${\mathbf{ifail}}=-4000$
- Invalid dimension for array $\u2329\mathit{\text{value}}\u232a$
- ${\mathbf{ifail}}=-8000$
- Negative dimension for array $\u2329\mathit{\text{value}}\u232a$
- ${\mathbf{ifail}}=-6000$
- Invalid Parameters $\u2329\mathit{\text{value}}\u232a$

# Accuracy

For an Hermitian matrix $A$, the matrix ${e}^{A}$, has the relative condition number

which is the minimal possible for the matrix exponential and so the computed matrix exponential is guaranteed to be close to the exact matrix. See Section 10.2 of Higham (2008) for details and further discussion.

$$\kappa \left(A\right)={\Vert A\Vert}_{2}\text{,}$$ |

# Parallelism and Performance

None.

# Further Comments

The cost of the algorithm is $O\left({n}^{3}\right)$.

As well as the excellent book cited above, the classic reference for the computation of the matrix exponential is Moler and Van Loan (2003).

# Example

This example finds the matrix exponential of the Hermitian matrix

$$A=\left(\begin{array}{cccc}1& 2+\phantom{2}i& 3+2i& 4+3i\\ 2-\phantom{2}i& 1& 2+\phantom{2}i& 3+2i\\ 3-2i& 2-\phantom{2}i& 1& 2+\phantom{2}i\\ 4-3i& 3-2i& 2-\phantom{2}i& 1\end{array}\right)\text{.}$$ |

Example program (C#): f01fde.cs