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_log (f01ej)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_matop_real_gen_matrix_log (f01ej) computes the principal matrix logarithm, logA, of a real n by n matrix A, with no eigenvalues on the closed negative real line.

Syntax

[a, imnorm, ifail] = f01ej(a, 'n', n)
[a, imnorm, ifail] = nag_matop_real_gen_matrix_log(a, 'n', n)

Description

Any nonsingular matrix A has infinitely many logarithms. For a matrix with no eigenvalues on the closed negative real line, the principal logarithm is the unique logarithm whose spectrum lies in the strip z:-π<Imz<π.
logA is computed using the inverse scaling and squaring algorithm for the matrix logarithm described in Al–Mohy and Higham (2011), adapted to real matrices by Al–Mohy et al. (2012).

References

Al–Mohy A H and Higham N J (2011) Improved inverse scaling and squaring algorithms for the matrix logarithm SIAM J. Sci. Comput. 34(4) C152–C169
Al–Mohy A H, Higham N J and Relton S D (2012) Computing the Fréchet derivative of the matrix logarithm and estimating the condition number MIMS EPrint 2012.72
Higham N J (2008) Functions of Matrices: Theory and Computation SIAM, Philadelphia, PA, USA

Parameters

Compulsory Input Parameters

1:     alda: – double array
The first dimension of the array a must be at least n.
The second dimension of the array a must be at least n.
The n by n matrix A.

Optional Input Parameters

1:     n int64int32nag_int scalar
Default: the second dimension of the array a and the first dimension of the array a. (An error is raised if these dimensions are not equal.)
n, the order of the matrix A.
Constraint: n0.

Output Parameters

1:     alda: – double array
The first dimension of the array a will be n.
The second dimension of the array a will be n.
The n by n principal matrix logarithm, logA.
2:     imnorm – double scalar
If the function has given a reliable answer then imnorm=0.0. If imnorm differs from 0.0 by more than unit roundoff (as returned by nag_machine_precision (x02aj)) then the computed matrix logarithm is unreliable.
3:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

   ifail=1
A is singular so the logarithm cannot be computed.
   ifail=2
A was found to have eigenvalues on the negative real line. The principal logarithm is not defined in this case. nag_matop_complex_gen_matrix_log (f01fj) can be used to find a complex non-principal logarithm.
W  ifail=3
logA has been computed using an IEEE double precision Padé approximant, although the arithmetic precision is higher than IEEE double precision.
   ifail=4
An unexpected internal error occurred. Please contact NAG.
   ifail=-1
Constraint: n0.
   ifail=-3
Constraint: ldan.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

For a normal matrix A (for which ATA=AAT), the Schur decomposition is diagonal and the algorithm reduces to evaluating the logarithm of the eigenvalues of A and then constructing logA using the Schur vectors. This should give a very accurate result. In general, however, no error bounds are available for the algorithm. See Al–Mohy and Higham (2011) and Section 9.4 of Higham (2008) for details and further discussion.
The sensitivity of the computation of logA is worst when A has an eigenvalue of very small modulus or has a complex conjugate pair of eigenvalues lying close to the negative real axis.
If estimates of the condition number of the matrix logarithm are required then nag_matop_real_gen_matrix_cond_log (f01jj) should be used.

Further Comments

The cost of the algorithm is On3 floating-point operations (see Al–Mohy and Higham (2011)). The double allocatable memory required is approximately 3×n2.
If the Fréchet derivative of the matrix logarithm is required then nag_matop_real_gen_matrix_frcht_log (f01jk) should be used.
nag_matop_complex_gen_matrix_log (f01fj) can be used to find the principal logarithm of a complex matrix. It can also be used to return a complex, non-principal logarithm if a real matrix has no principal logarithm due to the presence of negative eigenvalues.

Example

This example finds the principal matrix logarithm of the matrix
A = 3 -3 1 1 2 1 -2 1 1 1 3 -1 2 0 2 0 .  
function f01ej_example


fprintf('f01ej example results\n\n');

a =  [3, -3,  1,  1;
      2,  1, -2,  1;
      1,  1,  3, -1;
      2,  0,  2,  0];

% Compute log(a)
[loga, imnorm, ifail] = f01ej(a);

disp('log(A)');
disp(loga);


f01ej example results

log(A)
    1.1957   -1.2076   -0.5802    1.0872
    0.8464    1.0133   -0.5985   -0.1641
    0.4389    0.6701    1.8449   -1.2111
    1.2792    0.6177    2.1448   -1.9743


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–2015