0

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.

1729taxi
  • 109
  • 1
  • 3
  • I think you're asking about the equivalence of quadratic forms (with matrices $A$ and $B$ respectively). This is hard problem as far as I know (solved by Gauss for $n=2$). – Brauer Suzuki Jan 11 '22 at 08:58
  • Quadratic matrix equations are usually hard. See for example this article for references. The article also treats $XA-AX=X^2$, which is different of course, but has related references. – Dietrich Burde Jan 11 '22 at 09:05
  • you can turn this into a minimization problem $X\mapsto |X^TAX - B|^2$. It might be possible to solve this analytically, but you could certainly try something like gradient descent on it – Felix B. Jan 11 '22 at 11:09
  • hm it is going to be difficult to satisfy the rationality condition and weight zero condition with this approach I think – Felix B. Jan 11 '22 at 11:14
  • @1729 For the case where $X$ must be invertible, see this post. Essentially, one can get the solution (if one exists) by applying the reverse Hermite method twice. If $X$ is allowed to not be invertible, things get tricky; I discuss this more general case in my answer to this post. – Ben Grossmann Jan 11 '22 at 18:08

0 Answers0