polyvalm

Evaluates a polynomial with a square matrix as the variable.

Category: Mathematics > Elementary Math

Syntax

Y = polyvalm(p, X)

Evaluates p(1)*X^n + ... + p(n)*I using matrix products.

Description

Where polyval squares each entry, polyvalm uses true matrix powers, and the constant term is multiplied by the identity matrix. The Cayley-Hamilton theorem says that a matrix annihilates its own characteristic polynomial, so polyvalm(poly(A), A) is the zero matrix, up to rounding.

Input arguments

p
Coefficient vector, highest power first.
X
Square matrix.

Output arguments

Y
Square matrix of the same size as X.

Example

Matrix polynomial

A = [1 2; 3 4];
polyvalm([1 0 1], A)
A^2 + eye(2)
Output
ans = 2×2

     8    10
    15    23
ans = 2×2

     8    10
    15    23

See also

polyval poly expm mpower