Algebraic verification: from separated quadratic form to coupled bilinear form

x1^2 x2^2 + 9 x2^2 y1^2 + 9 x1^2 y2^2 + 81 y1^2 y2^2 == 81/64

How to transform the above equation into the following equation?

9 (-x2 y1 + x1 y2)^2 + (x1 x2 + 9 y1 y2)^2 == 81/64

Complete the square for the terms involving (-x₂y₁ + x₁y₂), while also completing the square for the remaining terms. The term (-x₂y₁ + x₁y₂) must remain present. How should this be done?

Here’s my attempt, though it’s rather brute-force and not much smarter than manual calculation.

Solve[ForAll[{x1, y1, x2, y2}, 
  Equivalent[
   9 x2^2 y1^2 - 18 x1 x2 y1 y2 + 9 x1^2 y2^2 + (x1 x2 + 9 y1 y2)^2 ==
     81/64, A (-x2 y1 + x1 y2)^2 + (x1 x2 + 9 y1 y2)^2 == 81/
    64]], A, Reals]

——————————————————————————————————————————

In the general case of the above problem: how do we convert this situation?

The general form of an equation is as follows:

(x1^2 x2^2)/a^4 + (x2^2 y1^2)/(a^2 b^2) + (x1^2 y2^2)/(a^2 b^2) + (
  y1^2 y2^2)/b^4 == 1

How to convert it into the following form:

((x1 x2)/a^2 + (y1 y2)/b^2)^2 + (x1 y2 - x2 y1)^2/(a^2 b^2) == 1

This is another way, not very simple either:

poly = x1^2 x2^2 + 9 x2^2 y1^2 + 9 x1^2 y2^2 + 81 y1^2 y2^2
subst = {p == -x2 y1 + x1 y2, q == x1 x2 + 9 y1 y2};
poly /. Solve[subst, {x1, x2}][[1]]
Collect[%, {p, q}]
% /. (subst /. Equal -> Rule)

Yet another way:

eqn = x1^2 x2^2 + 9 x2^2 y1^2 + 9 x1^2 y2^2 + 81 y1^2 y2^2 == 81/64;
vars = Variables[Subtract @@ eqn];
form = A (-x2 y1 + x1 y2)^2;
rem = First[eqn] - form;
asol = First@Solve[First@Discriminant[rem, vars] == 0, A]
Factor[rem /. asol] + (form /. asol) == Last[eqn]
(*
{A -> 9}
9 (-x2 y1 + x1 y2)^2 + (x1 x2 + 9 y1 y2)^2 == 81/64
*)

One wonders, given the special nature of the result, whether is something about the context in which the problem arises that points to a way to solve it.

The area of a triangle with three vertices at coordinates (0,0), (x1,y1), and (x2,y2) is given by Abs[x1y2 - x2y1]/2. Therefore, the purpose and significance of this Mathematica code lie in constructing terms containing (x1y2 - x2y1) to compute the maximum area of the triangle.

The preceding formula is obtained as follows: with two points on the ellipse satisfying {(8x₁²)/9 + 8y₁² = 1, (8x₂²)/9 + 8y₂² = 1}, we consider the problem of maximizing the area of the triangle formed by these two points and the origin. First, substituting the points into the ellipse equations yields {(8x₁²)/9 + 8y₁² = 1, (8x₂²)/9 + 8y₂² = 1}. Then, multiplying these two equations together and simplifying gives the content of this post.

If the equation contains no numbers, only parameters. This is the general case of the problem: how to transform the equality

(x1^2 x2^2)/a^4 + (x2^2 y1^2)/(a^2 b^2) + (x1^2 y2^2)/(a^2 b^2) + (
  y1^2 y2^2)/b^4 == 1

into this form:

((x1 x2)/a^2 + (y1 y2)/b^2)^2 + (x1 y2 - x2 y1)^2/(a^2 b^2) == 1

Now the problem has been updated: given the general form of the equation under normal circumstances, how to convert it into the desired form. The requirements remain the same.

My approach works on this, no?

Thanks! That works. Noticing the difference in parameters.

You’re welcome. I asked about my “wonderment” earlier because I had noticed that the following ways also produce the desired form, either from 2D or from 3D vectors. But I wasn’t sure that we could assume the equation would always have this form.

eqn = (x1^2 x2^2)/a^4 + (x2^2 y1^2)/(a^2 b^2) +
       (x1^2 y2^2)/(a^2 b^2) + (y1^2 y2^2)/b^4 == 1;
    
(*1*)
scale = {a, b};
v = {x1, y1}/scale;
w = {x2, y2}/scale;
Simplify@Det[{v, w}]^2 + (v . w)^2 == 1

(*2*)
scale = {a, b, 1}; (* 3rd component does not matter in this case *)
v = {x1, y1, 0}/scale;
w = {x2, y2, 0}/scale;
Simplify[# . # &@Cross[v, w]] + (v . w)^2 == 1

This implies the solutions may be derived from scaled vectors v, w whose lengths multiply to 1,
since Det[{v, w}]^2 + (v . w)^2 equals Norm[v]^2 Norm[w]^2.

Based on the above, here are two similar ways to derive the desired form from the expanded polynomial:

scale = {a, b};
v = {x1, y1}/scale;
w = {x2, y2}/scale;
reduction = {A == Det[{v, w}], B == v . w};
1 == 1 + First@GroebnerBasis[Join[{eqn}, reduction],
     {x1, y1, x2, y2, A, B}] /.
 First@Solve[reduction, {A, B}]

Eliminate[Join[{eqn}, reduction], {x1, y1, x2, y2}] /.
  First@Solve[reduction, {A, B}] //
 AddSides[#, 1] &

The second way might be better. It seems to return True if eqn does not satisfy the hypothesis (that eqn is of the form to be expressible in terms of A and B). GroebnerBasis[] will return a polynomial that will not be in the right form, if eqn cannot be put in the right form; one should check it before substituting A and B.