You know how to evaluate a polynomial like p(x)=2x2−3x+5 at a number: plug in x, get a number out. Now plug in a square matrixA instead. The variable becomes A, and — crucially — the constant term becomes a multiple of the identity matrixI, because you cannot add a bare number to a matrix.
The Definition
For p(x)=anxn+⋯+a1x+a0 and a square matrix A,
p(A)=anAn+an−1An−1+⋯+a1A+a0I.
Here Ak is k-fold matrix multiplication, akAk is scalar multiplication, and a0I replaces the constant. The result is a square matrix of the same size as A.
Note
There is no ambiguity from non-commutativity here: a polynomial only ever multiplies A by itself, and A always commutes with A.
To evaluate an expression such as A2+2A+7I, compute each term as a matrix and add them entrywise. The only subtlety is that the constant term is a scalar multiple of the identity, not a scalar added to every entry.
Steps
Step 1: Compute A2 by matrix multiplication.
Each entry of A2 is a row of A dotted with a column of A.
Why it's wrong: 7I=[7007], so 7 is added only to the diagonal entries; adding it to the off-diagonal entries is wrong. Correct approach: build 7I explicitly before adding.
Mistake 2: Computing A2 as the entrywise square of A.
Why it's wrong: A2 means the matrix product A⋅A, not squaring each entry. Correct approach: use row-by-column multiplication. …