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.