Compute the e^{matrix} Can anyone help me out with the following question:
Compute $e^{A}$ for the following matrix:
$A=\begin{bmatrix}
    2 & 1 & -1 \\
      0 & 4 & -2 \\
      0 & 2 & 0 \\
\end{bmatrix}$
I've written $A=\begin{bmatrix}
                  2 & 0 & 0 \\
                   0 & 2 & 0\\
                   0 & 0 & 2 \\
\end{bmatrix}+\begin{bmatrix}
               0 & 1 & -1 \\
                0 & 2 & -2 \\
                 0 & 2 & -2\\
\end{bmatrix}=D+N$ with D diagonal and N nilpotent.
Now I thought: $e^{A}=e^{D+N}=e^2 I e^N=e^2[I+N]=\begin{bmatrix}
e^2& e^2 & -e^2 \\
0 & 3e^2 & -2e^2 \\
0 & 2e^2 & -e^2 \\
\end{bmatrix}$.
But this isn't the same as the answer if I compute it with for example maple. Does anyone see my mistake?
 A: Your answer is correct; your Maple code is not.
The analogous calculations in Mathematica are probably


*

*Exp[ {
{2, 1, -1},
{0, 4, -2},
{0, 2, 0}
} ] which exponentiates each element of the matrix individually


and 


*

*MatrixExp[ {
{2, 1, -1},
{0, 4, -2},
{0, 2, 0}
} ] which actually computes the genuine quantity $e^A$ which you are interested in


which give respectively $$
e^A \neq \pmatrix{
 e^2 & e & \frac{1}{e} \\
 1 & e^4 & \frac{1}{e^2} \\
 1 & e^2 & 1
}, \qquad e^A =  \pmatrix{ e^2 & e^2 & -e^2 \\
 0 & 3 e^2 & -2 e^2 \\
 0 & 2 e^2 & -e^2 }$$
A: The usual way to compute the exponential of a matrix is using the Jordan decomposition.
The Jordan decomposition of your matrix is
$$
\begin{bmatrix}
2&1&-1\\0&4&-2\\0&2&0
\end{bmatrix}
=
\begin{bmatrix}
0&-1&0\\1&-2&0\\1&-2&1
\end{bmatrix}
\begin{bmatrix}
2&0&0\\0&2&1\\0&0&2
\end{bmatrix}
\begin{bmatrix}
0&-1&0\\1&-2&0\\1&-2&1
\end{bmatrix}^{-1}
$$
Now, since the matrices commute, we can compute
$$
\begin{align}
\exp\left(\begin{bmatrix}
2&0&0\\0&2&1\\0&0&2
\end{bmatrix}
\right)
&=
\exp\left(\begin{bmatrix}
2&0&0\\0&2&0\\0&0&2
\end{bmatrix}
\right)
\exp\left(\begin{bmatrix}
0&0&0\\0&0&1\\0&0&0
\end{bmatrix}
\right)\\[6pt]
&=
\begin{bmatrix}
e^2&0&0\\0&e^2&0\\0&0&e^2
\end{bmatrix}
\begin{bmatrix}
1&0&0\\0&1&1\\0&0&1
\end{bmatrix}\\
\end{align}
$$
Finally,
$$
\begin{align}
\exp\left(\begin{bmatrix}
2&1&-1\\0&4&-2\\0&2&0
\end{bmatrix}
\right)
&=
\begin{bmatrix}
0&-1&0\\1&-2&0\\1&-2&1
\end{bmatrix}
\exp\left(\begin{bmatrix}
2&0&0\\0&2&1\\0&0&2
\end{bmatrix}\right)
\begin{bmatrix}
0&-1&0\\1&-2&0\\1&-2&1
\end{bmatrix}^{-1}\\
\end{align}
$$

I don't see anything wrong with your computation with the nilpotent matrix. In fact, I get the same result when  completing the computations above.
