which $X$ can satisfy $XSX^2=D$? In the question, $X$, $S$, and $D$ are symmetric positive definite (SPD) matrices.
Just for an example, $X=S^{-\frac{1}{2}}(S^{\frac{1}{2}}DS^{\frac{1}{2}})^{\frac{1}{2}}S^{-\frac{1}{2}}$ is the solution to  $XSX=D$.
$X^2=XX$, $X^{\frac{1}{2}}X^{\frac{1}{2}}=X$, and  $X^{-\frac{1}{2}}X^{-\frac{1}{2}}=X^{-1}$. $X^{\frac{1}{2}}$ and $X^{-\frac{1}{2}}$ are also symmetric positive definite (SPD) matrices.

If $X$ is a solution, $SX=X^{-1}DX^{-1}$ must be positive definite. Therefore $X$ must commute with $S$. But then $XSX^2=D$ gives $X^3=S^{-1}D$. So, a solution exists if and only if $S$ commutes with $D$ and $X=S^{-1/3}D^{1/3}$.
