TITLE: Solve for $X$ in $Y = X^TAX$.
QUESTION [8 upvotes]: Suppose $$
Y = X^TAX,
$$ where $Y$ and $A$ are both known $n\times n$, real, symmetric matrices.  The unknown matrix $X$ is restricted to $n\times n$.

I think there should be at least one real valued solution for $X$.  How do I solve for $X$?

REPLY [6 votes]: The solution of the problem exists if and only if the (symmetric) matrices $Y$ and $A$ have the same inertia, that is, they have the same number of positive, zero, and negative eigenvalues.
Every symmetric matrix $S$ can be transformed by a (nonsingular) congruent transformation to a diagonal matrix $D$ with $+1$, $-1$, and/or $0$ on the diagonal (consider them ordered, e.g., $1$'s first, then $0$'s, then $-1$'s). How? Let $S=U\Lambda U^T$ be the eigen-decomposition of $S$ such that $\Lambda=\mathrm{diag}(\lambda_1,\ldots,\lambda_n)$, $\lambda_1\geq\cdots\geq\lambda_n$. Then $S=(UC)\mathrm{sgn}(\Lambda)(CU^T)=(UC)\mathrm{sgn}(\Lambda)(UC)^T$, where $C$ is a diagonal matrix such that $(C)_{ii}=|\lambda_i|^{1/2}$ if $\lambda_i\neq 0$ and $(C)_{ii}=1$ (or whatever nonzero) otherwise. With $P=UC$ and $D=\mathrm{sgn}(\Lambda)$, we get the desired transformation $S=PDP^T$ introduced above.
Now, since both $Y$ and $A$ must have the same inertia (see the Sylvester's law of inertia), both $Y$ and $A$ can be congruently transformed to the same diagonal matrix $D$ with $1$'s, $-1$'s, and/or $0$'s on the diagonal. That is, there are nonsingular matrices $P_Y$ and $P_A$ such that
$$
Y=P_YDP_Y^T \quad\text{and}\quad A=P_ADP_A^T.
$$
Therefore,
$$
P_Y^{-1}YP_Y^{-T}=P_A^{-1}AP_A^{-T}
$$
and hence
$$
Y=P_YP_A^{-1}AP_A^{-T}P_Y^T=(P_YP_A^{-1})A(P_YP_A^{-1})^T.
$$
A matrix $X$ you look for is then $X=(P_YP_A^{-1})^T$. Saying "a matrix", because $X$ (same as the congruent transformations defined above) are not unique.