hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_matop_real_gen_matrix_fun_std (f01ek)

Purpose

nag_matop_real_gen_matrix_fun_std (f01ek) computes the matrix exponential, sine, cosine, sinh or cosh, of a real nn by nn matrix AA using the Schur–Parlett algorithm.

Syntax

[a, imnorm, ifail] = f01ek(fun, a, 'n', n)
[a, imnorm, ifail] = nag_matop_real_gen_matrix_fun_std(fun, a, 'n', n)

Description

f(A)f(A), where ff is either the exponential, sine, cosine, sinh or cosh, is computed using the Schur–Parlett algorithm described in Higham (2008) and Davies and Higham (2003).

References

Davies P I and Higham N J (2003) A Schur–Parlett algorithm for computing matrix functions. SIAM J. Matrix Anal. Appl. 25(2) 464–485
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 computed.
fun = 'exp'fun='exp'
The matrix exponential, eAeA, will be computed.
fun = 'sin'fun='sin'
The matrix sine, sin(A)sin(A), will be computed.
fun = 'cos'fun='cos'
The matrix cosine, cos(A)cos(A), will be computed.
fun = 'sinh'fun='sinh'
The hyperbolic matrix sine, sinh(A)sinh(A), will be computed.
fun = 'cosh'fun='cosh'
The hyperbolic matrix cosine, cosh(A)cosh(A), will be computed.
Constraint: fun = 'exp'fun='exp', 'sin''sin', 'cos''cos', 'sinh''sinh' or 'cosh''cosh'.
2:     a(lda, : :) – double array
The first dimension of the array a must be at least max (1,n)max(1,n)
The second dimension of the array must be at least nn
The nn by nn matrix AA.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The first dimension of the array a.
nn, the order of the matrix AA.
Constraint: n0n0.

Input Parameters Omitted from the MATLAB Interface

lda

Output Parameters

1:     a(lda, : :) – double array
The first dimension of the array a will be max (1,n)max(1,n)
The second dimension of the array will be nn
ldamax (1,n)ldamax(1,n).
The nn by nn matrix, f(A)f(A).
2:     imnorm – double scalar
If AA has complex eigenvalues, nag_matop_real_gen_matrix_fun_std (f01ek) will use complex arithmetic to compute the matrix function. The imaginary part is discarded at the end of the computation, because it will theoretically vanish. imnorm contains the 11-norm of the imaginary part, which should be used to check that the routine has given a reliable answer.
If AA has real eigenvalues, nag_matop_real_gen_matrix_fun_std (f01ek) uses real arithmetic and imnorm = 0imnorm=0.
3:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
A Taylor series failed to converge.
  ifail = 2ifail=2
An unexpected internal error occurred when evaluating the function at a point. Please contact NAG.
  ifail = 3ifail=3
There was an error whilst reordering the Schur form of AA.
Note:  this failure should not occur and suggests that the function has been called incorrectly.
  ifail = 4ifail=4
The function was unable to compute the Schur decomposition of AA.
Note:  this failure should not occur and suggests that the function has been called incorrectly.
  ifail = 5ifail=5
An unexpected internal error occurred. Please contact NAG.
  ifail = 6ifail=6
The linear equations to be solved are nearly singular and the Padé approximant used to compute the exponential may have no correct figures.
Note:  this failure should not occur and suggests that the function has been called incorrectly.
  ifail = 1ifail=-1
Input parameter number __ is invalid.
  ifail = 2ifail=-2
Input parameter number __ is invalid.
  ifail = 4ifail=-4
On entry, parameter lda is invalid.
Constraint: ldanldan.
  ifail = 999ifail=-999
Allocation of memory failed.

Accuracy

For a normal matrix AA (for which ATA = AATATA=AAT), the Schur decomposition is diagonal and the algorithm reduces to evaluating ff at the eigenvalues of AA and then constructing f(A)f(A) using the Schur vectors. This should give a very accurate result. In general, however, no error bounds are available for the algorithm.
For further discussion of the Schur–Parlett algorithm see Section 9.4 of Higham (2008).

Further Comments

The integer allocatable memory required is nn. If AA has real eigenvalues then up to 9n29n2 of double allocatable memory may be required. If AA has complex eigenvalues then up to 9n29n2 of complex allocatable memory may be required.
The cost of the Schur–Parlett algorithm depends on the spectrum of AA, but is roughly between 28n328n3 and n4 / 3n4/3 floating point operations; see Algorithm 9.6 of Higham (2008).
If the matrix exponential is required then it is recommended that nag_matop_real_gen_matrix_exp (f01ec) be used. nag_matop_real_gen_matrix_exp (f01ec) uses an algorithm which is, in general, more accurate than the Schur–Parlett algorithm used by nag_matop_real_gen_matrix_fun_std (f01ek).
If estimates of the condition number of the matrix function are required then nag_matop_real_gen_matrix_cond_std (f01ja) should be used.
nag_matop_complex_gen_matrix_fun_std (f01fk) can be used to find the matrix exponential, sin, cos, sinh or cosh of a complex matrix.

Example

function nag_matop_real_gen_matrix_fun_std_example
a =  [2,  0,  1,  0
      0,  2, -2,  1
      0,  2,  3,  1
      1,  4,  0,  0];
fun = 'cos';
% Compute cos(a)
[a, imnorm, ifail] = nag_matop_real_gen_matrix_fun_std(fun, a)
 

a =

   -0.2998    1.5003   -0.7849    0.4677
   -0.2385   -3.2657    0.5812   -1.1460
    0.4677    0.3008   -4.0853   -0.2200
   -0.2107   -2.8199   -1.2964   -0.8325


imnorm =

   3.3307e-16


ifail =

                    0


function f01ek_example
a =  [2,  0,  1,  0
      0,  2, -2,  1
      0,  2,  3,  1
      1,  4,  0,  0];
fun = 'cos';
% Compute cos(a)
[a, imnorm, ifail] = f01ek(fun, a)
 

a =

   -0.2998    1.5003   -0.7849    0.4677
   -0.2385   -3.2657    0.5812   -1.1460
    0.4677    0.3008   -4.0853   -0.2200
   -0.2107   -2.8199   -1.2964   -0.8325


imnorm =

   3.3307e-16


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013