# How to form result of MatrixExp

I have this sets of equations:

system=$\left(\begin{array}{c} x1'(t)=x2(t)\\ x2'(t)=-p2(t)-x2(t)\\ p1'(t)=-x1(t)\\p2'(t)=p2(t)-p1(t)\\\end{array}\right)$

and corresponding $A$ matrix is

$\left(\begin{array}{cccc} 0 & 1 & 0 & 0 \\ 0 & -1 & 0 & -1 \\ -1 & 0 & 0 & 0 \\ 0 & 0 & -1 & 1 \\\end{array}\right)$

I need to find the solution and have with the following line;

(Simplify /@ MatrixExp[t A] // N)


which resulted ie the 1,1 element of result as

$0.5 \left((0.5\, -0.288675 i) e^{(0.866025\, -0.5 i) t}+(0.5\, -0.288675 i) e^{(-0.866025+0.5 i) t}+(0.5\, +0.288675 i) e^{(-0.866025-0.5 i) t}+(0.5\, +0.288675 i) e^{(0.866025\, +0.5 i) t}\right)$

Edit: Required Codes

A = {{0, 1, 0, 0}, {0, -1, 0, -1}, {-1, 0, 0, 0}, {0, 0, -1, 1}};

(Simplify /@ MatrixExp[t A] // N) // TableForm


where $t$ is time variable.

How can I get rid of the imaginary variable inside the parenthesis and the exponential form to get something like $c_1e^a\cos(b)+c_2e^a\sin(b))$?

Result should be like this.

• You've already asked a few questions so should be able to format them properly. Here, you're mixing $\LaTeX$, code, and uncompiled $\LaTeX$ (?!). Edit your post so that it's readable. Provide the codes required to reproduce your results. As it stands, there's no t or A. See here for basic tips on asking questions. I'll retract the downvote once you conform to the requirements. Jan 14 '17 at 14:44
• Look up ExpToTrig[] in the meantime. Jan 14 '17 at 14:57
• @corey979 it was readable format for $\latex$ but it doesn't allow me to submit the question saying it seems there is a unporper formatted code. Thus I changed them into code to be able to submit. Jan 14 '17 at 15:04
• :) yes t is free variable. So how to solve :) Jan 14 '17 at 15:23
• may be it is a style thing, but I find Simplify[ MatrixExp[t A] ] more clear than Simplify /@ MatrixExp[t A] Jan 14 '17 at 21:05

With

m = Simplify /@ MatrixExp[t A] // Normal


do either (this gives hyperbolic functions)

out1 = FullSimplify @ ExpToTrig @ m
out1[[1, 1]]


$\cos \left(\frac{t}{2}\right) \cosh \left(\frac{\sqrt{3} t}{2}\right)-\frac{\sin \left(\frac{t}{2}\right) \sinh \left(\frac{\sqrt{3} t}{2}\right)}{\sqrt{3}}$

or (to get exponentials)

out2 = FullSimplify @ ComplexExpand @ m
out2[[1, 1]]


$\frac{e^{-\frac{\sqrt{3} t}{2}} \sin \left(\frac{t}{2}\right)}{2 \sqrt{3}}-\frac{e^{\frac{\sqrt{3} t}{2}} \sin \left(\frac{t}{2}\right)}{2 \sqrt{3}}+\frac{1}{2} e^{-\frac{\sqrt{3} t}{2}} \cos \left(\frac{t}{2}\right)+\frac{1}{2} e^{\frac{\sqrt{3} t}{2}} \cos \left(\frac{t}{2}\right)$

(I show only one element of each output because they're long).

• One might want to pre-process the RootSum[] objects with Normal[] before feeding to ExpToTrig[]. Jan 14 '17 at 15:33
• @J.M. Nice one, thanks! Jan 14 '17 at 15:38
• @corey979 thank you. Jan 14 '17 at 17:27