Why does this matrix give the derivative of a function? I happened to stumble upon the following matrix:
$$ A = \begin{bmatrix}
    a       &amp; 1  \\
    0       &amp; a 
\end{bmatrix}
$$

And after trying a bunch of different examples, I noticed the following remarkable pattern. If $P$ is a polynomial, then:
$$ P(A)=\begin{bmatrix}
    P(a)       &amp; P'(a)  \\
    0       &amp; P(a)
\end{bmatrix}$$

Where $P'(a)$ is the derivative evaluated at $a$.

Futhermore, I tried extending this to other matrix functions, for example the matrix exponential, and wolfram alpha tells me:
$$ \exp(A)=\begin{bmatrix}
    e^a       &amp; e^a  \\
    0       &amp; e^a
\end{bmatrix}$$
and this does in fact follow the pattern since the derivative of $e^x$ is itself!

Furthermore, I decided to look at the function $P(x)=\frac{1}{x}$. If we interpret the reciprocal of a matrix to be its inverse, then we get:
$$ P(A)=\begin{bmatrix}
    \frac{1}{a}       &amp; -\frac{1}{a^2}  \\
    0       &amp; \frac{1}{a}
\end{bmatrix}$$
And since $f'(a)=-\frac{1}{a^2}$, the pattern still holds!

After trying a couple more examples, it seems that this pattern holds whenever $P$ is any rational function.

I have two questions:


Why is this happening?
Are there any other known matrix functions (which can also be applied to real numbers) for which this property holds?
If $$ A = \begin{bmatrix}
    a       &amp; 1  \\
    0       &amp; a 
\end{bmatrix}
$$
then by induction you can prove that
$$ A^n = \begin{bmatrix}
    a^n       &amp; n a^{n-1}  \\
    0       &amp; a^n 
\end{bmatrix} \tag 1
$$
for $n \ge 1 $. If $f$ can be developed into a power series
$$
  f(z) = \sum_{n=0}^\infty c_n z^n
$$
then
$$
  f'(z) = \sum_{n=1}^\infty n c_n z^{n-1}
$$
and it follows that
$$
 f(A) = \sum_{n=0}^\infty c_n A^n = I + \sum_{n=1}^\infty c_n
\begin{bmatrix}
    a^n       &amp; n a^{n-1}  \\
    0       &amp; a^n 
\end{bmatrix} = \begin{bmatrix}
    f(a)       &amp; f'(a)  \\
    0       &amp; f(a)
\end{bmatrix} \tag 2
$$
From $(1)$ and 
$$
A^{-1} = \begin{bmatrix}
    a^{-1}       &amp; -a^{-2}  \\
    0       &amp; a^{-1} 
\end{bmatrix}
$$
one gets
$$
A^{-n} = \begin{bmatrix}
    a^{-1}       &amp; -a^{-2}  \\
    0       &amp; a^{-1} 
\end{bmatrix}^n =
(-a^{-2})^{n} \begin{bmatrix}
    -a       &amp; 1  \\
    0       &amp; -a 
\end{bmatrix}^n  \\ =
(-1)^n a^{-2n} \begin{bmatrix}
    (-a)^n       &amp; n (-a)^{n-1}  \\
    0       &amp; (-a)^n 
\end{bmatrix} = 
\begin{bmatrix}
    a^{-n}       &amp; -n a^{-n-1}  \\
    0       &amp; a^{-n} 
\end{bmatrix}
$$
which means that $(1)$ holds for negative exponents as well.
As a consequence, $(2)$ can be generalized to functions
admitting a Laurent series representation:
$$
  f(z) = \sum_{n=-\infty}^\infty c_n z^n
$$
If $e$ satisfies $Xe=eX$ and $e^k=0$, then $f(X+e)=f(X) + ef'(X)+\frac{e^2}{2}f''(X) + \dots + f^{(k-1}(X)\frac{e^{k-1}}{(k-1)!}$ (a finite sum with $k$ terms).  

This is true for polynomials and thus for power series that converge in a neighborhood of $X$.