Reduction of endomorphisms

Hello, I am studying reduction of endomorphisms and I came across a theorem that I can't understand completely. It states that:

Theorem: Let ##E## be a finite dimensional ##K## vector space, ##K## sub-field of ##\mathbb{C}##, and ##f## be an endomorphism of ##E##. Then, ##f## is diagonalizable if and only if there exists a polynomial ##P## of ##K[X]##, such that ##P(f) = 0##, and ##P## can be written as a product of polynomials of degree 1, and its roots have order of multiplicity 1.

I understand the proof I have for the sufficient condition, but the proof for the necessary condition is hard to follow for me so I tried an alternate way. I would like you to tell me if this is correct please:

##\Leftarrow ## ) Assume that there exists distinct ##\lambda_i##'s for ##i = 1...p##, and a polynomial ##P## in the form ##P = a \prod_{i=1}^p (X - \lambda_i) ## such that ##P(f) = 0##.
I want to show that ##E = \bigoplus_{\lambda \in \text{Sp}(f) } E_{f,\lambda}##, which is a necessary and sufficient condition of diagonalizability.
We have that for any ##x\in E-\{0\}##, ## P(f)(x) = 0##. So there exists ##i \in \{ 1...p \}## such that ##f(x) = \lambda_i x##, and ##x## belongs to the eigenspace ##E_{f,\lambda_i}##. Therefore ##x\in \bigoplus_{\lambda \in \text{Sp}(f) } E_{f,\lambda}##, and ##E \subset \bigoplus_{\lambda \in \text{Sp}(f) } E_{f,\lambda}##. The other inclusion is trivial. So ##f## diagonalizable.

If ##x\neq 0##, then ## 0 = P(f)(x) = a\prod_{i = 1}^p (f(x) - \lambda_i x)##. So at least one term in the product is equal to 0. Therefore, there exists ##i## such that ##f(x) - \lambda_i x = 0##, which means that ##x## belongs to the eigenspace associated to ##f## and eigenvalue ##\lambda_i##.

I'm very confused, and probably wasting your time, but let us take a trivial example.
##E={\mathbb C}²##, and ##f## the endomorphism represented (with the canonical basis) by the matrix ##\begin{pmatrix}1 & 0 \\
0 & 2 \end{pmatrix}##.
So ##f(a,b)=(a,2b)##, and ##P(X)=(X-1)(X-2)##.
Take ##x=(1,1)##. ##f(x)=(1,2)##, so ##x## is not an eigenvector of f.
But ##P(f(x))=f(f(x))-3f(x)+2x=f(1,2)-3(1,2)+2(1,1)=(1,4)-(3,6)+(2,2)=(0,0)##.

Developping the polynomial ##Q(f)## as a sum, and setting ##n = \text{Card(Sp}(f))##, we see that for any vector ##x\in E##, the family ## (x,f(x),f^2(x),...,f^n(x))## is linearly dependent in ##E##. Therefore ## \text{dim}(E) \le n ##.

I'm somewhat troubled by this step, but maybe I'm wrong about the notation.
If I understood it correctly, ##{Sp}(f)## is the set of all eigenvalues of ##f##.

If that is indeed the case, ##n = \text{Card(Sp}(f))## is the number of eigenvalues of ##f##. You claim that ## \text{dim}(E) \le n ##. But that can't be true in general, because an endomorphism can have less distinct eigenvalues than the dimension of the vector space, and still be diagonalizable.

I also don't immediately see why the linearly dependence of the family ## (x,f(x),f^2(x),...,f^n(x))## for all x implies that ## \text{dim}(E) \le n ##.

In a previous post, we said that ##P(f) = 0## implies that the eigenvalues of ##f## are among the zeros of ##P##.
Then it had to be true that ## P(f) = 0 \iff Q(f) = 0 ##, where ##Q = \prod_{\lambda \in \text{Sp}(f)} (X - \lambda) ##.

Now I want to show that ## E = \bigoplus_{\lambda\in\text{Sp}(f)} \text{Ker}(f-\lambda e) ##. The inclusion ##\supset## is trivial, and we now want to show ##\subset##. We need to prove that any ##x\in E## has a decomposition over the eigenspaces of ##f## in the form ##x = x_1 + ... + x_n ##, where ##x_i \in \text{Ker}(f-\lambda_i e) ##.

That would be done if we could find ##n## polynomials ##Q_k## such that the endomorphism ##Q_k(f)## sends any ##x\in E## in the ##k##-th eigenspace and :
## 0 = Q(f) = e - \sum_{k=1}^n Q_k(f) ##.

Existence of a non-zero constant ##\beta## such that ## Q = \beta \ (1 - \sum_{k=1}^n Q_k)##, and the ##Q_k##'s have the same degree as ##Q##.

So if ##Q_k## has the form ##Q_k = \alpha (X-\mu) \prod_{i\neq k} (X-\lambda_i)##, where ##\alpha,\mu## are constants to be determined, then the first constraint is satisfied, and ##Q_k## has the same degree as ##Q##. For the second constraint, we must satisfy that ## 1 - \sum_{k=1}^n Q_k ## has the same roots as ##Q##. So it seems logic to determine ##\alpha,\mu## such that ##Q_k(\lambda_i) = \delta_{ik} \iff \alpha = \frac{1}{(\lambda_k-\mu) \prod_{i\neq k} (\lambda_k - \lambda_i)}## and ##\mu## is not an eigenvalue of ##f##.