# naginterfaces.library.matop.real_​gen_​matrix_​fun_​num¶

naginterfaces.library.matop.real_gen_matrix_fun_num(a, f, data=None)[source]

real_gen_matrix_fun_num computes the matrix function, , of a real matrix . Numerical differentiation is used to evaluate the derivatives of when they are required.

For full information please refer to the NAG Library document for f01el

https://www.nag.com/numeric/nl/nagdoc_28.4/flhtml/f01/f01elf.html

Parameters
afloat, array-like, shape

The matrix .

fcallable fz = f(z, data=None)

The function evaluates at a number of points .

Parameters
zcomplex, ndarray, shape

The points at which the function is to be evaluated.

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

Returns
fzcomplex, array-like, shape

The function values. should return the value , for . If lies on the real line, then so must .

dataarbitrary, optional

User-communication data for callback functions.

Returns
afloat, ndarray, shape

The matrix, .

imnormfloat

If has complex eigenvalues, real_gen_matrix_fun_num will use complex arithmetic to compute . The imaginary part is discarded at the end of the computation, because it will theoretically vanish. 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, real_gen_matrix_fun_num uses real arithmetic and .

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

A Taylor series failed to converge after terms. Further Taylor series coefficients can no longer reliably be obtained by numerical differentiation.

(errno )

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.

(errno )

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.

(errno )

Warns
NagCallbackTerminateWarning
(errno )

Termination requested in .

Notes

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