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$f$ at a real n$n$ by n$n$ matrix A$A$ in the 1$1$-norm, where f$f$ is either the exponential, logarithm, sine, cosine, hyperbolic sine (sinh) or hyperbolic cosine (cosh). The evaluation of the matrix function, f(A)$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$f$ at A$A$, condabs(f,A)${\mathrm{cond}}_{\mathrm{abs}}\left(f,A\right)$ is given by the norm of the Fréchet derivative of f$f$, L(A)$L\left(A\right)$, which is defined by
 ‖L(X)‖ := maxE ≠ 0 (‖L(X,E)‖)/(‖E‖) , $‖L(X)‖ := maxE≠0 ‖L(X,E)‖ ‖E‖ ,$
where L(X,E)$L\left(X,E\right)$ is the Fréchet derivative in the direction E$E$. L(X,E)$L\left(X,E\right)$ is linear in E$E$ and can therefore be written as
 vec (L(X,E)) = K(X) vec(E) , $vec ( L(X,E) ) = K(X) vec(E) ,$
where the vec$\mathrm{vec}$ operator stacks the columns of a matrix into one vector, so that K(X)$K\left(X\right)$ is n2 × n2${n}^{2}×{n}^{2}$. nag_matop_real_gen_matrix_cond_std (f01ja) computes an estimate γ$\gamma$ such that γ K(X)1 $\gamma \le {‖K\left(X\right)‖}_{1}$, where K(X)1 [ n1 L(X)1 , n L(X)1 ] ${‖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
 condrel (f,A) = ( condabs (f,A) ‖A‖1 )/(‖f(A)‖1) . $cond rel (f,A) = cond abs (f,A) ‖A‖1 ‖f(A)‖ 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:     fun – string
Indicates which matrix function will be used.
fun = 'exp'${\mathbf{fun}}=\text{'exp'}$
The matrix exponential, eA${e}^{A}$, will be used.
fun = 'sin'${\mathbf{fun}}=\text{'sin'}$
The matrix sine, sin(A)$\mathrm{sin}\left(A\right)$, will be used.
fun = 'cos'${\mathbf{fun}}=\text{'cos'}$
The matrix cosine, cos(A)$\mathrm{cos}\left(A\right)$, will be used.
fun = 'sinh'${\mathbf{fun}}=\text{'sinh'}$
The hyperbolic matrix sine, sinh(A)$\mathrm{sinh}\left(A\right)$, will be used.
fun = 'cosh'${\mathbf{fun}}=\text{'cosh'}$
The hyperbolic matrix cosine, cosh(A)$\mathrm{cosh}\left(A\right)$, will be used.
fun = 'log'${\mathbf{fun}}=\text{'log'}$
The matrix logarithm, log(A)$\mathrm{log}\left(A\right)$, will be used.
Constraint: fun = 'exp'${\mathbf{fun}}=\text{'exp'}$, 'sin'$\text{'sin'}$, 'cos'$\text{'cos'}$, 'sinh'$\text{'sinh'}$, 'cosh'$\text{'cosh'}$ or 'log'$\text{'log'}$.
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$ matrix A$A$.

### Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The second 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)$.
The n$n$ by n$n$ matrix, f(A)$f\left(A\right)$.
2:     conda – double scalar
An estimate of the absolute condition number of f$f$ at A$A$.
3:     norma – double scalar
The 1$1$-norm of A$A$.
4:     normfa – double scalar
The 1$1$-norm of f(A)$f\left(A\right)$.
5:     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 = 1${\mathbf{ifail}}=1$
An internal error occurred when evaluating the matrix function f(A)$f\left(A\right)$. Please contact NAG.
ifail = 2${\mathbf{ifail}}=2$
An internal error occurred when estimating the norm of the Fréchet derivative of f$f$ at A$A$. Please contact NAG.
ifail = 1${\mathbf{ifail}}=-1$
On entry, fun = 'exp'${\mathbf{fun}}=\text{'exp'}$, 'sin'$\text{'sin'}$, 'cos'$\text{'cos'}$, 'sinh'$\text{'sinh'}$, 'cosh'$\text{'cosh'}$ or 'log'$\text{'log'}$.
Input parameter number _$_$ is invalid.
ifail = 2${\mathbf{ifail}}=-2$
On entry, n < 0${\mathbf{n}}<0$.
Input parameter number _$_$ is invalid.
ifail = 4${\mathbf{ifail}}=-4$
On entry, parameter lda is invalid.
Constraint: ldan$\mathit{lda}\ge {\mathbf{n}}$.
ifail = 999${\mathbf{ifail}}=-999$
Allocation of memory 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 γ K(X)1 $\gamma \le {‖K\left(X\right)‖}_{1}$ and K(X)1 [ n1 L(X)1 , n L(X)1 ] ${‖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 6n2$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(A)$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

```function nag_matop_real_gen_matrix_cond_std_example
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] = nag_matop_real_gen_matrix_cond_std(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 = nag_machine_precision;
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 and so the\nrelative condition number is undefined.\n');
end
```
```

F(a) = sinh(A)
Estimated absolute condition number is:  204.45
Estimated relative condition number is:    7.90

```
```function f01ja_example
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 and so the\nrelative condition number is undefined.\n');
end
```
```

F(a) = sinh(A)
Estimated absolute condition number is:  204.45
Estimated relative condition number is:    7.90

```