# Failure during calculating the matrix exponential, but where?

I have to calculate $e^{At}$ of the matrix $A$. We are learned to first compute $A^k$, by just computing $A$ for a few values of $k$, $k=\{0\ldots 4\}$, and then find a repetition. $A$ is defined as follows:

$$A = \begin{bmatrix} -2 & 2& 0 \\ 0 & 1 & 0 \\ 1 & -1 & 0 \end{bmatrix}$$

Because I couldn't find any repetition I used Wolfram|Alpha which gave me the following, http://goo.gl/JxyIg:

$$\frac{1}{6} \begin{bmatrix} 3(-1)^k2^{k+1} & 2(2-(-1)^k2^{k+1}) & 0 \\ 0 & 6 & 0 \\ 3(-(-2)^k+0^k) & 2(-1+(-2)^k) & 6*0^k \end{bmatrix}$$

Then $e^{At}$ is calculated as followed (note that $\sum_{k=0}^{\infty}\frac{0^kt^k}{k!} = e^{0t} = 1$, using that $0^0 = 1$): $$e^{At} = \begin{bmatrix} \frac{1}{6}\sum_{k=0}^{\infty}\frac{3(-1)^k2^{k+1}t^k}{k!} & \frac{1}{6}\sum_{k=0}^{\infty}\frac{2(2-(-1)^k2^{k+1})t^k}{k!} & 0 \\ 0 & \frac{1}{6}\sum_{k=0}^{\infty}\frac{6t^k}{k!} & 0 \\ \frac{1}{6}\sum_{k=0}^{\infty}\frac{3(-(-2)^k+0^k)t^k}{k!} & \frac{1}{6}\sum_{k=0}^{\infty}\frac{2(-1+(-2)^k)}{k!} & \frac{1}{6}\sum_{k=0}^{\infty}\frac{6^k*0^k}{k!} \end{bmatrix}$$

Now this matrix should give as a answer

$$\begin{bmatrix} e^{-2t} & e^{2t} & 0 \\ 0 & e^{t} & 0 \\ e^{t} & e^{-t} & 1 \end{bmatrix}$$

Now when I compute this answer of $e^{At}$, I get different answers for some elements. Only the elements $A_{11} = e^{-2t}$, $A_{13} = A_{21} = A_{23} = A_{33} = 1$ and $A_{22} = e^t$. However when I calculate $A_{12}$ I get the following:

$$A_{12}=\frac{1}{6}\sum_{k=0}^{\infty}\frac{2(2-(-1)^k2^{k+1})t^k}{k!}=\frac{2}{6}\left(\sum_{k=0}^{\infty}\frac{2t^k}{k!}-\sum_{k=0}^{\infty}\frac{(-1)^k2^{k+1}t^k}{k!}\right)=\frac{4}{6}\left(\sum_{k=0}^{\infty}\frac{t^k}{k!}-\sum_{k=0}^{\infty}\frac{(-1)^k2^{k}t^k}{k!}\right)=\frac{4}{6}\left(e^t-e^{-2t}\right)$$

Which is of course not equal to $e^{2t}$. Where do I make a mistake? Or does maybe Wolfram|Alpha make a mistake, I know it is correct for $0\ldots 4$.

-
Why do you say it "should give" that answer? It shouldn't. Your calculation of the $(1,2)$ matrix element is correct. But those $1$'s in the $(1,3)$, $(2,1)$ and $(2,3)$ positions should be $0$. – Robert Israel Sep 21 '12 at 19:45
Well to be fair I also thought they had to be 0, but both Wolfram|Alpha as well as Matlab, goo.gl/po8AC, quiet stupid of myself to just to take that over. – WG- Sep 21 '12 at 20:07

Corrected : Your $A^k$ is right but for $e^{At}$ you should just have multiplied every term by $\frac {t^k}{k!}$ before computing the sum. So no $6^k$ in the central term for example.
Further (as explained by Robert Israel) for $k=0$ your $A^k$ expression is still valid with only diagonal $1$ terms (so no $1$ elsewhere).

Last you seem to be supposing that $e^{At}$ will simply be the exponential of each term : this is not true as shown by your $A_{1,2}$ term (i.e. the 'should give...' part is not right). I'll add that, in Mathematica, you must use MatrixExp to compute a matrix exponential and not Exp that returns the exponential of the individual terms! Result :

Hoping this helped more,

-
... or rather because $6/6 = 1$. There should be no $6^k$. – Robert Israel Sep 21 '12 at 19:47
@RobertIsrael: well the power of $k$ is clearly wrong but I agree ! – Raymond Manzoni Sep 21 '12 at 19:55
Yes you are correct. I don't know why i wrote $6^k$. I don't have it on my notes ;) just a writing failure. – WG- Sep 21 '12 at 20:01
@Wouter: see my edit for your additional $1$s problem – Raymond Manzoni Sep 21 '12 at 20:06
@RaymondManzoni thank you very much. Cleary I was depending to much on Wolfram|Alpha and Matlab. It also seems that Matlab also has that type of function, expm. Thanks again for your help. – WG- Sep 21 '12 at 21:09

In general, you would be better off by finding a diagonalization of $A$ and exponentiating the diagonal matrix, i.e.

$e^{At} = e^{VDV^Tt} = \sum_k \frac{(VDV^Tt)^k}{k!} = \sum_k V\frac{D^k t^k}{k!} V^T = Ve^{Dt}V^T$,

(since $V$ is orthonormal). Then, $e^D$ simply exponentiates the diagonal of $D$, premultiplying every diagonal entry with $t$, and you have to multiply things out...

-
Yes I know I can solve it by diagonalization of $A$ but I rather want to solve it now like this. – WG- Sep 21 '12 at 20:03
At gt6989b a really good suggestion. That is the way I remember doing it way back in the 70s. I vaguely remember needing to do this to solve differential difference equations for queuing processes. We had to be careful calculating A$k$/k! when convergence was slow because it was very easy to get overflow errors if you did it stupidly. – Michael Chernick Sep 21 '12 at 22:11
The amazing thing to me was that sometimes there could be an accumulation of roundoff error that had the effect the terms that were suppose to sum to one would start summing to values greater than 1 and as the convergence get slower (for some values of the parameters in the A matrix) roundoff error could become a huge problem! I go on too much! – Michael Chernick Sep 21 '12 at 22:12
– Robert Israel Sep 23 '12 at 3:46