TITLE: When is the rank of $AB+BA$ equal to one?
QUESTION [7 upvotes]: For two arbitrary matrices $A$ and $B$, are there any known conditions for the rank of $AB+BA$ to be equal to one?

REPLY [2 votes]: Consider the function $f:X\in M_n(\mathbb{C})\mapsto AX+XA$, where $A\in M_n(\mathbb{C})$ and $spectrum(A)=(\lambda_i)$.
Then $f=A\otimes I_n+I_n\otimes A^T$, where the matrices are stacked into vectors rows by rows, cf.
https://en.wikipedia.org/wiki/Kronecker_product
and $spectrum(f)=\{\lambda_i+\lambda_j;i,j\}$.
Finally, $f$ is a bijection iff $A$ satisfies the property $\mathcal{P}$: for every $i,j$, $\lambda_i+\lambda_j\not= 0$.
Here, we want to satisfy an equation in the form $AB+BA=U$, where $U$ is a given matrix with rank $1$.
The algebraic set $W=\{Y;rank(Y)\leq 1\}$ is Zariski closed and has dimension $2n-1$; $V=\{Y;rank(Y)=1\}$ is a Zariski open dense subset of $W$ and therefore is a quasi-affine variety (or a constructible set or simply a variety).
Let $E_n=\{(A,B)\in M_n;rank(AB+BA)=1\}$. Consider a generic matrix $A$; then $A$ satisfies $\mathcal{P}$ and, for every $U\in V$, there exists exactly one matrix $B_U$ s.t. $AB_U+B_UA=U$. Note that $B_U$ is simply the solution of a linear equation, and can be easily  computed.
Then the local dimension  of $E_n$ in such a point is $n^2+2n-1$ and the dimension of $E_n$ is $d_n=n^2+2n-1$; yet, the maximal dimension may be reached using matrices $A$ that do not satisfy $\mathcal{P}$.
For example, assume that $n=4$ ($d_4=23$) and consider $A=diag(u,-u,v,-v)$, where $u,v$ are distinct non-zero; here $f$ is diagonalizable and $dim(\ker(f))=4$; more precisely, the matrices in $\ker(f)$ are in the form $\begin{pmatrix}0&a_1&0&0\\a_2&0&0&0\\0&0&0&b_1\\0&0&b_2&0\end{pmatrix}$.
$\textbf{Remark.}$ Note that we can see the dimension of the algebraic set $F_n=\{(A,B);AB+BA=0\}$ in the neighborhood of such matrices; the stabilizer $\{P;P^{-1}AP=A,P^{-1}BP=B\}=\{diag(a,a,b,b);a,b\}$ has dimension $2$; then the dimension of the orbit is $4^2-2$; we add the variations of the entries $u,v$ and $a_1,a_2,b_1,b_2$ where the products $a_1a_2,b_1b_2$ are fixed; the total is $dim(F_4)=14+2+2=18$ and, more generally, $dim(F_n)=floor(n^2+n/2)$.
Now we take $A=diag(1,-1,2,-2),\tilde{B}=\begin{pmatrix}0&1&0&0\\2&0&0&0\\0&0&0&3\\0&0&4&0\end{pmatrix}$. To obtain an element of $E_4$, we choose $B=\tilde{B}+H$, where $rank(H)=1$ and $AH=HA$; for example $H=diag(0,0,0,1)$.
Using the Grobner basis theory , we can show -with the help of a computer- that the local dimension of $E_4$ in $(A,B)$ is also $23$.