﻿ f01fc Method
f01fc computes the matrix exponential, ${e}^{A}$, of a complex $n$ by $n$ matrix $A$.

# Syntax

C#
```public static void f01fc(
int n,
Complex[,] a,
out int ifail
)```
Visual Basic
```Public Shared Sub f01fc ( _
n As Integer, _
a As Complex(,), _
<OutAttribute> ByRef ifail As Integer _
)```
Visual C++
```public:
static void f01fc(
int n,
array<Complex,2>^ a,
[OutAttribute] int% ifail
)```
F#
```static member f01fc :
n : int *
a : Complex[,] *
ifail : int byref -> unit
```

#### Parameters

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}}$
Note: the second dimension of the array a must be at least ${\mathbf{n}}$.
On entry: the $n$ by $n$ matrix $A$.
On exit: with ${\mathbf{ifail}}={0}$, 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 Padé approximant and the scaling and squaring method described in Al–Mohy and Higham (2009).

# References

Al–Mohy A H and Higham N J (2009) A new scaling and squaring algorithm for the matrix exponential SIAM J. Matrix Anal. 31(3) 970–989
Higham N J (2005) The scaling and squaring method for the matrix exponential revisited SIAM J. Matrix Anal. Appl. 26(4) 1179–1193
Higham N J (2008) Functions of Matrices: Theory and Computation SIAM, Philadelphia, PA, USA
Moler 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}}=1$
The linear equations to be solved for the Padé approximant are singular; it is likely that this method has been called incorrectly.
${\mathbf{ifail}}=2$
The linear equations to be solved are nearly singular and the Padé approximant probably has no correct figures; it is likely that this method has been called incorrectly.
${\mathbf{ifail}}=3$
${e}^{A}$ has been computed using an IEEE double precision Padé approximant, although the arithmetic precision is higher than IEEE double precision.
${\mathbf{ifail}}=4$
${\mathbf{ifail}}=-1$
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 0$.
${\mathbf{ifail}}=-3$
On entry, ${\mathbf{lda}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{lda}}\ge {\mathbf{n}}$.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
${\mathbf{ifail}}=-9000$
An error occured, see message report.
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-4000$
Invalid dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-8000$
Negative dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$

# Accuracy

For a normal matrix $A$ (for which ${A}^{\mathrm{H}}A=A{A}^{\mathrm{H}}$) the computed matrix, ${e}^{A}$, is guaranteed to be close to the exact matrix, that is, the method is forward stable. No such guarantee can be given for non-normal matrices. See Al–Mohy and Higham (2009) and Section 10.3 of Higham (2008) for details and further discussion.
If estimates of the condition number of the matrix exponential are required then (F01KGF not in this release) should be used.

# Parallelism and Performance

None.

The cost of the algorithm is $O\left({n}^{3}\right)$; see Section 5 of Al–Mohy and Higham (2009). The complex allocatable memory required is approximately $6×{n}^{2}$.
If the Fréchet derivative of the matrix exponential is required then (F01KHF not in this release) should be used.
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 matrix
 $A=1+2i2+2i2+2i2+i3+2i112+i3+2i2+2i12+i3+2i3+2i3+2i1+i.$

Example program (C#): f01fce.cs

Example program data: f01fce.d

Example program results: f01fce.r