An exercise on the calculation of a function of operator The operator is given by
$$A=\begin{pmatrix}
1 & 0 & 0\\
1 & 1 & 0\\
0 & 0 & 4
\end{pmatrix}$$
I have to write down the operator $$B=\tan(\frac{\pi} {4}A)$$
I calculate $$\mathcal{R} (z) =\frac{1}{z\mathbb{1}-A}=\begin{pmatrix} 
\frac{1}{z-1} & 0 & 0\\
\frac{1}{(z-1)^2} & \frac{1}{z-1} & 0\\
0 & 0 & \frac{1}{z-4}\end{pmatrix} $$
Now the B operator is given by:
$$B=\begin{pmatrix}
Res_{z=1}\frac{\tan(\frac{\pi}{4}z)}{z-1} & 0 & 0\\
Res_{z=1}\frac{\tan(\frac{\pi}{4}z)}{(z-1)^2} & Res_{z=1}\frac{\tan(\frac{\pi}{4}z)}{z-1} & 0\\
0 & 0 & Res_{z=4}\frac{\tan(\frac{\pi}{4}z)}{z-4}
\end{pmatrix} $$
For me the result should be
$$ B=\begin{pmatrix}
1 & 0 & 0\\
\frac{\pi}{2} & 1 & 0\\
0 & 0 & 0\end{pmatrix}$$
But the exercise gives as  solution:
$$ B=\begin{pmatrix}
1 & 0 & 0\\
\frac{\pi}{4} & 1 & 0\\
0 & 0 & 1\end{pmatrix}$$
Where is the error?
Thank you and sorry for bad English 

It would appear that there’s an error in either the problem statement or the solution.  
You can check your own answer by computing this via a consequence of the Cayley-Hamilton theorem: any analytic function of $A$ can be expressed as a quadratic polynomial in $A$, i.e., $\tan\left(\frac\pi4A\right) = aI+bA+cA^2$ for some unknown coefficients $a$, $b$, $c$. The eigenvalues of $A$ are obviously $1$, $1$ and $4$, so you can find these coefficients by solving the following system of linear equations $$a+b+c = \tan\frac\pi4 \\ b+2c = \frac\pi4\sec^2\frac\pi4 \\ a+4b+16 = \tan\pi$$ obtained by substituting the eigenvalues of $A$ into the above equation for $\tan\left(\frac\pi4A\right)$, as well as into its derivative in order to get a third independent equation in the case of the repeated eigenvalue. Solving these equations and computing the polynomial of $A$ produces $\pi/4$, not $\pi/2$ on the off-diagonal.
