Skip to content

Instantly share code, notes, and snippets.

@hcschuetz
Last active June 29, 2026 11:48
Show Gist options
  • Select an option

  • Save hcschuetz/468e943446591bfd0bade29942e1be4a to your computer and use it in GitHub Desktop.

Select an option

Save hcschuetz/468e943446591bfd0bade29942e1be4a to your computer and use it in GitHub Desktop.

Two Equations with Two Variables

a^2 - b = 133                   (1)
b^2 - a = 133                   (2)

The original problem, about which there are several Youtube videos, has the additional condition a ≠ b. But I did not see this in the banner pictures. So I found more solutions.

The "Standard" Solution

All the Youtube solutions I watched subtracted the two equations (1) and (2) and transformed the result (more or less) like this:

a^2 - b - b^2 + a = 0
a^2 - b^2 = - (a - b)
(a + b) (a - b) = - (a - b) 

Divide both sides by a - b, which is possible since a ≠ b, and isolate b:

a + b = -1
b = -1 - a

Use this to eliminate b in equation (1):

a^2 - (-1 - a) = 133
a^2 + a - 132 = 0

From this quadratic equation two solutions for a (and then also for b) can be computed easily. (See below.)

My Solution

The core trick above was to rewrite a^2 - b^2 as (a + b)(a - b), and to cancel the factor a - b with another occurrence of that expression that happens to appear "magically". I did not see this possibility and therefore used a different approach.

Isolate b in equation (1) and substitute the expression for b in equation (2). Then transform this into a quartic equation with the single variable a:

b = a^2 - 133
(a^2 - 133)^2 - a = 133
a^4 - 266 a^2 + 17689 - a - 133 = 0
a^4 - 266 a^2 - a + 17556 = 0

Let's call the LHS polynomial P4.

There is a formula/algorithm for solving quartic equations, but I don't know it.

Due to the symmetry of the problem we can hope for solutions with a = b. This assumption simplifies both of the original equations (1) and (2) to

a^2 - a - 133 = 0

where we call the LHS polynomial P2.

The equation has solutions a = (1 ± sqrt(533))/2. In each case b is the same as a.

But we expect two more solutions for the quartic equation (actually the ones with a ≠ b). For this we could divide P4 by (a - (1 + sqrt(533))/2) and then by (a - (1 - sqrt(533))/2), which results in a polynomial of degree 2. But it is easier to directly divide P4 by P2 (which is just the product of these two divisors).

(a^4       - 266 a^2 -     a + 17556) / (a^2 - a - 133) = a^2 + a - 132
 a^4 - a^3 - 133 a^2
 -------------------------------
       a^3 - 133 a^2 -     a + 17556
       a^3 -     a^2 - 133 a
       -------------------------
           - 132 a^2 + 132 a + 17556
           - 132 a^2 + 132 a + 17556
           -------------------------
                                   0

As expected, the division leaves no rest and the quotient polynomial has degree 2. Setting that polynomial to zero yields the quadratic equation that was also derived in the "standard" solution above:

a^2 + a - 132 = 0

With the quadratic formula we get the two solutions

a = 11 and a = -12

For symmetry reasons in each case b must be the other one of these solutions. (This is also straight-forward to compute if you do not believe the symmetry argument.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment