<s>[INST] Solving a Matrix Equation with Maple I am attempting to use Maple to solve a matrix equation of the form $aB^2 + bB + cI = B^{-2}$, where $B$ is a $3 \times 3$ matrix, and I is the $3 \times 3$ identity matrix (i.e. to find the values a, b and c which satisfy the equation).
My idea was to use a piece of code like 
A:=Matrix([[7,4,-2],[4,7,5],[2,-3,8]]);
d:=Vector([[8],[5],[2]]); 

for matrix inversion to solve a system of three linear equations but that would assume that the right-hand side of the equation is a column vector when it is actually another $3 \times 3$ matrix.  Is there a  simple way to look at this which I am missing?
 [/INST] using new letters, there is the characteristic polynomial for $B.$ As $B$ is 3 by 3 and invertible, we have $r \neq 0$ in
$$ B^3 + p B^2 + q B + r I = 0.   $$
When needed, this gives us the useful $$  B^3 = -p B^2 - q B - r I .   $$
Next, we get
$$ B^4 =  -p B^3 - q B^2 - r B = -p (-p B^2 - q B - r I )  - q B^2 - r B ,   $$ 
$$  B^4 = (p^2 - q) B^2 + (pq -r)B + prI. $$
Looks right. For you, these coefficients will be integers.
Also, you should confirm with the actual numbers that show up. 
Back to $ B^3 + p B^2 + q B + r I = 0,   $ we have $r \neq 0$ in
$$  B^3 + p B^2 + q B = -rI,  $$
$$ B^2 + p B + q I = -r B^{-1}. $$ So
$$ B^{-1} = - \frac{1}{r} B^2 - \frac{p}{r} B - \frac{q}{r} I.  $$
Nice rational coefficients, no guesswork. Finally, we get $B^{-2} = \left(B^{-1} \right)^2,$ which involves those coefficients, and will have $B^4$ and $B^3.$ All you do is substitute the expressions we found for $B^4$ and $B^3,$ add like terms, you get $B^{-2}$ in terms of $B^2, B,I.$
</s>