TITLE: Why does calculating matrix inverses, roots, etc. using the spectrum of a matrix work?
QUESTION [17 upvotes]: Suppose $A$ is a $n \times n$ matrix from $M_n(\mathbb{C})$ with eigenvalues $\lambda_1, \ldots, \lambda_s$. Let $$m(\lambda) = (\lambda - \lambda_1)^{m_1} \ldots (\lambda - \lambda_s)^{m_s}$$
be the minimal polynomial of $A$. 
We define $f(A)$ in general to be $p(A)$ for some polynomial interpolating $f(\lambda_k), f'(\lambda_k), \ldots, f^{(m_k - 1)}(\lambda_k)$ for all $k$, assuming that $f$ is defined at these points. This is well defined because for any such two interpolating polynomials $p$ and $q$ we have $p(A) = q(A)$ and such a polynomial always exists. We can also find a polynomial $p$ which has degree less than the minimal polynomial $m$.
Also, then there exist linearly independent matrices $Z_{ij}$ such that for any $f$ defined at $f(\lambda_k), f'(\lambda_k), \ldots, f^{(m_k - 1)}(\lambda_k)$ for all $k$, we have
$$f(A) = \sum_{k = 1}^{s} ( f(\lambda_k)Z_{k0} + f'(\lambda_k)Z_{k1} + \ldots + f^{(m_k - 1)}(\lambda_k)Z_{k, m_k - 1})$$

Okay, with the definitions and such out of the way here's the actual question..
We can use this definition to calculate $f(A)$ for $f$ such as $f(x) = 1/x$ which gives us the inverse of $A$, or $f(x) = \sqrt{x}$ which gives us the square root of $A$, or $f(A)$ for any polynomial $f(x)$. The power series definition of $\sin(A)$, $\cos(A)$, etc also agrees with the definition. 
Now this is all really awesome and interesting in my opinion, but why on earth does this work? I have no idea why the properties of the inverse function $1/x$ or the square root $\sqrt{x}$ are "passed on" to matrices this way.
Also, what is this called? Spectral something, but I'm not sure. I tried looking it up on Wikipedia and Google but couldn't find anything. Besides answers to help me understand what this is all about, I'll appreciate any references, keywords and so on.

REPLY [3 votes]: When the matrix $A$ is not diagonalizable, working with the "spectrum" becomes technically involved, but even then via Cauchy's theorem of complex analysis you can make sense of $\sin(A)$, etc., in a single formula not involving any eigenvalues or diagonalization process: When all eigenvalues of $A$ are contained in the disk $D_R$  of radius $R$ around $0$ then
$$\sin(A)={1\over2\pi i}\int_{\partial D_R}{\sin z\over z-A}\ dz\ .$$
Back to matrices:  In the one-dimensional case an $A:\ {\mathbb R}\to{\mathbb R}$ is just  a scaling $t\mapsto \lambda t$ with a certain factor $\lambda\in{\mathbb C}$, and the only meaning $f(A)$ could have then is that $f(A)$ scales by the factor $f(\lambda)$.
In the $n$-dimensional diagonalizable case the space $V={\mathbb R}^n$ where $A$ acts can be written as a direct sum $V=\oplus_{i=1}^n V_i$ of the one-dimensional  eigenspaces $V_i:=\{x| Ax=\lambda_i x\}$. This means that $A$ acts as $n$ independent one-dimensional scalings $t\mapsto \lambda_i t$ in parallel. If you are given a function $f$ whose domain $\Omega\subset{\mathbb C}$ contains the $\lambda_i$, then $f(A)$ restricted to one of the $V_i$ is just the map $$f(A)\restriction V_i: \quad t\mapsto f(\lambda_i) t\ ,$$
where $t$ is a "local" coordinate in $V_i$, denoted by $t_i$ when we look at all of these at the same time.
Now, since all this makes sense when we look at $A$ as being a linear map $V\to V$, by general principles this also makes sense in the world of matrices. In particular: If $T$ is the matrix whose columns are the eigenvectors of $A$, i.e., the basis vectors of the $V_i$ above, and $D={\rm diag}(\lambda_1,\ldots,\lambda_n)$ is the diagonal matrix containing the eigenvalues, then
$$f(A)=T\  {\rm diag}\bigl(f(\lambda_1),\ldots,f(\lambda_n)\bigr)\ T^{-1}\ .$$