PDF version (NAG web site
, 64-bit version, 64-bit version)
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 by matrix using the Schur–Parlett algorithm.
Syntax
Description
, where
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:
– string
-
Indicates which matrix function will be computed.
- The matrix exponential, , will be computed.
- The matrix sine, , will be computed.
- The matrix cosine, , will be computed.
- The hyperbolic matrix sine, , will be computed.
- The hyperbolic matrix cosine, , will be computed.
Constraint:
, , , or .
- 2:
– double array
-
The first dimension of the array
a must be at least
.
The second dimension of the array
a must be at least
.
The by matrix .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the first dimension of the array
a.
, the order of the matrix .
Constraint:
.
Output Parameters
- 1:
– double array
-
The first dimension of the array
a will be
.
The second dimension of the array
a will be
.
The by matrix, .
- 2:
– double scalar
-
If
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
-norm of the imaginary part, which should be used to check that the routine has given a reliable answer.
If has real eigenvalues, nag_matop_real_gen_matrix_fun_std (f01ek) uses real arithmetic and .
- 3:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
A Taylor series failed to converge.
-
-
An unexpected internal error occurred when evaluating the function at a point. Please contact
NAG.
-
-
There was an error whilst reordering the Schur form of .
Note: this failure should not occur and suggests that the function has been called incorrectly.
-
-
The function was unable to compute the Schur decomposition of .
Note: this failure should not occur and suggests that the function has been called incorrectly.
-
-
An unexpected internal error occurred. Please contact
NAG.
-
-
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.
-
-
On entry, was an illegal value.
-
-
Input argument number is invalid.
-
-
On entry, argument lda is invalid.
Constraint: .
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
For a normal matrix (for which ), the Schur decomposition is diagonal and the algorithm reduces to evaluating at the eigenvalues of and then constructing 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 . If has real eigenvalues then up to of double allocatable memory may be required. If has complex eigenvalues then up to of complex allocatable memory may be required.
The cost of the Schur–Parlett algorithm depends on the spectrum of
, but is roughly between
and
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
This example finds the matrix cosine of the matrix
Open in the MATLAB editor:
f01ek_example
function f01ek_example
fprintf('f01ek example results\n\n');
a = [2, 0, 1, 0
0, 2, -2, 1
0, 2, 3, 1
1, 4, 0, 0];
fun = 'cos';
[cosa, imnorm, ifail] = f01ek(fun, a);
disp('f(A) = cos(A)');
disp(cosa);
fprintf('Imnorm = %6.2f\n',imnorm);
f01ek example results
f(A) = cos(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 = 0.00
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015