PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_matop_complex_gen_matrix_fun_num (f01fl)
Purpose
nag_matop_complex_gen_matrix_fun_num (f01fl) computes the matrix function, , of a complex by matrix . Numerical differentiation is used to evaluate the derivatives of when they are required.
Syntax
Description
is computed using the Schur–Parlett algorithm described in
Higham (2008) and
Davies and Higham (2003). The coefficients of the Taylor series used in the algorithm are evaluated using the numerical differentiation algorithm of
Lyness and Moler (1967).
The scalar function
is supplied via function
f which evaluates
at a number of points
.
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
Lyness J N and Moler C B (1967) Numerical differentiation of analytic functions SIAM J. Numer. Anal. 4(2) 202–210
Parameters
Compulsory Input Parameters
- 1:
– complex 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 .
- 2:
– function handle or string containing name of m-file
-
The function
f evaluates
at a number of points
.
[iflag, fz, user] = f(iflag, nz, z, user)
Input Parameters
- 1:
– int64int32nag_int scalar
-
- 2:
– int64int32nag_int scalar
-
, the number of function values required.
- 3:
– complex array
-
The points at which the function is to be evaluated.
- 4:
– Any MATLAB object
f is called from
nag_matop_complex_gen_matrix_fun_num (f01fl) with the object supplied to
nag_matop_complex_gen_matrix_fun_num (f01fl).
Output Parameters
- 1:
– int64int32nag_int scalar
-
iflag should either be unchanged from its entry value of zero, or may be set nonzero to indicate that there is a problem in evaluating the function
; for instance
may not be defined. If
iflag is returned as nonzero then
nag_matop_complex_gen_matrix_fun_num (f01fl) will terminate the computation, with
.
- 2:
– complex array
-
The function values.
should return the value , for .
- 3:
– Any MATLAB object
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the first dimension of the array
a.
, the order of the matrix .
Constraint:
.
- 2:
– Any MATLAB object
user is not used by
nag_matop_complex_gen_matrix_fun_num (f01fl), but is passed to
f. Note that for large objects it may be more efficient to use a global variable which is accessible from the m-files than to use
user.
Output Parameters
- 1:
– complex array
-
The first dimension of the array
a will be
.
The second dimension of the array
a will be
.
The by matrix, .
- 2:
– Any MATLAB object
- 3:
– int64int32nag_int scalar
-
, unless
iflag has been set nonzero inside
f, in which case
iflag will be the value set and
ifail will be set to
.
- 4:
– 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 after terms. Further Taylor series coefficients can no longer reliably be obtained by numerical differentiation.
-
-
iflag has been set nonzero by the user.
-
-
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.
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.
-
-
An unexpected internal error occurred. Please contact
NAG.
-
-
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
) Schur decomposition is diagonal and the algorithm reduces to evaluating
at the eigenvalues of
and then constructing
using the Schur vectors. See Section 9.4 of
Higham (2008) for further discussion of the Schur–Parlett algorithm, and
Lyness and Moler (1967) for a discussion of numerical differentiation.
Further Comments
The integer allocatable memory required is , and up to of complex allocatable memory is required.
The cost of the Schur–Parlett algorithm depends on the spectrum of
, but is roughly between
and
floating-point operations. There is an additional cost in numerically differentiating
, in order to obtain the Taylor series coefficients. If the derivatives of
are known analytically, then
nag_matop_complex_gen_matrix_fun_usd (f01fm) can be used to evaluate
more accurately. If
is complex Hermitian then it is recommended that
nag_matop_complex_herm_matrix_fun (f01ff) be used as it is more efficient and, in general, more accurate than
nag_matop_complex_gen_matrix_fun_num (f01fl).
Note that must be analytic in the region of the complex plane containing the spectrum of .
For further information on matrix functions, see
Higham (2008).
If estimates of the condition number of the matrix function are required then
nag_matop_complex_gen_matrix_cond_num (f01kb) should be used.
nag_matop_real_gen_matrix_fun_num (f01el) can be used to find the matrix function
for a real matrix
.
Example
This example finds
where
Open in the MATLAB editor:
f01fl_example
function f01fl_example
fprintf('f01fl example results\n\n');
a = [1.0+0.0i, 0.0+1.0i, 1.0+0.0i, 0.0+1.0i;
-1.0+0.0i, 0.0+0.0i, 2.0+1.0i, 0.0+0.0i;
0.0+0.0i, 2.0+1.0i, 0.0+2.0i, 0.0+1.0i;
1.0+0.0i, 1.0+1.0i, -1.0+0.0i, 2.0+1.0i];
[sin2a, user, iflag, ifail] = f01fl(a, @f);
disp('f(A) = sin(2A)');
disp(sin2a);
function [iflag, fz, user] = f(iflag, nz, z, user)
fz = sin(2*z);
f01fl example results
f(A) = sin(2A)
1.1960 - 3.2270i -21.0733 - 9.6441i -15.4159 -14.1977i -12.4279 -11.9638i
3.2957 - 3.6334i -14.6084 -21.4846i -6.7764 -24.1726i -5.1338 -17.0926i
5.0928 - 3.7806i -14.6839 -34.5063i -0.9231 -35.4729i -2.0715 -26.3460i
-1.8349 + 0.0808i -8.2484 - 0.4014i -6.0093 - 1.6831i -7.1318 - 1.9396i
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015