Leverrier’s algorithm
[num,den]=nlev(A,z [,rmax])
:A real square matrix : :z character string : :rmax optional parameter (see bdiag) :
[num,den]=nlev(A,z [,rmax]) computes (z*eye()-A)^(-1)
by block diagonalization of A followed by Leverrier’s algorithm on each block.
This algorithm is better than the usual leverrier algorithm but still not perfect!
A=`rand`_(3,3);x=`poly`_(0,'x');
[NUM,den]=nlev(A,'x')
`clean`_(den-`poly`_(A,'x'))
`clean`_(NUM/den-`inv`_(x*`eye`_()-A))