MFUN - Matrix Function
Created by Jeff Pedersen
Released 7 April 2004

DESCRIPTION

In general for a scalar function f(x) and a square matrix A,the matrix function
   f(a) is defined as follows


          infinity        
          ____
          \
 f(A) :=   \     c_k * A^k
           /
          /___
           k=0

where the scalar function f has the power series expansion

          infinity        
          ____
          \
 f(x) :=   \     c_k * x^k
           /
          /___
           k=0

for appropriate {c_k}.

(Just so we're clear we are not talking about element-wise application
 of the function)
 
MFUN calculates functions of square matrices through application of the
Cayley-Hamilton Theorem.  If the calculator is exact mode, the program
attempts to calculate the function exactly, but if the eigenvalues
of A cannot be found exactly, the program continues in approximate mode.

INSTALLATION

Two libraries are included.

MFUN49g     - For HP 49g
MFUN49gplus - For HP 49g+

Download the appropriate library to your calculator and install according
to instructions at http://www.hpcalc.org/install.php

OPERATION

Put the square matrix A and an expression of the CAS independent variable
on the stack in positions 2 and 1, respectively, and invoke MFUN.
The function f(A) is returned.  The arguments are not preserved.

NOTES

This is the first program i have written for any calculator and so isn't
the most efficient code in the world.  It was written in UserRPL on an
HP 49g+.  The HP 49g version can be quite slow, comparitively.  The form
of the matrix f(A) is not linearized, factorized, or otherwise simplified.

The program does not check for errors.  It assumes the user has entered a
SQUARE n×n matrix and an algebraic expression in the CAS variable ('X' by
default).

Sometimes the program will ask to switch to approximate mode, even if this
mode is already set.

I have tested the program, and feel it is solid, but I can provide no
gaurantees.  If the program gives you an incorrect result please e-mail
me and let me know! Thanks.

Jeff Pedersen
pedersen@ece.ualberta.ca