I have seen people ask about solving this equation where A is the unknown matrix but I have never seen people talking about X being the unknown. The matrices are square matrices.
In my situation X will have entries in the rationals and has weight zero - i.e. the sum of all rows and columns add up to zero. A and B have entries in the integers and rationals respectively and that A and B are symmetric.
Now for small matrices - say of size $5 \times 5$ - I can solve the equation by brute force in Mathematica using the Solve function.
i.e. one solution is: (note I found 156 solutions in total)
$A = \left( \begin{array}{ccccc} 681 & -260 & -286 & -208 & 78 \\ -260 & 105 & 110 & 80 & -30 \\ -286 & 110 & 126 & 88 & -33 \\ -208 & 80 & 88 & 69 & -24 \\ 78 & -30 & -33 & -24 & 14 \\ \end{array} \right)$
and
$B = \left( \begin{array}{ccccc} \frac{43750}{13} & -\frac{21875}{13} & -\frac{28125}{13} & \frac{9375}{13} & -\frac{3125}{13} \\ -\frac{21875}{13} & \frac{53125}{39} & \frac{21875}{39} & -\frac{34375}{39} & \frac{25000}{39} \\ -\frac{28125}{13} & \frac{21875}{39} & \frac{109375}{39} & -\frac{50000}{39} & \frac{3125}{39} \\ \frac{9375}{13} & -\frac{34375}{39} & -\frac{50000}{39} & \frac{165625}{39} & -\frac{109375}{39} \\ -\frac{3125}{13} & \frac{25000}{39} & \frac{3125}{39} & -\frac{109375}{39} & \frac{90625}{39} \\ \end{array} \right)$
giving a solution to $X^T A X = B$ of
$X = \left( \begin{array}{ccccc} -8 & \frac{10}{3} & \frac{17}{3} & -\frac{7}{3} & \frac{4}{3} \\ -\frac{152}{13} & \frac{436}{39} & \frac{191}{39} & -\frac{172}{39} & \frac{1}{39} \\ -\frac{45}{13} & -\frac{238}{39} & \frac{526}{39} & \frac{37}{39} & -\frac{190}{39} \\ \frac{24}{13} & \frac{29}{39} & -\frac{479}{39} & \frac{190}{39} & \frac{188}{39} \\ \frac{277}{13} & -\frac{119}{13} & -\frac{153}{13} & \frac{12}{13} & -\frac{17}{13} \\ \end{array} \right)$
My problem is trying to do this for $n \times n$ matrix with $n \gt 5$. The brute force approach in Mathematica just goes away and never comes back. The $ 5 \times 5$ matrix above takes about 40 seconds to solve. A $6 \times 6$ matrix hasn't solved after 8 hours.
Does anyone have insight into solving without a brute force Mathematica Solve function "black box" approach? My linear algebra skills have atrophied and any insight would be much appreciated.