<s>[INST] 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 
 [/INST] Your calculation seems plausible. Let's try it the other way: the Taylor expansion of $\tan(\pi x/4)$ at $x=1$ is
$$
\tan(\pi x/4)=1+\frac{\pi}{2}(x-1)+\ldots
$$
Then for the Jordan block
$$
J=\begin{bmatrix}1 & 0\\1 & 1\end{bmatrix}
$$
we have
$$
\tan(\pi J/4)=I+\frac{\pi}{2}\begin{bmatrix}0 & 0\\1 & 0\end{bmatrix}=\begin{bmatrix}1 & 0\\\color{red}{\frac{\pi}{2}} & 1\end{bmatrix}.
$$
</s>