I'm taking linear algebra and I'm not really understanding how putting a matrix into a function works. We learned that f(x) = A^2 + 2A + 1 means square matrix A + 2* matrix A + Identity Matrix. Our teacher said you can basically plug anything into a function. But does the function still obey the laws of algebra?

For example can you factor a function? I have a question that says show p1(A) = p2(A)p3(A) for any square matrix A. It tells me p1(x) = x^2 + 9 and p2(x) = x + 3 and p3(x) = x - 3. I verified it for a specific 2x2 matrix A, but am not sure how to generalize. I would like to generalize it even farther than they are asking to factor anything like I can with regular algebra.

I have a similar question later, show that a square matrix A satisfies A^2 - 3A + I = 0 then A^-1 = 3I - A. It is trivial to show it works for a specific matrix A, and I would like to understand how they came up with the 2nd equation, and not merely that it is true, so I can understand what operations are valid.

I don't really know the name of what I'm having trouble with, so I wasn't really able to find anything useful on the internet. I'm taking it at a community college, so the people in the math lab can't really help me, in fact I work in our math lab myself.

Thanks so much for your help!