Martin Rubey
2007-04-01 18:39:19 UTC
Hello,
Let P in Ring[X] and M in SquareMatrix(Ring)
The mathematics evaluate P(M)
by sum (ak*M^k, k=0..deg P) in SquareMatrix(Ring)
where P = sum (ak*X^k, k=0..deg P)
How can I do this in axiom.
-- work in SquareMatrix(n, FRAC POLY INT)Let P in Ring[X] and M in SquareMatrix(Ring)
The mathematics evaluate P(M)
by sum (ak*M^k, k=0..deg P) in SquareMatrix(Ring)
where P = sum (ak*X^k, k=0..deg P)
How can I do this in axiom.
n := 4;
SM ==> SquareMatrix(n, FRAC POLY INT)
--
-- Create a generic matrix
--
M: SM := matrix [[a[i,j] for j in 1..n] for i in 1..n]
-- Create an identity matrix
I: SM := 1;
-- Computes determinant (M - x*Id) where M is the previous generic matrix.
-- note that characteristicPolynomial would do this for youm however, for some
-- strange reason, it accepts an element of Matrix R instead of SquareMatrix R.
P := determinant (M - x * I)
-- Now evaluate P(M). We find the (0)_4 matrix. Note that you can coerce only
-- to a univariate polynomial, since matrix multiplication is not
-- commutative...
(P::UP(x, SM))(M)