2
$\begingroup$

My students will need to do the following work by hand.

\begin{align*} x_1'&=-\frac14x_1+2x_2,\quad x_1(0)=1\\ x_2'&=-8x_1-\frac14x_2,\quad x_2(0)=1 \end{align*} They set it up in matrix form. $$ \begin{bmatrix} x_1\\ x_2 \end{bmatrix}' = \begin{bmatrix} -\frac14 & 2\\ -8 & -\frac14 \end{bmatrix} \begin{bmatrix} x_1\\ x_2 \end{bmatrix},\qquad \begin{bmatrix} x_1(0)\\ x_2(0) \end{bmatrix} = \begin{bmatrix} 0\\ 0\\ \end{bmatrix} $$ Then they get the eigenvalues and eigenvectors by hand, which can be checked as follows:

A = {{-1/4, 2}, {-8, -1/4}}
eigsys = Eigensystem[A]

{{-(1/4) + 4 I, -(1/4) - 4 I}, {{-I, 2}, {I, 2}}}

Then they take one eigenvalue, $\lambda=-\frac14+4i$, and its corresponding eigenvector $\vec v=\begin{bmatrix}-i\\2\end{bmatrix}$, and perform the following hand calculations.

$$ \begin{align*} e^{(-1/4+4i)t}\begin{bmatrix}-i\\2\end{bmatrix} &=e^{-t/4}(\cos 4t+i \sin 4t)\left\{\begin{bmatrix}0\\2\end{bmatrix}+i\begin{bmatrix}-1\\0\end{bmatrix}\right\}\\ &=e^{-t/4}\left\{\begin{bmatrix}\sin 4t\\2\cos 4t\end{bmatrix}+i\begin{bmatrix}-\cos 4t\\2\sin 4t\end{bmatrix}\right\} \end{align*} $$

Then the real and imaginary parts form a fundamental set of solutions and the general solution can be written in the form

$$ \begin{bmatrix}x_1\\x_2\end{bmatrix} =e^{-t/4}\left\{C_1\begin{bmatrix}\sin 4t\\2\cos4t\end{bmatrix}+C_2\begin{bmatrix}-\cos 4t\\2\sin4t\end{bmatrix}\right\}, $$ or equivalently, $$\begin{bmatrix}x_1\\x_2\end{bmatrix}= \begin{bmatrix}e^{-t/4}\sin 4t & -e^{-t/4}\cos 4t\\ 2e^{-t/4}\cos 4t & 2e^{-t/4}\sin4t\end{bmatrix} \begin{bmatrix}C_1\\C_2\end{bmatrix}, $$ where the matrix $$ \begin{bmatrix}e^{-t/4}\sin 4t & -e^{-t/4}\cos 4t\\ 2e^{-t/4}\cos 4t & 2e^{-t/4}\sin4t\end{bmatrix} $$ is called the fundamental matrix.

So I tried the following.

Exp[eigsys[[1, 1]] t]*{{-I}, {2}}

(*{{-I E^((-(1/4) + 4 I) t)}, {2 E^((-(1/4) + 4 I) t)}}*)

Then I tried a Complex Expand.

ComplexExpand[%]

(*{{-I E^(-t/4) Cos[4 t] + 
   E^(-t/4) Sin[4 t]}, {2 E^(-t/4) Cos[4 t] + 2 I E^(-t/4) Sin[4 t]}}*)

Then I needed to form the Fundamental Matrix, so I used:

aa = 
 ArrayFlatten[{{Simplify[Re[%], t >= 0], Simplify[Im[%], t >= 0]}}]

(*{{E^(-t/4) Sin[4 t], -E^(-t/4) Cos[4 t]}, {2 E^(-t/4)
    Cos[4 t], 2 E^(-t/4) Sin[4 t]}}*)

Then I formed a function for the general solution.

x[t_] = aa.{{c1}, {c2}}

(*{{-c2 E^(-t/4) Cos[4 t] + 
   c1 E^(-t/4) Sin[4 t]}, {2 c1 E^(-t/4) Cos[4 t] + 
   2 c2 E^(-t/4) Sin[4 t]}}*)

Then I use Collect to factor our the E^[-t4].

x[t_] = Collect[aa.{{c1}, {c2}}, Exp[-t/4]]

(*{{E^(-t/4) (-c2 Cos[4 t] + c1 Sin[4 t])}, {E^(-t/
    4) (2 c1 Cos[4 t] + 2 c2 Sin[4 t])}}*)

Then I solved for the constants using my initial conditions.

c1c2 = Solve[x[0] == {{1}, {1}}, {c1, c2}]

(*{{c1 -> 1/2, c2 -> -1}}*)

And I then plugged the solutions into my general solution.

x[t_] = x[t] /. First[c1c2]

(*{{E^(-t/4) (Cos[4 t] + 1/2 Sin[4 t])}, {E^(-t/
    4) (Cos[4 t] - 2 Sin[4 t])}}*)

Of course, all of the output for these steps is much better for the students if we start with the command:

$PrePrint := If[MatrixQ[#], MatrixForm[#], #] &

Then they can see most of the output in matrix form.

I then checked my answer with DSolveValue.

sol = 
 DSolveValue[{{x1'[t], x2'[t]} == 
    A.{x1[t], x2[t]}, {x1[0], x2[0]} == {1, 1}}, {x1[t], x2[t]}, t]

(*{1/2 E^(-t/4) (2 Cos[4 t] + Sin[4 t]), 
 E^(-t/4) (Cos[4 t] - 2 Sin[4 t])}*)

To make it look like my last solution, I expanded and collected.

Collect[Expand[sol], Exp[-t/4]]

(*{E^(-t/4) (Cos[4 t] + 1/2 Sin[4 t]), 
 E^(-t/4) (Cos[4 t] - 2 Sin[4 t])}*)

I think I might have a pretty good approach here for students using Mathematica for the very first time, but I would love to hear suggestions. The handout for my students is here.

$\endgroup$
  • $\begingroup$ I think your approach is excellent if you want to teach expression manipulation and simplification in mathematics. But I hope your students have some prior experience of programming! $\endgroup$ – djp Mar 19 '15 at 20:06
  • $\begingroup$ Can you formulate a specific question? What is the Mathematica issue you want to address? It seems this is more a pedagogy question. $\endgroup$ – Jens Mar 19 '15 at 21:40
  • $\begingroup$ I am asking my expert colleagues in Mathematica exchange if I have followed a good procedure, or if perhaps they have better ideas on how to do what I have done. $\endgroup$ – David Mar 20 '15 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.