Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_matop_complex_herm_matrix_exp (f01fd)

## Purpose

nag_matop_complex_herm_matrix_exp (f01fd) computes the matrix exponential, ${e}^{A}$, of a complex Hermitian $n$ by $n$ matrix $A$.

## Syntax

[a, ifail] = f01fd(uplo, a, 'n', n)
[a, ifail] = nag_matop_complex_herm_matrix_exp(uplo, a, 'n', n)

## Description

${e}^{A}$ is computed using a spectral factorization of $A$
 $A = Q D QH ,$
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
 $eA = Q eD QH ,$
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).

## References

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

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{uplo}$ – string (length ≥ 1)
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'}$.
2:     $\mathrm{a}\left(\mathit{lda},:\right)$ – complex array
The first dimension of the array a must be at least ${\mathbf{n}}$.
The second dimension of the array a must be at least ${\mathbf{n}}$.
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.

### Optional Input Parameters

1:     $\mathrm{n}$int64int32nag_int scalar
Default: the first dimension of the array a.
$n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.

### Output Parameters

1:     $\mathrm{a}\left(\mathit{lda},:\right)$ – complex array
The first dimension of the array a will be ${\mathbf{n}}$.
The second dimension of the array a will be ${\mathbf{n}}$.
If ${\mathbf{ifail}}={\mathbf{0}}$, the upper or lower triangular part of the $n$ by $n$ matrix exponential, ${e}^{A}$.
2:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{0}}$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

Errors or warnings detected by the function:
${\mathbf{ifail}}>0$
The computation of the spectral factorization failed to converge.
${\mathbf{ifail}}=-1$
On entry, uplo was invalid.
${\mathbf{ifail}}=-2$
Constraint: ${\mathbf{n}}\ge 0$.
${\mathbf{ifail}}=-3$
${\mathbf{ifail}}=-4$
Constraint: $\mathit{lda}\ge {\mathbf{n}}$.
${\mathbf{ifail}}=-99$
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

## Accuracy

For an Hermitian matrix $A$, the matrix ${e}^{A}$, has the relative condition number
 $κA = A2 ,$
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.

The integer allocatable memory required is n, the double allocatable memory required is n and the complex allocatable memory required is approximately $\left({\mathbf{n}}+\mathit{nb}+1\right)×{\mathbf{n}}$, where nb is the block size required by nag_lapack_zheev (f08fn).
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 = 1 2+2i 3+2i 4+3i 2-2i 1 2+2i 3+2i 3-2i 2-2i 1 2+2i 4-3i 3-2i 2-2i 1 .$
```function f01fd_example

fprintf('f01fd example results\n\n');

uplo = 'u';
a = [1,  2 + 1i,  3 + 2i,  4 + 3i;
0,  1 + 0i,  2 + 1i,  3 + 2i;
0,  0,       1 + 0i,  2 + 1i;
0,  0,       0,       1 + 0i];

% Compute exp(a)
[expa, ifail] = f01fd(uplo, a);

% Display results
[ifail] = x04da(uplo, 'n', expa, 'Hermitian Exp(a)');

```
```f01fd example results

Hermitian Exp(a)
1            2            3            4
1    1.1457E+04   8.7983E+03   7.8120E+03   8.3103E+03
0.0000E+00   2.0776E+03   4.5500E+03   7.8871E+03

2                 7.1339E+03   6.8242E+03   7.8120E+03
0.0000E+00   2.0776E+03   4.5500E+03

3                              7.1339E+03   8.7983E+03
0.0000E+00   2.0776E+03

4                                           1.1457E+04
0.0000E+00
```