Matrix exponential of any matrix I want to be able to compute the exponential of any square matrix $A\in M_n(\mathbb{R})$.
I know that:


*

*If $A$ is diagonalizable, then we can write $A=PDP^{-1}$, where $D=\left(\begin{array}{ccc}
\lambda_{1} & \cdots & 0\\
\vdots & \ddots & \vdots\\
0 & \cdots & \lambda_{n}
\end{array}\right)$
and it is easy to show that $e^A=Pe^DP^{-1}$.

*If we can write $A$ in the form $$\left(\begin{array}{ccccc}
\lambda_{1} & 1 & \cdots & 0 & 0\\
 & \lambda_{2} & \ddots & 0 & 0\\
 &  & \ddots & 1 & \vdots\\
\vdots &  &  & \lambda_{n-1} & 1\\
0 & \cdots &  &  & \lambda_{n}
\end{array}\right)
 $$
then  we can write $A=D+N$ where $D$ is diagonal and $N$ is nilpotent. If $DN=ND$, then $e^A=e^{D+N}=e^De^N$, and this shouldn't be too hard to compute.
Now, what if both cases fail? For example, what if $A$ is not diagonalizable and, furthermore, the decomposition $D,N$ is such that $DN\ne ND$? Or, even worse, if there is no such  decomposition?
For example: $A=\left(\begin{array}{cc}
2 & 1\\
0 & 1
\end{array}\right)$ is diagonalizable, so we can use the first case above. But we can't use the second, since $A=\left(\begin{array}{cc}
2 & 0\\
0 & 1
\end{array}\right)+\left(\begin{array}{cc}
0 & 1\\
0 & 0
\end{array}\right)$ but these matrices do not commute. If $A$ was not diagonalizable, I was in a bad situation. 
 A: It is well known that we can write any matrix in Jordan normal form by a change of basis. This means it is a block-diagonal matrix, with block-entries the 'Jordan blocks' (not sure if that's standard terminology):
$$ J(\lambda, n) = \begin{bmatrix} \lambda & 1 & & \\ & \lambda &1 &\\ &&\ddots &1 \\ &&&\lambda \end{bmatrix} = \lambda \cdot I + N,$$
where $N$ is the matrix with ones at all entries immediately above the diagonal.
These blocks, then, can be split as indicated above, and $\lambda I \cdot N = N \cdot \lambda I$, for $I$ commutes with all matrices. Since each block on the diagonal of the Jordan normal form commutes, we can split the entire matrix in a diagonal matrix and a nilpotent matrix. Since each block commutes, the 'entire thing' commutes as well.
So, to summarise: we can find a Jordan normal form: $A = U \cdot J \cdot U^{-1}$, and this $J$ can be split in a diagonal and a nilpotent matrix. 
A: The Jordan-Chevalley decomposition guaranties that any matrix can be expressed in the form $A=PJP^{-1}$ with the entries of $P$ and $J$ in $\mathbb{C}$ ( $J$ is the Jordan form of the linear transformation) , and $J=D+N$ with $DN=ND$.  
If you  are interested in the computational ways to find the exponential of a matrix, you can see here.
(Note that in your example the matrix is diagonalizable, so the exponential is easy calculated) .
