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_real_symm_matrix_exp (f01ed)

## Purpose

nag_matop_real_symm_matrix_exp (f01ed) computes the matrix exponential, eA${e}^{A}$, of a real symmetric n$n$ by n$n$ matrix A$A$.

## Syntax

[a, ifail] = f01ed(uplo, a, 'n', n)
[a, ifail] = nag_matop_real_symm_matrix_exp(uplo, a, 'n', n)

## Description

eA${e}^{A}$ is computed using a spectral factorization of A$A$
 A = Q D QT , $A = Q D QT ,$
where D$D$ is the diagonal matrix whose diagonal elements, di${d}_{i}$, are the eigenvalues of A$A$, and Q$Q$ is an orthogonal matrix whose columns are the eigenvectors of A$A$. eA${e}^{A}$ is then given by
 eA = Q eD QT , $eA = Q eD QT ,$
where eD${e}^{D}$ is the diagonal matrix whose i$i$th diagonal element is edi${e}^{{d}_{i}}$. See for example Section 4.5 of Higham (2008).

## References

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:     uplo – string (length ≥ 1)
Indicates whether the upper or lower triangular part of A$A$ is stored.
uplo = 'U'${\mathbf{uplo}}=\text{'U'}$
The upper triangular part of A$A$ is stored.
uplo = 'L'${\mathbf{uplo}}=\text{'L'}$
The lower triangular part of A$A$ is stored.
Constraint: uplo = 'U'${\mathbf{uplo}}=\text{'U'}$ or 'L'$\text{'L'}$.
2:     a(lda, : $:$) – double array
The first dimension of the array a must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The second dimension of the array must be at least n${\mathbf{n}}$
The n$n$ by n$n$ symmetric matrix A$A$.
• If uplo = 'U'${\mathbf{uplo}}=\text{'U'}$, the upper triangular part of a$a$ must be stored and the elements of the array below the diagonal are not referenced.
• If uplo = 'L'${\mathbf{uplo}}=\text{'L'}$, the lower triangular part of a$a$ must be stored and the elements of the array above the diagonal are not referenced.

### Optional Input Parameters

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

lda

### Output Parameters

1:     a(lda, : $:$) – double array
The first dimension of the array a will be max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The second dimension of the array will be n${\mathbf{n}}$
ldamax (1,n)$\mathit{lda}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
If ${\mathbf{ifail}}={\mathbf{0}}$, the upper or lower triangular part of the n$n$ by n$n$ matrix exponential, eA${e}^{A}$.
2:     ifail – int64int32nag_int scalar
${\mathrm{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:
ifail > 0${\mathbf{ifail}}>0$
The computation of the spectral factorization failed to converge.
ifail = 1${\mathbf{ifail}}=-1$
Constraint: uplo = 'L'${\mathbf{uplo}}=\text{'L'}$ or 'U'$\text{'U'}$.
ifail = 2${\mathbf{ifail}}=-2$
Constraint: n0${\mathbf{n}}\ge 0$.
ifail = 3${\mathbf{ifail}}=-3$
ifail = 4${\mathbf{ifail}}=-4$
Constraint: ldan$\mathit{lda}\ge {\mathbf{n}}$.
ifail = 999${\mathbf{ifail}}=-999$
Dynamic memory allocation failed. Dynamic memory allocation failed. Dynamic memory allocation failed.

## Accuracy

For a symmetric matrix A$A$, the matrix eA${e}^{A}$, has the relative condition number
 κ(A) = ‖A‖2 , $κ(A) = ‖A‖2 ,$
which is the minimum 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 cost of the algorithm is O(n3)$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

```function nag_matop_real_symm_matrix_exp_example
uplo = 'u';
a =  [1, 2, 3, 4;
0, 1, 2, 3;
0, 0, 1, 2;
0, 0, 0, 1];
% Compute exp(a)
[aOut, ifail] = nag_matop_real_symm_matrix_exp(uplo, a);
% Display results
[ifail] = nag_file_print_matrix_real_gen(uplo, 'n', aOut, 'Symmetric Exp(a)')
```
```
Symmetric Exp(a)
1          2          3          4
1   2675.3899  2193.0210  2193.2062  2675.2803
2              1798.3297  1797.8497  2193.2062
3                         1798.3297  2193.0210
4                                    2675.3899

ifail =

0

```
```function f01ed_example
uplo = 'u';
a =  [1, 2, 3, 4;
0, 1, 2, 3;
0, 0, 1, 2;
0, 0, 0, 1];
% Compute exp(a)
[aOut, ifail] = f01ed(uplo, a);
% Display results
[ifail] = x04ca(uplo, 'n', aOut, 'Symmetric Exp(a)')
```
```
Symmetric Exp(a)
1          2          3          4
1   2675.3899  2193.0210  2193.2062  2675.2803
2              1798.3297  1797.8497  2193.2062
3                         1798.3297  2193.0210
4                                    2675.3899

ifail =

0

```