TITLE: General solution of a system of linear differential equations with multiple generalized eigenvectors
QUESTION [5 upvotes]: I am looking for general solutions for the linear sODE's
$$\textbf{x}'(t) = A\textbf{x}(t)$$
with $t \geq 0$ and $A \in \mathbb{R}^{n \times n}$
Let focus on just real eigenvalues and eigenvectors. For the case of $n=2$, where we have one eigenvalue, $\lambda \in \mathbb{R}$, such that $am(\lambda)=2, gm(\lambda)=1$ I know that the general solution is
$$\textbf{x}(t) = e^{\lambda t}(c_1 \textbf{v} + c_2\textbf{w}) + te^{\lambda t}(c_2 \textbf{w})$$
where $c_1,c_2 \in \mathbb{R}$, $\textbf{v}$ is the eigenvector corresponding to $\lambda$ and $\textbf{w}$ is a generalized eigenvector of $A$.
But what would be the general solution be in the case $n = 3$ with one eigenvalue, $\lambda \in \mathbb{R}$, such that $am(\lambda)=3, gm(\lambda)=1$ or in the case of two eigenvalues  $\lambda_1,\lambda_2$ with $am(\lambda_1)=2, gm(\lambda_1) = 1, am(\lambda_2)=1, gm(\lambda_2) = 1$?
So, all in all, how would one find the general solution to such systems of linear differential equations?
Full answers are appreciated, but I prefer some hints to find the solution myself.
Thanks in advance!
Bonus: The same question but then with difference equations.

REPLY [7 votes]: This process is explained in numerous ODE textbooks and lecture notes; why reinvent the wheel? 

Find the eigenvalues (you are assuming they are real). 
For each eigenvalue $\lambda$, find a basis of the eigenspace, i.e., of the null space of $A-\lambda I$. 
Each basis element $v$ yields a solution $e^{\lambda t}v $.
If the dimension of the eigenspace is equal to the algebraic multiplicity of $\lambda$, we are done with $\lambda$. 
Otherwise look for generalized  eigenvectors on top of each $v$ as in step 3. These come from equations $(A-\lambda I)w_1=v$, $(A-\lambda I)w_2=w_1$, etc.
The generalized eigenvectors contribute solutions $$e^{\lambda t} (tv+w_1),\quad   e^{\lambda t} \left(\frac{t^2}2 v+tw_1+w_2\right), \dots$$ where the coefficients are of the form $t^k/k!$
The number of solutions obtained in this way is $n$. Since they are linearly independent by construction, their linear combinations yield the general solution of the system.