For any $A\in M_n(\mathbb{R})$, there is a $B$ s.t. $\operatorname{rank}(A)+\operatorname{rank}(B)=n$ and $AB=0$. This is a qualifying exam question which I have little experience approaching. This is certainly an exercise in linear algebra so I would like to obtain a method in solving similar questions.

Let $M_n(\mathbb{R})$ be the ring of $n\times n$ matrices over $\mathbb{R}$. If $A\in M_n(\mathbb{R})$, then there exists a $B\in M_n(\mathbb{R})$ s.t. $\operatorname{rank}(A)+\operatorname{rank}(B)=n$ and $AB=0$. Also does there exist a $B$ with the same properties such that $BA=0$ as well?

As far as I can tell, there is a similar question, but the question is over $\mathbb{C}$ coefficients so this is not a repeat question.
My approach is as follows. Since we work over $\mathbb{R}$, we should focus on the Rational Canonical Form. So write $A$ as a direct sum of companion matrices. The rank is preserved under similarity classes. The rank of $A$ is the sum of the ranks of the companion matrices. So the problem reduces to proving the result for a companion matrix.
Let $A=\begin{pmatrix}
0 & \dots & \dots & -a_1\\
1 & 0 & \dots &-a_2\\
\ddots &\ddots & \ddots & \ddots \\
0 & \dots & 1 &-a_{n-1}
\end{pmatrix}$ be a companion matrix. This has either rank $n-1$ or $n-2$. Then there should be choices of $B$ which work. Of course, this would be a tedious computation.
My question. Is there a better approach to this question? For example, some way to relate $M_n(\mathbb{R})$ to $M_n(\mathbb{C})$ so that I can use Jordan canonical forms instead?
 A: The kernel, or nullspace, of $A$ is a subspace of $\mathbb{R}^n$.  Let $\{b_1, \ldots, b_k\}$ be a basis for the kernel.  Take $B$ to be the matrix representing the linear transformation mapping the standard basis of $\mathbb{R}^k$ to the basis of the kernel.  Then $AB = 0$, and, due to the Rank-Nullity Theorem, you have the result.
A: If $\operatorname{rank}(A)=0$ or $\operatorname{rank}(A)=n$, the result is obvious.
If $\operatorname{rank}(A)=r$ and $0<r<n$, then, we can find $P$ and $Q$ in $GL_n(\mathbb R)$ such that  $A = P \begin{pmatrix} I_r & 0 \\ 0 & 0\end{pmatrix}Q$.
And we can choose  $\ \ \ B = Q^{-1} \begin{pmatrix} 0 & 0 \\ 0 & I_{n-r}\end{pmatrix}P^{-1}$.
A: Here is a constructive approach. Fix such $n\times n$ real matrix $A$. Let $W$ be its row space (span of the rows of $A$), namely $W = im(A^T)$. Now $W$ is a subspace in $\mathbb R^n$, so you can compute its orthogonal complement $W^\perp$. Let $b_1,\ldots,b_k$ be a basis of $W^\perp$, and consider a matrix $B$ whose columns are $b_1,\ldots,b_k$, and fill the rest with zeros.
Now imagine how matrix product is computed, $AB$ is the zero matrix, as each row of $A$ is orthogonal to each column of $B$. Further, rank of $A$ is the dimension of $W$ as $rk(A)=rk(A^T)$. Lastly, we have $rk(B) = dim(W^\perp) = n - dim(W) = n- rk(A)$.
(Note, $W^\perp = im(A^T)^\perp = ker(A)$. So you just need to take a basis for $ker(A)$ for $b_1,\ldots,b_k$.)
Note, this isn't a "canonical form" approach, but I'm illustrating this can be done in a more elementary brute way.
A: In order to address also the last part of the question (getting $BA=0$ as well), let the image of $A$ be generated by the $k$ column vectors $a_1,...,a_k$ and complement this (in an arbitrary way) with vectors $c_1,...,c_{n-k}$ so that the matrix $P=[a_1,...,a_k,c_1,...,c_{n-k}]$ has rank $n$, whence is invertible.
Let the kernel of $A$ be generated by $n-k$ vectors $z_1,...,z_{n-k}$.
We want $B$ to map ${\rm Im}\,A$ to zero vectors and the $c_j$'s to $\ker A$. This is fulfilled for example when  $B$  satisfies
$$ BP= B ( a_1,...,a_k,c_1 ..., c_{n-k}) = {(0,...,0, z_1,...,z_{n-k})} =: Q $$
And the solution is simply to take $B=QP^{-1}$ which verifies ${\rm rank} A+{\rm rank} B=n$ and both of $AB=0$, $BA=0$ at the same time.
