Solving differential equations in linear algebra I'm having a hard time early on in this linear algebra course, I'm a first year student in University. I'm reading my textbook right now and it gives the following differential equation as an example with a solution and I still can't understand how to solve it:
$x'_1 = 3x_1 + x_2 + x_3 $
$x'_2 = 2x_1 + 4x_2 + 2x_3$
$x'_3 = -x_1 - x_2 + x_3$
It goes on to say that $x: R \rightarrow R^3$
and $x(t)$ is a matrix with one column of the $x_1(t)$, $x_2(t)$, $x_3(t)$.
Then it gives me a matrix which is just to coefficients of the above system of equations.
Then it gives me a Q and D such that $Q^{-1}AQ=D$ and $A=QDQ^{-1}$.
I have no clue where these matrices are obtained, they are just given to me in my textbook which is really frustrating. I feel like the people that wrote the textbook may have overlooked some steps that they find trivial but new students are just learning. Can someone please explain how to solve a differential equation like this?
Thanks
 A: Instead of just a bunch of unrelated equations, it's useful to consider your system of equations as an equation involving a matrix and a vector.  First take your three $x$'s and think of them as the components of a vector:
$$ {\bf x} = \pmatrix{x_1(t)\cr x_2(t)\cr x_3(t)\cr}$$
The left sides of your equations, the derivatives of the $x$'s, can be thought of as the derivative of the vector:
$$ {\bf x}' = \pmatrix{x_1'(t)\cr x_2'(t)\cr x_3'(t)\cr}$$
The right sides can be obtained by multiplying a matrix $A$ of constants with your vector:
$$ \pmatrix{ 3x_1 + x_2 + x_3\cr  2x_1 + 4x_2 + 2x_3\cr  -x_1 - x_2 + x_3\cr}
= \pmatrix{3 & 1 & 1\cr 2 & 4 & 2\cr -1 & -1 & 1\cr} {\bf x}$$
So now your differential equations can be written in a nice compact way as
${\bf x}' = A {\bf x}$.
But now how to solve this?  Well, the key observation is that if instead of the complicated matrix $A$ you had a diagonal matrix of constants
$$ D = \pmatrix{d_1 & 0 & 0\cr 0 & d_2 & 0\cr 0 & 0 & d_3\cr}$$
things would be very easy, because you could just separately solve the three equations:
$$ \eqalign{x_1' &= d_1 x_1 \cr x_2' &= d_2 x_2\cr x_3' &= d_3 x_3\cr}$$
The next insight is that (at least sometimes) you can transform your system
to a diagonal system: if $D = Q^{-1} A Q$ is a diagonal matrix for some 
invertible matrix $Q$, then ${\bf y} = Q^{-1} {\bf x}$ satisfies
$$ {\bf y}' = (Q^{-1} {\bf x})' = Q^{-1} {\bf x}' = Q^{-1} A {\bf x}
= Q^{-1} A Q Q^{-1} {\bf x} = D {\bf y}$$ 
So you could solve this for ${\bf y}$, and then get back to ${\bf x}$ by
${\bf x} = Q {\bf y}$.
And so the next question is, how can I find those $D$ and $Q$?  But I'll leave that part up to your linear algebra textbook...
