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 
 A: 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}.
$$
A: Can you try using the exponent formula for matrices? It works the same way: $$e^{A} =1+A + \frac{1}{2!} A^2+\dots \in \text{GL}(2, \mathbb{R})$$
The exponent of any matrix is an invertible $3\times 3$ matrix.
if we need a tangent function defined on matrices all of $\tan, \sin, \cos$ can be done with exponent function:
$$ \tan A = \frac{e^{iA}-e^{-iA}}{e^{iA}+e^{-iA}}$$
What remains is to find the matrix exponent of the lower-triangular matrix.
if we can write $A=A_0+N$ with $A_0$ diagonal and $N$ nilpotent (here $N^3=0$), then $e^{A}=e^{A_0}e^{N}$. Indeed 
$$A=
\begin{pmatrix}
1 & 0 & 0\\
1 & 1 & 0\\
0 & 0 & 4
\end{pmatrix}=
\begin{pmatrix}
1 & 0 & 0\\
0 & 1 & 0\\
0 & 0 & 4
\end{pmatrix}+
\begin{pmatrix}
0 & 0 & 0\\
1 & 0 & 0\\
0 & 0 & 0
\end{pmatrix}=A_0+N
 $$
This gets you started.
A: 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.
