Matrix equation XAX=B where the solution must be diagonal $$X_{solution}=\arg\min_X \|XAX-B|_F \quad\mathrm{subject\ to}$$
X is square and diagonal
A is square and positive semi-definite
B is square and positive semi-definite
Any pointers or relevant search terms?
 A: @Robert, we can assume that $A$ is diagonal and $X$ is symmetric, that I shall do in the sequel. We suppose that the matrices are real. You seek the argmin of the function $f:X\in Sym\rightarrow trace(UU^T)$ where $U=XAX-B$. Then $D_Xf=0$ iff, for every symmetric matrix $H$, 
$trace((AX^2AX+XAX^2A-AXB-BXA)H)=0$. Therefore,
any symmetric candidate $X$ satisfies $AX^2AX+XAX^2A-AXB-BXA=0$ (system of equations of degree $3$), that is equivalent to $AX(XAX-B)$ is skew symmetric.
EDIT: Federico, you are right, but, in my mind, the OP assumed $X$ diagonal in order to simplify the problem. Yet, if $X$ is a unknown symmetric matrix, then we cannot assume that it is diagonal. Of course, if the OP correctly stated his question, then I considered a distinct problem.
Now we assume that $X=diag((x_i)_i)$. Let $Z=AX^2AX+XAX^2A-AXB-BXA$. In the same way, we obtain: for every $H$ diagonal,  $trace(ZH)=0$. Therefore, for every $i$, $Z_{i,i}=0$ and we have a system of $n$ equations of degree $3$ in the $n$ unknowns $(x_i)_i$. More precisely, if $A=[a_{i,j}],B=[b_{i,j}]$, then for every $i$, $\sum_j a_{i,j}^2x_i{x_j}^2-\sum_ja_{i,j}b_{i,j}x_j=0$.
