PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_matop_complex_gen_matrix_fun_usd (f01fm)
Purpose
nag_matop_complex_gen_matrix_fun_usd (f01fm) computes the matrix function, , of a complex by matrix , using analytical derivatives of you have supplied.
Syntax
Description
is computed using the Schur–Parlett algorithm described in
Higham (2008) and
Davies and Higham (2003).
The scalar function
, and the derivatives of
, are returned by the function
f which, given an integer
, should evaluate
at a number of points
, for
, on the complex plane.
nag_matop_complex_gen_matrix_fun_usd (f01fm) is therefore appropriate for functions that can be evaluated on the complex plane and whose derivatives, of arbitrary order, can also be evaluated on the complex plane.
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:
– 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
-
Given an integer
, the function
f evaluates
at a number of points
.
[iflag, fz, user] = f(m, iflag, nz, z, user)
Input Parameters
- 1:
– int64int32nag_int scalar
-
The order,
, of the derivative required.
If , should be returned. For , should be returned.
- 2:
– int64int32nag_int scalar
-
- 3:
– int64int32nag_int scalar
-
, the number of function or derivative values required.
- 4:
– complex array
-
The points at which the function is to be evaluated.
- 5:
– Any MATLAB object
f is called from
nag_matop_complex_gen_matrix_fun_usd (f01fm) with the object supplied to
nag_matop_complex_gen_matrix_fun_usd (f01fm).
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 for a particular
. If
iflag is returned as nonzero then
nag_matop_complex_gen_matrix_fun_usd (f01fm) will terminate the computation, with
.
- 2:
– complex array
-
The function or derivative 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_usd (f01fm), 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.
-
-
iflag has been set nonzero by the user.
-
-
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.
-
-
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. See Section 9.4 of
Higham (2008) for further discussion of the Schur–Parlett algorithm.
Further Comments
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 evaluating
and its derivatives.
If the derivatives of
are not known analytically, then
nag_matop_complex_gen_matrix_fun_num (f01fl) can be used to evaluate
using numerical differentiation.
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_usd (f01fm).
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_usd (f01kc) should be used.
nag_matop_real_gen_matrix_fun_usd (f01em) can be used to find the matrix function
for a real matrix
.
Example
This example finds the
where
Open in the MATLAB editor:
f01fm_example
function f01fm_example
fprintf('f01fm example results\n\n');
a = [ 1.0+0.0i, 0.0+0.0i, 1.0+0.0i, 0.0+2.0i;
0.0+1.0i, 1.0+0.0i, -1.0+0.0i, 1.0+0.0i;
-1.0+0.0i, 0.0+1.0i, 0.0+1.0i, 0.0+1.0i;
1.0+1.0i, 0.0+2.0i, -1.0+0.0i, 0.0+1.0i];
[exp3a, user, iflag, ifail] = f01fm(a, @f);
disp('f(A) = exp(3A)');
disp(exp3a);
function [iflag, fz, user] = f(m, iflag, nz, z, user)
fz = double(3^m)*exp(3*z);
f01fm example results
f(A) = exp(3A)
-10.3264 +14.8082i -1.4883 +74.3369i -12.1206 -47.0956i 41.5622 +32.2927i
63.3909 -40.5336i -21.0117 -62.7073i 16.5106 +35.2787i -5.1725 +17.9413i
-6.3954 +56.4708i 25.4246 +13.8034i -14.4937 - 9.2397i -20.3167 + 2.8647i
31.4957 +23.2757i 28.6003 +21.4573i -23.8034 -11.6547i 23.9841 +18.7737i
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015