Prove there exists a particular basis of $\mathrm{Ker}(u^2+u+Id)$ Let $u \in \mathcal{L}(\mathbb{R}^5)$, with $u^3-u^2-u-2 \mathrm{Id}=0$ and $\mathrm{Tr}(u)=0$. So I have shown that $2$ is the only eigenvalue of $u$ and moreover that $\mathrm{Ker}(u^2+u+\mathrm{Id})\bigoplus\mathrm{Ker}(u-2\mathrm{Id})=\mathbb{R}^5$ with $\dim(\mathrm{Ker}(u-2\mathrm{Id}))=1$ therefore,
$$ \dim(\mathrm{Ker}(u^2+u+\mathrm{Id}))=4$$
How can I prove there exists a basis $(e_1,e_2,e_3,e_4)$ of $\mathrm{Ker}(u^2+u+\mathrm{Id})$ such that:
$$ \left\{\begin{array}{ll} u(e_1)=e_2\\ u(e_2)=-e_1-e_2\\ u(e_3) = e_4\\ u(e_4) = -e_3-e_4\end{array} \right.$$

My idea was:
Let $e_1 \neq0$  be an element of $\mathrm{Ker}(u^2+u+\mathrm{Id})$, then let's call $e_2 = u(e_1) $. I wanted to show afterwards that $(e_1,e_2)$ was linearly independant in $\mathrm{Ker}(u^2+u+\mathrm{Id})$, so I could take $e_3$ such that $(e_1,e_2,e_3)$ is still linearly independant in $\mathrm{Ker}(u^2+u+\mathrm{Id})$ and finally take $e_4 = u(e_3)$ so $(e_1,e_2,e_3,e_4)$ would verify all the conditions, except maybe the fact it is a basis of $\mathrm{Ker}(u^2+u+\mathrm{Id})$.

I don't know if it will work, and I feel there is something maybe more efficient, could somebody help me please?

In other words, my problem is as follows.
Let $A\in \mathcal{M}_5(\mathbb{R})$ be a matrix such that $\mathrm{Tr(A)=0}$ and $A^3-A^2-A-2I_n = 0$. I want to show that $A$ is similar to :
\begin{pmatrix}
2 & 0 & 0 & 0 & 0 \\ 
0 & 0 & -1 & 0 & 0 \\ 
0 & 1 & -1 & 0 & 0 \\ 
0 & 0 & 0 & 0 & -1 \\ 
0 & 0 & 0 & 1 & -1
\end{pmatrix}
 A: I think that your approach is a good one.
Begin by taking $e_1$ to be any non-zero element of $\ker(u^2 + u + \operatorname{Id})$. To see that $e_2 = u(e_1)$ is linearly independent from $e_1$, suppose to the contrary that it is not. It follows that there exists a scalar $\lambda \in \Bbb R$ such that $u(e_1) = \lambda e_1$. Thus,
$$
(u^2 + u + \operatorname{Id})e_1 = 0 \implies (\lambda^2 + \lambda + 1)e_1 = 0.
$$
However, there is no real solution to the equation $\lambda^2 + \lambda + 1 = 0$, so this is impossible.
From there, we automatically satisfy part of the requirement for the basis. Indeed, we have
$$
u(e_2) = u^2(e_1) = (-u - \operatorname{Id})e_1 = -e_1-e_2.
$$
From there, take $e_3$ to be any element of $\ker(u^2 + u + \operatorname{Id})$ outside of the span of $e_1,e_2$, and let $e_4 = u(e_3)$. As before, we find that $e_3,e_4$ satisfy the required relations
$$
u(e_3) = e_4, \quad u(e_4) = -e_3-e_4.
$$
From there, one would need to show that $e_1,e_2,e_3,e_4$ is a linearly independent set, which is a bit tricky.

Suppose to the contrary that $e_4$ lies in the span of $e_1,e_2,e_3$. That is, there exist constants $c_1,c_2,c_3$ such that
$$
e_4 = u(e_3) = c_1 e_1 + c_2 e_2 + c_3 e_3.
$$
With that, we have
$$
(u - c_3\operatorname{Id}) e_3 = c_1 e_1 + c_2 e_2.
$$
We know that the polynomial $x^2 + x + 1$ has no real roots.
Thus, the polynomials $x^2 + x + 1$ and $x - c_3$ are relatively prime. By Euclidean division, we have
$$
x^2 + x + 1 = q(x)(x-c_3) + r
$$
for some polynomial $q$ and some non-zero $r \in \Bbb R$. Equivalently, we have
$$
q(x)(x - c_3) = r - (x^2 + x + 1) \implies\\
q(u)(x - c_3 \operatorname{Id})e_3 = [r \operatorname{Id} - (u^2 + u + \operatorname{Id})]e_3 = re_3.
$$
So, we have
$$
(u - c_3\operatorname{Id}) e_3 = c_1 e_1 + c_2 e_2 \implies\\
\frac 1r q(u)(u - c_3\operatorname{Id}) e_3 =  \frac 1r q(u) (c_1 e_1 + c_2 e_2) \implies\\
e_3 = \frac 1r q(u) (c_1 e_1 + c_2 e_2).
$$
However, $\frac 1r q(u) (c_1 e_1 + c_2 e_2)$ must be in the span of $e_1$ and $e_2$, so we have concluded that $e_3$ lies in the span of $e_1$ and $e_2$, which is false.

On the other hand, if you are already aware of the existence of rational canonical form, then you can reach the desired conclusion almost immediately.
A: This is my own solution to the following problem:

Let $A\in \mathcal{M}_n(\mathbb{R})$ be a matrix such that $\mathrm{Tr(A)=0}$ and $A^3-A^2-A-2I_n = 0$. I want to show that there exists $p \in \mathbb{N}$ such that $n=5p$ and that $A$ is similar to :
$$C=\begin{pmatrix} 2I_p & 0 & 0 & 0 \\  0 & B & 0 & 0 \\  0 & 0 & \ddots & 0 \\  0 & 0 & 0 & B \end{pmatrix}$$
where $B = \begin{pmatrix} 0 & -1 \\  1 & -1 \end{pmatrix}$

First of all, $P(X) = X^3-X^2-X-2$ annulates $A$ and one can see that:
$$P(X) = (X-2)(X^2+X+1) = (X-2)(X-j)(X-\bar{j})$$
where $j = \mathrm{e}^{i2 \pi/3}$.
Therefore as $P$ annulates $A$ and is irreducible with all its factors of degree $1$ and all of its roots with multiplicity equals to one thus I know $A$ is diagonalizable on $\mathbb{C}$.
Moreover, we know that $\sigma(A) \subset\{2,j,\bar{j}\}$ as $P$ annulates $A$.
Therefore, there exists $a,b,c \in\mathbb{N}$ such that its characteristic polynomial $\chi_A$ can be written:
$$\chi_A(X) = (X-2)^a(X-j)^b(X-\overline{j})^c$$
But $\chi_A \in \mathbb{R}[X]$ because $A$ is a matrix with real coefficients. Consequently $\chi_A = \overline{\chi_A}$ so $b = c$.
Moreover $\mathrm{Tr}(A) = 2a+bj+c\bar{j} = 2a+b(j+\overline{j})=2a-b=0   $, so $2a = b$. Finally $a+b+c = a+2b= \deg(\chi_A) = n$, we deduce that $\boxed{5a =n}$.
Therefore,
$$\chi_A(X) = (X-2)^{a}(X-j)^{2a}(X-\bar{j})^{2a}$$
As $a \neq 0$ we have $\sigma(A) = \{2,j,\bar{j}\} $ and because $A$ is diagonalizable on $\mathbb{C}$ there exists $P \in GL_n(\mathbb{C})$ such that,
$$A = P\begin{pmatrix}
2I_a & 0 & 0 & 0 & 0 & 0 \\ 
0 & j & 0 & 0 & 0 & 0 \\ 
0 & 0 & \bar{j} & 0 & 0 & 0 \\ 
0 & 0 & 0 & \ddots & 0 & 0 \\ 
0 & 0 & 0 & 0 & j & 0 \\ 
0 & 0 & 0 & 0 & 0 & \bar{j}
\end{pmatrix}  P^{-1}$$
On top of that if we call $B = \begin{pmatrix} 0 & -1 \\  1 & -1 \end{pmatrix}$ we have $\chi_B(X)= X^2+X+1 = (X-j)(X-\bar{j})$, thus because $j \neq \overline{j}$ we can find $Q \in GL_2(\mathbb{C})$ such that,
$$ B = Q \begin{pmatrix} j & 0 \\  0 & \overline{j} \end{pmatrix} Q^{-1} $$
Hence,
$$C =
\begin{pmatrix} I_a & 0 & 0 & 0 \\  0 & Q & 0 & 0 \\  0 & 0 & \ddots & 0 \\  0 & 0 & 0 & Q \end{pmatrix}
\begin{pmatrix}
2I_a & 0 & 0 & 0 & 0 & 0 \\ 
0 & j & 0 & 0 & 0 & 0 \\ 
0 & 0 & \bar{j} & 0 & 0 & 0 \\ 
0 & 0 & 0 & \ddots & 0 & 0 \\ 
0 & 0 & 0 & 0 & j & 0 \\ 
0 & 0 & 0 & 0 & 0 & \bar{j}
\end{pmatrix}
\begin{pmatrix} I_a & 0 & 0 & 0 \\  0 & Q & 0 & 0 \\  0 & 0 & \ddots & 0 \\  0 & 0 & 0 & Q \end{pmatrix}^{-1}$$
Consequently, $A$ is similar to the real matrix $C$ in $\mathcal{M}_n(\mathbb{C})$ so we can write $A = RCR^{-1}$ with $R = R_1 +iR_2\in GL_n(\mathbb{C})$  and $R_1,R_2 \in \mathcal{M}_n(\mathbb{R})$
Hence $AR = RC$, then $ AR_1 = R_1C$ and $AR_2 = CR_2$.
Moreover $\varphi : x \mapsto \det(R_1+xR_2) $ is a polynomial function with real coefficients and we know $\varphi(i) = \det(R) \neq 0$ therefore $\varphi$ has a finite number of roots, meaning we can find $x_0 \in \mathbb{R}$ such that $\varphi(x_0) \neq0$, id est $R_0 = R_1+x_0R_2 \in GL_2(\mathbb{R})$ and :
$$AR_0 = AR_1+x_0AR_2 = R_1C +x_0R_2C = R_0C$$
Finally,
$$A = R_0 C R_0^{-1}$$
So it proves that $A$ is similar to $C$ in $\mathcal{M}_n(\mathbb{R})$.
A: Let us think of the problem in terms of the associated $\mathbb{R}[u]$-module.  The condition that $u^3 - u^2 - u - 2 = (u-2) (u^2+u+1)$ annihilates this module implies that the decomposition of the module into a direct sum of indecomposable cyclic modules must have factors $\mathbb{R}[u] / \langle u-2 \rangle$ and $\mathbb{R}[u] / \langle u^2+u+1 \rangle$ only.  Then, the restriction that the dimension as a vector space over $\mathbb{R}$ is 5 restricts us to the choices $(\mathbb{R}[u] / \langle u-2 \rangle)^5$, $(\mathbb{R}[u] / \langle u-2 \rangle)^3 \oplus \mathbb{R}[u] / \langle u^2+u+1 \rangle$, or $\mathbb{R}[u] / \langle u-2 \rangle \oplus (\mathbb{R}[u] / \langle u^2+u+1 \rangle)^2$; and out of these, the only one with $\operatorname{tr}(u) = 0$ is the last one.  Now, $u$ operating on this module $\mathbb{R}[u] / \langle u-2 \rangle \oplus (\mathbb{R}[u] / \langle u^2+u+1 \rangle)^2$ has $\ker(u^2+u+\operatorname{id}) = 0 \oplus (\mathbb{R}[u] / \langle u^2+u+1 \rangle)^2$, and $e_1 := (0, 1, 0), e_2 := (0, u, 0), e_3 := (0, 0, 1), e_4 := (0, 0, u)$ does form an $\mathbb{R}$-basis of $\ker(u^2+u+\operatorname{id})$ with the desired properties.
