TITLE: Condition on endomorphisms satisfying $\operatorname{Ker} f=\operatorname{Im} f$
QUESTION [5 upvotes]: Let $E$ a finite dimensional vector space and $f \in \mathcal{L}(E)$. Show that:
$$\operatorname{Ker} f=\operatorname{Im} f \Leftrightarrow (f^2=0) \wedge (\exists h \in \mathcal{L}(E) \mid h \circ f + f \circ h=Id_E)$$

My attempt:
I managed to show the $\Leftarrow$ implication.
For $x \in \operatorname{Im} f$, $x=f(y)$, then $x \in \operatorname{Ker} f$ because $f(x)=f^2(y)=0$ so $\operatorname{Im} f \subset \operatorname{Ker} f$.
For $x \in \operatorname{Ker} f$, we have $h \circ f(x) + f \circ h(x)=f \circ h(x)=x$ which shows that $x \in \operatorname{Im} f$. So $\operatorname{Ker} f \subset \operatorname{Im} f \Rightarrow \operatorname{Ker} f = \operatorname{Im} f$.
Now, assuming $\operatorname{Ker} f = \operatorname{Im} f$, for any $x$, we have $f^2(x)=f(f(x))=0$, hence $f^2=0$. Yet, I can’t figure out the other part of the $\Rightarrow$ implication. I guess we would need to construct explicitly a function $h$ satisfying the equality. Generally in these kind of problems, a trick is to consider the decomposition $E=\operatorname{Ker} f + \operatorname{Im} f$ but it is here clearly not possible. Could anyone give me a hint on how to proceed?

REPLY [5 votes]: Let $d$ be the dimension of the kernel, pick a basis of the kernel $v_1,\dots,v_d.$
Since the kernel is the image, we can pick $u_i$ so that $f(u_i)=v_i.$ Note at the least that the $u_i$ are not in the kernel because then $v_i=0.$
Show $v_1,\cdots v_d,u_1,\cdots,u_d$ are a basis for the whole space.
Part 1: Show that $u_i$ are independent. Hint: If $\sum a_iu_i=0,$ consider $f\left(\sum a_iu_i\right).$
Part 2: Show there can’t be any element outside the set of elements generated by $u_i,v_i.$ Hint: For any $u,$ find $b_i$ so that  $f(u)=\sum b_i v_i$ and consider $u’=u-\sum b_iu_i.$
Part 3: Show the $u_i,v_i$ are all independent. Hint: Suppose $\sum a_iu_i+\sum b_jv_j =0$ with some $a_i,b_j$ non-zero.

Once you’ve done this, define $h$ on the basis with $h(u_i)=v_i,h(v_i)=u_i.$
Validate this $h$ works.

This approach shows that in some basis, the matrix of such an $f$ can be:
$$F=\begin{pmatrix}0_d&I_d\\0_d&0_d\end{pmatrix}$$ and $h$ can be:
$$H=\begin{pmatrix}0_d&I_d\\I_d&0_d\end{pmatrix}$$
where the $0_d,I_d$ are the $d\times d$ zero and identity matrices, respectively.
It is a pretty easy calculation to show that:
$$HF+FH=I_{2d}$$

It’s not clear we need finite-dimensional, as long as we accept the axiom of choice, which allows us to pick the $u_i$ for all $i.$