Let the polynomial $p(x)=a_0+a_1 x+\dots+a_nx^n$, with $a_0\neq 0$. Let M be an invertible matrix and suppose $p(M)=0$. Find a invertible matrix $M^{-1}$ as a function of M.
How I try: $p(M)=a_0I+a_1 M+ a_2 M^2+ \dots + a_n M^n = a_0 M M^{-1}+a_1 M+ a_2 M^2+ \dots + a_n M^n$
$\Rightarrow M(a_0 M^{-1}+a_1 I + \dots + a_n M^{n-1})=0$
But in this way I find $M^{-1}$ as a function of the coefficients of the polynomial $p(x)$.
I think I'm thinking the wrong way.
It depends on the wording of the question.... If we are not completely sure there is an inverse, but we have $p(M)=a_0I+a_1 M+ a_2 M^2+ \dots + a_n M^n $ with $a_0 \neq 0$ and the value $p(M) = 0$ as a matrix, we have $$ a_1 M+ a_2 M^2+ \dots + a_n M^n = - a_0I. $$ Then $$ -\frac{a_1}{a_0} M -\frac{a_2}{a_0} M^2+ \dots -\frac{a_n}{a_0} M^n = I, $$ $$ M \left(-\frac{a_1}{a_0} I -\frac{a_2}{a_0} M+ \dots -\frac{a_n}{a_0} M^{n-1} \right) = I. $$ We could instead have written, either way it is just the distributive law, $$ \left(-\frac{a_1}{a_0} I -\frac{a_2}{a_0} M+ \dots -\frac{a_n}{a_0} M^{n-1} \right) M = I. $$ It is this expression that says that $M$ has an inverse, and the inverse is equal to $$ \left(-\frac{a_1}{a_0} I -\frac{a_2}{a_0} M+ \dots -\frac{a_n}{a_0} M^{n-1} \right) $$