Forms integer powers of a square matrix (P.W. Lane).
||Matrix from which to form the power|
||Power to which each matrix is to be raised|
||Structure to store the result|
MPOWER forms powers of a square matrix, using as few matrix operations as possible in order to save time and decrease rounding errors. The square matrix is specified using the
MATRIX parameter, and can be either an ordinary matrix structure (with an equal number of rows and columns), a symmetric matrix or a diagonal matrix. The required power, which must be a positive integer, is specified using the
POWER parameter. The
RESULT parameter supplies the identifier of the structure to save the results; this will be declared automatically to be of the same type as the input structure.
For general matrices, successive powers of two of the matrix are formed by matrix products, and the result formed by taking the product of those that are needed to achieve the specified power. Diagonal matrices are dealt with using simple exponentiation of the diagonal values. Symmetric matrices are spectrally decomposed, and the result formed as a product of the matrix containing the latent vectors (
V) with the simple power of the diagonal matrix containing the latent roots (
RESULT = V *+ R**POWER *+ TRANSPOSE(V).
Commands for: Calculations and manipulation.
CAPTION 'MPOWER example',\ !t('Calculate the 65th power of a transition matrix to',\ 'find the state of a process after 65 transitions.'); STYLE=meta,plain MATRIX [ROWS=7; COLUMNS=7] Tprob READ Tprob .999360 .000351 0 .000131 .000023 .000005 .000130 0 .998960 0 .000816 .000063 .000031 .000130 0 0 .997371 .001947 .000458 .000094 .000130 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 : MPOWER Tprob; POWER=65; RESULT=T65 PRINT T65