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_gen_matrix_cond_std (f01ja)

## Purpose

nag_matop_real_gen_matrix_cond_std (f01ja) computes an estimate of the absolute condition number of a matrix function $f$ at a real $n$ by $n$ matrix $A$ in the $1$-norm, where $f$ is either the exponential, logarithm, sine, cosine, hyperbolic sine (sinh) or hyperbolic cosine (cosh). The evaluation of the matrix function, $f\left(A\right)$, is also returned.

## Syntax

[a, conda, norma, normfa, ifail] = f01ja(fun, a, 'n', n)
[a, conda, norma, normfa, ifail] = nag_matop_real_gen_matrix_cond_std(fun, a, 'n', n)

## Description

The absolute condition number of $f$ at $A$, ${\mathrm{cond}}_{\mathrm{abs}}\left(f,A\right)$ is given by the norm of the Fréchet derivative of $f$, $L\left(A\right)$, which is defined by
 $LX := maxE≠0 LX,E E ,$
where $L\left(X,E\right)$ is the Fréchet derivative in the direction $E$. $L\left(X,E\right)$ is linear in $E$ and can therefore be written as
 $vec LX,E = KX vecE ,$
where the $\mathrm{vec}$ operator stacks the columns of a matrix into one vector, so that $K\left(X\right)$ is ${n}^{2}×{n}^{2}$. nag_matop_real_gen_matrix_cond_std (f01ja) computes an estimate $\gamma$ such that $\gamma \le {‖K\left(X\right)‖}_{1}$, where ${‖K\left(X\right)‖}_{1}\in \left[{n}^{-1}{‖L\left(X\right)‖}_{1},n{‖L\left(X\right)‖}_{1}\right]$. The relative condition number can then be computed via
 $cond rel f,A = cond abs f,A A1 fA 1 .$
The algorithm used to find $\gamma$ is detailed in Section 3.4 of Higham (2008).

## References

Higham N J (2008) Functions of Matrices: Theory and Computation SIAM, Philadelphia, PA, USA

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{fun}$ – string
Indicates which matrix function will be used.
${\mathbf{fun}}=\text{'exp'}$
The matrix exponential, ${e}^{A}$, will be used.
${\mathbf{fun}}=\text{'sin'}$
The matrix sine, $\mathrm{sin}\left(A\right)$, will be used.
${\mathbf{fun}}=\text{'cos'}$
The matrix cosine, $\mathrm{cos}\left(A\right)$, will be used.
${\mathbf{fun}}=\text{'sinh'}$
The hyperbolic matrix sine, $\mathrm{sinh}\left(A\right)$, will be used.
${\mathbf{fun}}=\text{'cosh'}$
The hyperbolic matrix cosine, $\mathrm{cosh}\left(A\right)$, will be used.
${\mathbf{fun}}=\text{'log'}$
The matrix logarithm, $\mathrm{log}\left(A\right)$, will be used.
Constraint: ${\mathbf{fun}}=\text{'exp'}$, $\text{'sin'}$, $\text{'cos'}$, $\text{'sinh'}$, $\text{'cosh'}$ or $\text{'log'}$.
2:     $\mathrm{a}\left(\mathit{lda},:\right)$ – double 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$ matrix $A$.

### Optional Input Parameters

1:     $\mathrm{n}$int64int32nag_int scalar
Default: the first dimension of the array a and the second dimension of the array a. (An error is raised if these dimensions are not equal.)
$n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.

### Output Parameters

1:     $\mathrm{a}\left(\mathit{lda},:\right)$ – double array
The first dimension of the array a will be ${\mathbf{n}}$.
The second dimension of the array a will be ${\mathbf{n}}$.
The $n$ by $n$ matrix, $f\left(A\right)$.
2:     $\mathrm{conda}$ – double scalar
An estimate of the absolute condition number of $f$ at $A$.
3:     $\mathrm{norma}$ – double scalar
The $1$-norm of $A$.
4:     $\mathrm{normfa}$ – double scalar
The $1$-norm of $f\left(A\right)$.
5:     $\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}}=1$
An internal error occurred when evaluating the matrix function $f\left(A\right)$. Please contact NAG.
${\mathbf{ifail}}=2$
An internal error occurred when estimating the norm of the Fréchet derivative of $f$ at $A$. Please contact NAG.
${\mathbf{ifail}}=-1$
On entry, ${\mathbf{fun}}=_$ was an illegal value.
${\mathbf{ifail}}=-2$
On entry, ${\mathbf{n}}<0$.
Input argument number $_$ is invalid.
${\mathbf{ifail}}=-4$
On entry, argument lda is invalid.
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

nag_matop_real_gen_matrix_cond_std (f01ja) uses the norm estimation function nag_linsys_real_gen_norm_rcomm (f04yd) to estimate a quantity $\gamma$, where $\gamma \le {‖K\left(X\right)‖}_{1}$ and ${‖K\left(X\right)‖}_{1}\in \left[{n}^{-1}{‖L\left(X\right)‖}_{1},n{‖L\left(X\right)‖}_{1}\right]$. For further details on the accuracy of norm estimation, see the documentation for nag_linsys_real_gen_norm_rcomm (f04yd).

The matrix function is computed using one of three underlying matrix function routines:
Approximately $6{n}^{2}$ of real allocatable memory is required by the routine, in addition to the memory used by these underlying matrix function routines.
If only $f\left(A\right)$ is required, without an estimate of the condition number, then it is far more efficient to use the appropriate matrix function routine listed above.
nag_matop_complex_gen_matrix_cond_std (f01ka) can be used to find the condition number of the exponential, logarithm, sine, cosine, sinh or cosh matrix functions at a complex matrix.

## Example

This example estimates the absolute and relative condition numbers of the matrix sinh function where
 $A = 2 1 3 1 3 -1 0 2 1 0 3 1 1 2 0 3 .$
```function f01ja_example

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

a = [2,   1,   3,   1;
3,  -1,   0,   2;
1,   0,   3,   1;
1,   2,   0,   3];
fun = 'sinh';

% Find absolute condition number estimate
[a, conda, norma, normfa, ifail] = f01ja( ...
fun, a);

fprintf('\nf(A) = %s(A)\n', fun);
fprintf('Estimated absolute condition number is: %7.2f\n', conda);

%  Find relative condition number estimate
eps = x02aj;
if normfa > eps
cond_rel = conda*norma/normfa;
fprintf('Estimated relative condition number is: %7.2f\n', cond_rel);
else
fprintf('The estimated norm of f(A) is effectively zero;\n');
fprintf('the relative condition number is therefore undefined.\n');
end

```
```f01ja example results

f(A) = sinh(A)
Estimated absolute condition number is:  204.45
Estimated relative condition number is:    7.90
```