A formula in 'The Matrix Cookbook' In section 9.4 (Idempotent Matrices), the book says that :
if $A$ is idempotent, which means that $AA = A$, then 
$f(sI + tA) = (I-A)f(s) + Af(s+t)$
but I don't understand the meaning of this formula, can anyone tell me where does it come from or show me how to proof this formula? Thanks.
 A: I'm guessing here that $f \in k[x]$, $s,t \in k$ and evaluating $f$ at a matrix $A$ is done as follows:
$$f(A) = \sum_{i=0}^n a_iA^i$$
where $f(x) = \sum_{i=0}^n a_ix^i$ and $A^0 = I$.
I imagine you should be able to prove this fairly easily by induction on the degree of $f$. It certainly very clearly holds when $f$ is linear.
To show it in the case when $f = a_1x +a_0$, first expand the RHS:
\begin{align*}(I-A)f(s) + Af(s+t) &= (I-A)(a_1s+a_0) + A(a_1(s+t)+a_0)\\
&=a_1(sI+tA)+a_0I = f(sI+tA)\end{align*}
Now, for the inductive step, say $f=a_nx^n + \ldots +a_1x +a_0$, we can write $f$ as $f=x\cdot a_nx^{n-1} + g$, where $g = a_{n-1}x^{n-1} + \ldots +a_1x+a_0$ has degree strictly smaller than $f$.
Now apply your inductive step and this result,
\begin{align*}f(sI+tA) &= (sI+tA)a_n(sI+tA)^{n-1} + g(sI+tA)\\
&=(sI+tA)a_n[(I-A)s^{n-1} +A(s+t)^{n-1}] + (I-A)g(s) + Ag(s+t)\end{align*}
Now expand, use that $A$ is idempotent to cancel some terms, and you get $Aa_n(s+t)^n + Ag(s+t) + (I-A)a_ns^n + g(s)$, which is precisely the result if you think how $g$ was defined.
A: For a diagonalizable matrix $A=SDS^{-1}$ and and a function $f$, it is standard to define $f(A)=Sf(D)S^{-1}$, and $f(D) $ is the diagonal matrix with diagonal $(f(D_{jj}) )$. This is coherent with polynomial evaluation,  since $(SDS^{-1})^n=SD^nS^{-1} $. It is also coherent with writing continuous functions as limits of polynomials. 
Now here $A$ is idempotent,  and thus diagonalizable. So the formula certainly makes sense.  The question is whether it is true. By the first paragraph, it is enough to check the formula on a diagonal matrix $D$ with its diagonal entries consisting of zeroes and ones.
So the diagonal of $f(sI+tD) $ consists of a number of $f(s) $ (when $D_{jj}=0$) and $f(s+t) $ (when $D_{jj}=1$). In both cases the formula
$$
f(s+tD_{jj})=(1-D_{jj})f(s)+D_{jj}f(s+t)
$$
holds. So
$$
f(sI+tA)=Sf(sI+tD)S^{-1}=S((I-D)f(s)+Df(s+t))S^{-1}\\=(I-A)f(s)+Af(s+t).
$$
