Searching for a 3x3 magic square of Squares
- 3 hours ago
- 30 min read
Introduction
The question of whether it is possible to create a 3x3 magic square of squares is an unsolved problem in mathematics. There have been many attempts at finding a solution, resulting in many “near misses” - solutions that meet some of the requirements but not all of them. There is an excellent summary of research and attempts at solutions at http://www.multimagie.com/English/SquaresOfSquaresSearch.htm.
Here, I will present a purely algebraic approach to a 3x3 magic square of squares, and see how far that gets me toward a solution.
Spoiler: This did not lead to a solution, but it did lead to a system of Diophantine equations which, if solved would yield a 3x3 magic square of squares. Proving that the system of equations is impossible to solve would also prove that a 3x3 magic square of squares is impossible.
From here on, I may write “magic square” or “magic square of squares” and assume you know I’m talking about a 3x3 magic square.
The next 5 sections are reviews of some well-known facts about magic squares. Feel free to skip them If you are already familiar with the 3x3 magic square and jump straight to the Magic Square of Squares section or the Magic Triples section below.
Definition of a Magic Square
A 3x3 magic square is an arrangement of nine unique integers, into a square of 3 rows and columns, such that each row, column, and diagonal of three integers adds up to the same total (shown below as T):

Here is the most famous 3x3 magic square. Every line adds up to 15:

The total, T, is three times the center value, E
From the bottom row we have:
G + H + I = T
By diagonal 1, G + E + C = T. Solving for G gives us:
G = T - E - C
By column 2, B + E + H = T. Solving for H gives us:
H = T - E - B
By diagonal 2, A + E + I = T. Solving for I gives us:
I = T - E - A
Replacing G, H, and I values derived above:
T - E - C + T - E - B + T - E - A = T
Consolidating terms:
3T - 3E - (A + B + C) = T
Replacing A + B + C with T:
3T - 3E - T = T
Isolating T:
T = 3E
The total, T, is equal to 3 times the center value. From here on, I will drop T and use 3E as the total.
There is a single arrangement of numbers greater than E
For the magic square to contain 9 unique numbers, every line that passes through E must have one number, L, larger than E and one number, S, smaller than E. L and S must add up to 2E. I will represent numbers larger than E with ‘L’ and numbers smaller than E with ‘S’. In the line AEI, A + I = 2E and either A > E and I < E or A < E and I > E:

Since the second arrangement can be rotated 180 ° to match the first one, I will keep the first arrangement and discard the second as equivalent to the first. There are two ways to assign values to the other corners:

The second arrangement can be rotated 90° counter clockwise to match the first arrangement. Again, I discard the second arrangement as equivalent to the first.
If we have three numbers in a line larger than E, the total must be larger than 3E, so we cannot have three L’s in a row. By the same logic, we cannot have three S’s in a row. This leaves only one possibility for the middle row:

Finally, there are two ways to fill in the two remaining spots:

The second arrangement can be flipped to produce the first arrangement, leaving us with this:

This corresponds to:

Thus, all magic squares can be flipped or rotated to match this arrangement. I will use this arrangement exclusively in all future discussion.
The magic square is definable with 3 values:
Once A, B, and E are selected, all other values can be calculated:
A > E | B > E | C = 3E - A - B |
D = 4E - 2A - B | E | F = 2A + B - 2E |
G = A + B - E | H = 2E - B | I = 2E - A |
In a “side note” at the end of this article, I explore some limitations on A and B, relative to E, and also the relative sizes of all entries in the magic square.
A magic square can be multiplied by a constant:
Multiplying A, B and E by a factor, X, will preserve the magic square properties:
Ax | Bx | Cx = 3Ex - Ax - Bx |
Dx = 4Ex - 2Ax - Bx | Ex | Fx = 2Ax + Bx - 2Ex |
Gx = Ax + Bx - Ex | Hx = 2Ex - Bx | Ix = 2Ex - Ax |
I don’t consider this to be a unique magic square, but rather an equivalent square to the original.
The 3x3 Magic Square of Squares
In a magic square of squares, all of the numbers are perfect squares. I will use upper-case numbers for the perfect squares and lower-case numbers for the roots:
a2 = A | b2 = B | c2 = C |
d2 = D | e2=E | f2=F |
g2 = G | h2 = H | i2 = I |
Magic Triples:
There are four lines in the magic square that pass through the center:
a2 + e2 + i2 = 3e2
b2 + e2 + h2 = 3e2
g2 + e2 + c2 = 3e2
f2 + e2 + d2 = 3e2
Subtracting e2 from both sides gives us:
a2 + i2 = 2e2
b2 + h2 = 2e2
g2 + c2 = 2e2
f2 + d2 = 2e2
Each of these equations requires a “Magic Triple”, which I define as three integers, [l, e, s], where l > e > s, and l2 + s2 = 2e2. The relationships between the numbers are shown in this diagram:

Given:
Eq. 1: l2 + s2 = 2e2
Eq. 2: j = e - s
Eq. 3: k = l - e
It should be obvious that j > k > 0. The difference between l2 and e2 is:
Eq. 4: l2 - e2 = 2ek + k2
The difference between e2 and s2 is:
Eq. 5: e2 - s2 = 2ej - j2
Starting with Eq. 1:
l2 + s2 = 2e2
2e2 - s2 = l2
e2 - s2 = l2 - e2
Substitute Eqs. 4 and 5:
2ej - j2 = 2ek + k2
Eq. 6: 2ej - 2ek = j2 + k2
2e(j - k) = j2 + k2
Eq. 7: e = (j2 + k2) / 2(j - k)
By Eq. 6, j2 + k2 must be even. Therefore, j2 and k2 must both be even or both be odd. This implies that (j - k) must be even, and 2(j - k) must be divisible by 4. Since l, e, s, j, and k are all integers, Eq. 7 implies that (j2 + k2) must be divisible by 4.
If j and k are both odd, then they must each be equal to 1 mod 4 or 3 mod 4.
(1 mod 4)2 = 1 mod 4.
(3 mod 4)2 = 1 mod 4.
If j and k are both odd, then j2 + k2 = 2 mod 4 and is not divisible by 4. Thus, j and k must both be even.
I will break j and k into smaller components by replacing j with 2j and k with 2k, replacing Eqs. 2 and 3 with Eqs. 8 and 9:
Eq. 8: 2j = e - s
Eq. 9: 2k = l - e
Eq. 7 then becomes:
e = (4j2 + 4k2) / 2(2j - 2k)
Eq.10: e = (j2 + k2) / (j - k)
Note that this drops the previous constraint that j and k are either both even or both odd. We can now derive formulas for l, e, and s:
From Eq. 9: l = e + 2k
Inserting Eq. 10 gives us:
l = (j2 + k2) / (j - k) + 2k
l = (j2 + k2) / (j - k) + 2k (j - k) / (j - k)
l = (j2 + 2jk - k2) / (j - k)
From Eq. 8: s = e - 2j
Inserting Eq. 10 gives us:
s = (j2 + k2) / (j - k) - 2j
s= (j2 + k2) / (j - k) - 2j (j - k) / (j - k)
s = (-j2 + 2jk + k2) / (j - k)
This gives us the formula for a Magic Triple:
Eq. 11: l2 + s2 = 2e2
Eq. 12: l = (j2 + 2jk - k2) / (j - k)
Eq. 13: e = (j2 + k2) / (j - k)
Eq. 14: s = (-j2 + 2jk + k2) / (j - k)
Since Eqs. 12 - 14 were derived from eq. 11, all Magic Triples that satisfy eq. 11 must be of the form shown in eqs. 12 - 14.
Constraints on k in relation to j
In order for s to be positive, we need:
s = -j2 + 2jk + k2 > 0
Solving the quadratic, -j2 + 2jk + k2 = 0 for k, gives us:
k = (-1 ± √2)j
j crosses 0 at those two points. The original formula, s = -j2 + 2jk + k2, defines a parabola in k, which means that s is less than zero between k = (-1 - √2)j and k = (-1 + √2)j and greater than zero outside that range. Therefore, we know that s > 0 when k < (-1 - √2)j or k > (-1 + √2)j. Since k must be a positive integer, we discard k < (-1 - √2)j and are left with:
(√2 - 1)j < k < j
Since k must be a positive integer less than j, we can state:
⌈(√2 - 1)j⌉ ≤ k ≤ j - 1
In a side note at the end of this article, I explore further limitations on ja, ka, jb, and kb.
Reversing the Magic Triple Formula
Given l, e, and s, we can derive j and k with:
(l + e) / (s + e)
Substituting Eqs. 12 - 14:
l = (j2 + 2jk - k2) / (j - k)
e = (j2 + k2) / (j - k)
s = (-j2 + 2jk + k2) / (j - k)
((j2 + 2jk - k2) / (j - k) + (j2 + k2) / (j - k)) / ((-j2 + 2jk + k2) / (j - k) + (j2 + k2) / (j - k))
Multiplying numerator and denominator by (j- k)
((j2 + 2jk - k2) + (j2 + k2)) / ((-j2 + 2jk + k2) + (j2 + k2))
(2j2 + 2jk) / (2k2 + 2jk)
(j2 + jk) / (k2 + jk)
j(j + k) / k(j + k)
j / k
Thus
j/k = (l + e) / (s + e)
Note that since the ratio of j to k equals the ratio of (l + e) to (s + e), this doesn’t necessarily produce the original j and k as the numerator and denominator - it may instead produce j and k either multiplied or divided by a factor.
Finding inputs that always work
We still have the requirement that terms in eqs. 12 - 14 must be divisible by (j - k). We have two possible approaches. The easy approach is to multiply all three equations by (j - k). This scales l, e, and s up by the same amount, preserving the Magic Triple properties:
Eq. 15: l = (j2 + 2jk - k2)
Eq. 16: e = (j2 + k2)
Eq. 17: s = (-j2 + 2jk + k2)
We can reduce a number of duplicate cases by requiring that j and k be relatively prime. This still has the potential to produce l, e, and s such that the greatest common factor, GCF(l, e, s), is greater than 1. In this case, we can simply divide l, e, and s by GCF(l, e, s) to reduce the Magic Triple to its most basic form. It is also fine to leave them as is - the worst case this produces is a magic square that can be divided by a constant to produce an equivalent magic square - we do not miss any possible magic squares by reducing or not reducing a Magic Triple.
The other approach is to identify all conditions under which Eqs. 12 - 14 are divisible by (j - k). I show that approach at the end of this article, in a “side note”. It produced an approach more complex than multiplying by (j-k), so for the rest of this article, I use the simpler eqs. 15 - 17.
Assembling a Magic Square
In a magic square of squares, we must have four Magic Triples, [a, e, i], [b, e, h], [g, e, c], and [f, e, d].
Since three numbers, a, b, and e, can define a magic square, I will select ja and ka to define a Magic Triple [la, ea, sa], and then select jb and kb to define Magic Triple [lb, eb, sb]:
la = ja2 + 2jaka - ka2
ea = ja2 + ka2
sa = -ja2 + 2jaka + ka2
and
lb = jb2 + 2jbkb - kb2
eb = jb2 + kb2
sb = -jb2 + 2jbkb + kb2
This produces two different values for e. We can multiply la, ea, and sa by eb, and multiply lb, eb, and sb by ea to get 5 values compatible with a magic square of squares:
a = laeb | b = lbea |
|
| e = eaeb |
|
| h = sbea | i = saeb |
With a, b, and e set, all other values in the magic square are fixed. It may be possible to reduce this arrangement by dividing by GCF(laeb, lbea, eaeb, sbea, saeb), but again this produces an equivalent magic square, and not a magic square uniquely different from our original values.
Must all solutions to a magic square fit this approach? We know that [a, e, i] and [b, e, h] must be Magic Triples. Therefore, either ea = eb, or one or both of the Magic Triples must be multiplied by a factor so that the final values for ea and eb are equal. Therefore, all magic square solutions to a, b, e, h, and I can be produced by this approach.
Solving for G, C, F, and D, given A, B, E, H, and I
We will start with the defined values for A, B, E, H, and I
A = la2 * eb2 | B = lb2 * ea2 | C = 3E - A - B |
D = 4E - 2A - B | E = ea2 * eb2 | F = 2A + B - 2E |
G = A + B - E | H = sb2 * ea2 | I = sa2 * eb2 |
We must find a Magic Triple, [lg, eg, sg] to define G’ and C’. We assume we will have to multiply A, B, E, H, and I by eg, giving us A’, B’, E’, H’, and I’:
A’ = A * eg2 = la2 * eb2 * eg2 | B’ = B * eg2 = lb2 * ea2 * eg2 | C’ = sg2 * ea2 * eb2 |
| E’ = E * eg2 = ea2 * eb2 * eg2 |
|
G’ = lg2 * ea2 * eb2 | H’ = H * eg2 = sb2 * ea2 * eg2 | I’ = I * eg2 = sa2 * eb2 * eg2 |
We have the requirement that:
G’ = A’ + B’ - E’
A’ = la2eb2eg2
B’ = lb2ea2eg2
E’ = ea2eb2eg2
G’ = g’2 = lg2ea2eb2
lg2ea2eb2 = la2eb2eg2 + lb2ea2eg2 - ea2eb2eg2
lg2ea2eb2 = eg2 * (la2eb2 + lb2ea2 - ea2eb2)
lgeaeb = eg * √(la2eb2 + lb2ea2 - ea2eb2)
lgeaeb = eg * √(la2eb2 + lb2ea2 - ea2eb2)
g’ = eg * √(A + B - E)
g’ = eg * √G
This shows us that G, as determined by Magic Triples [la, ea, sa] and [lb, eb, sb], must be a perfect square. Attempting to find a Magic Triple for G’, E’, and C’ will not work if G is not already a perfect square.
We cannot multiply A, B, and E by a constant to attempt to make G a perfect square. If G is not a perfect square, then in order to make it a perfect square we must multiply it by another factor, x, which is also not a perfect square. But multiplying A, B, and E by x means that they are no longer perfect squares.
We find the same is true for C, F, and D:
C’ = 3E’ - A’ - B’
A’ = la2eb2eg2
B’ = lb2ea2eg2
E’ = ea2eb2eg2
C’ = c’2 = sg2ea2eb2
sg2ea2eb2 = 3ea2eb2eg2 - la2eb2eg2 - lb2ea2eg2
sg2ea2eb2 = eg2 * (3ea2eb2 - la2eb2 - lb2ea2)
sgeaeb = eg * √(3ea2eb2 - la2eb2 - lb2ea2)
c’ = eg * √(3E - A -B)
c’ = eg * √C
F’ = 2A’ + B’ - 2E’
A’ = la2eb2ef2
B’ = lb2ea2ef2
E’ = ea2eb2ef2
F’ = f’2 = lf2ea2eb2
lf2ea2eb2 = 2la2eb2ef2 + lb2ea2ef2 - 2ea2eb2ef2
lf2ea2eb2 = ef2 * (2la2eb2 + lb2ea2 - 2ea2eb2)
lfeaeb = ef * √(2a2eb2 + b2ea2 - 2ea2eb2)
f’ = ef * √(2A + B - 2E)
f’ = ef * √F
D’ = 4E’ - 2A’ - B’
A’ = la2eb2ef2
B’ = lb2ea2ef2
E’ = ea2eb2ef2
D’ = d’2 = sf2ea2eb2
sf2ea2eb2 = 4ea2eb2ef2 - 2la2eb2ef2 - lb2ea2ef2
sf2ea2eb2 = ef2 * (4ea2eb2 - 2la2eb2 - lb2ea2)
sfeaeb = ef2 * √(4ea2eb2 - 2la2eb2 - lb2ea2)
f’ = ef2 * √(4E - 2A - B)
f’ = ef2 * √D
Thus, our Magic Triples for A and B, [la, ea, sa] and [lb, eb, sb] must yield perfect squares for G, C, F, and D.
Our search for more Magic Triples ends here and we must focus on finding values for ja, ka, jb, and kb that produce a complete magic square of squares.
The Diophantine Equations that a Magic Square of Squares Hinges Upon:
Since ja, ka, jb, and kb must naturally produce solutions for g and c, we have:
G = A + B - E
g2 = a2eb2 + b2ea2 - ea2eb2
G = (jg2 + 2jgkg - kg2)2 = (ja2 + 2jaka - ka2)2(jb2 + kb2)2 + (jb2 + 2jbkb - kb2)2(ja2 + ka2)2 - (ja2 + ka2)2(jb2 + kb2)2
eg2 = E
E = (jg2 + kg2)2 = (ja2 + ka2)2(jb2 + kb2)2
C = 3E - A + B
c2 = 3ea2eb2 - a2eb2 - b2ea2
C = (-jg2 + 2jgkg + kg2)2 = 3(ja2 + ka2)2(jb2 + kb2)2 - (ja2 + 2jaka - ka2)2(jb2 + kb2)2 - (jb2 + 2jbkb - kb2)2(ja2 + ka2)2
To attempt to make these a little more readable, we will replace jg, jg, ja, ja, jb, and jb, with s, t, w, x, y, and z. This gives us a system of three Diophantine equations:
Eq. 18: G = (s2 + 2st - t2)2 = (w2 + 2wx - x2)2(y2 + z2)2 + (y2 + 2yz - z2)2(w2 + x2)2 - (w2 + x2)2(y2 + z2)2
Eq. 19: E = (s2 + t2)2 = (w2 + x2)2(y2 + z2)2
Eq. 20: C = (-s2 + 2st + t2)2 = 3(w2 + x2)2(y2 + z2)2 - (w2 + 2wx - x2)2(y2 + z2)2 - (y2 + 2yz - z2)2(y2 + z2)2
If we find solutions for the equations for eqs. 18 and 19, we will automatically have a solution for eq. 20. If we find solutions for eqs 19 and 20, we will automatically have a solution for eq. 18. If we find solutions for eqs. 18 and 20, we will automatically have a solution for eq 19.
Applying the same approach to D, E, and F gives us:
Eq. 21: F = (u2 + 2uv - v2)2 = 2(w2 + 2wx - x2)2(y2 + z2)2 + (y2 + 2yz - z2)2(w2 + x2)2 - 2(w2 + x2)2(y2 + zx2)2
Eq. 22: E = (u2 + v2)2 = (w2 + x2)2(y2 + z2)2
Eq. 23: D = (-u2 + 2uv + v2)2 = 4(w2 + x2)2(y2 + z2)2 - 2(w2 + 2wx -x2)2(y2 + z2)2 - (y2 + 2yz - z2)2(w2 + x2)2
To prove that a magic square of squares is possible, we need to find solutions for two equations out of eqs. 18 - 20, and solutions for two equations out of eqs. 21 - 23, where the solutions use the same values for w, x, y, and z.
To prove that a magic square of squares is impossible, we need to prove that there is no simultaneous solution to any two equations out of eqs. 18 - 20 or any two equations out of eqs. 21 - 23.
No Solution Yet
I wrote a small program to search possibles values of ja, ka, jb, and kb for solutions. That program is available at https://github.com/telemath/MagicSquare3/tree/master.
As of the time of this writing, it tested over 100 billion values for ja, ka, jb, and kb and not found any solutions to the equations above. There are thousands of values that produce squares for a single value out of C, D, F, or G, but so far none produce a square for more than one of those missing values.
Here are a few samples of those seeds values (ja, ka, jb, and kb) and their resulting magic square entries. The full list of "near misses" can be found at https://github.com/telemath/MagicSquare3/tree/master/Results, in the spreadsheet"Results Summary.xlxs". It's my hope that maybe these near misses will reveal a pattern that helps unlock the Diophantine equations or shows why no full solution is possible.
Magic Square of Squares Produced by | ja = 8, ka = 7, jb = 7, kb= 6 | |
A = 116,532,025 | B = 120,143,521 |
|
D = 15,816,529 | E = 92,256,025 |
|
| H = 64,368,529 | I = 67,980,025 |
Magic Square of Squares Produced by | ja = 763, ka = 683, jb = 50, kb= 33 | |
A = 17,271,001,800,150,028,324 | B = 24,405,851,091,350,154,244 | C = 817,959,875,538,240,964 |
| E = 14,164,937,589,012,807,844 |
|
| H = 3,924,024,086,675,461,444 | I = 11,058,873,377,875,587,364 |
Magic Square of Squares Produced by | ja = 1628, ka = 1577, jb = 1531, kb= 995 | |
A = 312,017,411,918,384,402,943,810,244 | B = 511,094,225,397,581,896,212,411,844 |
|
| E = 293,359,121,922,739,758,970,465,924 |
|
G = 529,752,515,393,226,540,185,756,164 | H = 75,624,018,447,897,621,728,520,004 | I = 274,700,831,927,095,114,997,121,604 |
I do not believe that this system of Diophantine equations is solvable - meaning I don’t believe a 3x3 magic square of squares is possible, but I haven’t been able to prove that yet.
Side Notes
Side note: Limits on A and B
Given the above formulas, and the pattern where A and B > E, and assuming we only want positive numbers in our magic square, we have these limits on A and B:

The gray area shows the valid values for A and B. These limits can be reduced to:
Eq. 8: E < A < 1.5 E
Eq. 9: E < B < 4 E - 2 A
Thus, all 3x3 magic squares (with positive values only) can be defined by A, B, and E, such that:
E < A < 1.5E | E < B < 4E - 2A |
|
| E |
|
|
|
|
Side note: Ranking the numbers by size
Since G = A + B - E, G is greater than A and B
Since F = 2A + B - 2E, F is greater than G, making F the largest number in the magic square.
Since D + F = 2E, D must be the smallest number in the magic square. C must be the second smallest.
This gives us this ranking of numbers in the magic square:
2E > F > G > A, B > E > H, I, > C > D > 0
Side note: When is the Magic Triple Divisible by (j - k)?
To be thorough, I also investigated the conditions under which the Magic Triple equations are divisible by (j - k). I replaced the difference between j and k with d: d = j - k, giving me:
Eq. 12: l = (j2 + 2jk - k2) / (j - k)
Replace j - k with d, replace k with j - d
l = (j2 + 2j(j-d) - (j-d)2) / d
l = 2j2 / d - d
Eq. 13: e = (j2 + k2) / (j - k)
Replace j - k with d, replace k with j - d
e = (j2 + (j - d)2) / d
e = 2j2 / d - 2j + d
Eq. 14: s = (-j2 + 2jk + k2) / (j - k)
Replace j - k with d, replace k with j - d
s = (-j2 + 2j(j-d) + (j-d)2) / d
s = 2j2 / d - 4j + d
This gives us the Magic Triple in terms of j and d:
Eq. 24: l = 2j2 / d - d
Eq. 25: e = 2j2 / d - 2j + d
Eq. 26: s = 2j2 / d - 4j + d
In all three equations, we have a whole number if and only if d | 2j2. In order for d | 2j2 to be true, we must have one of the following cases:
· Case 1: d is 1, giving us 1 | 2j2.
· Case 2: d is 2, giving us 2 | 2j2.
· Case 3: d is a factor of j, e.g. j becomes dj, giving us d | 2d2j2.
· Case 4: d is 2 times a factor of j, e.g. d becomes 2d and j becomes dj, giving us 2d | 2d2j2.
· Case 5: d is the square of a factor of j, e.g. d becomes d2 and j becomes dj, giving us d2 | 2d2j2.
· Case 6: d is 2 times the square of a factor of j, e.g. d becomes 2d2 and j becomes dj, giving us 2d2 | 2f2d2.
We will examine these cases individually:
Case 1: d = 1
Eq. 24: l = 2j2 / d - d Replace d with 1 l = 2j2 - 1
Eq. 25: e = 2j2 / d - 2j + d Replace d with 1 e = 2j2 - 2j + 1
Eq. 26: s = 2j2 / d - 4j + d Replace d with 1 s = 2j2 - 4j + 1
This produces a unique solutions. | Case 2: d = 2
Eq. 24: l = 2j2 / d - d Replace d with 2 l = 2j2 / 2 - 2 l = j2 - 2
Eq. 25: e = 2j2 / d - 2j + d Replace d with 2 e = 2j2 / 2 - 2j + 2 e = j2 - 2j + 2
Eq. 26: s = 2j2 / d - 4j + d Replace d with 2 s = 2j2 / 2 - 4j + 2 s = j2 - 4j + 2
If j is even, this can be reduced to Case 1 by dividing all equations by 2. If j is odd, this produces a valid solution.
|
Case 3: replace j with dj:
Eq. 24: l = 2j2 / d - d Replace j with dj l = 2d2j2 / d - d l = d(2j2 - 1)
Eq. 25: e = 2j2 / d - 2j + d Replace j with dj e = 2d2j2 / d - 2dj + d e = d(2j2 - 2j + 1)
Eq. 26: s = 2j2 / d - 4j + d Replace j with dj s = 2d2j2 / d - 4dj + d s = d(2j2 - 4j + 1)
After dividing all equations by d, this reduces to Case 1. | Case 4: replace d with 2d, j = dj:
Eq. 24: l = 2j2 / d - d Replace d with 2d and j with dj l = 2d2j2 / 2d - 2d l = d(j2 - 2)
Eq. 25: e = 2j2 / d - 2j + d Replace d with 2d and j with dj e = 2d2j2 / 2d - 2dj + 2d e = d(j2 - 2j + 2)
Eq. 26: s = 2j2 / d - 4j + d Replace d with 2d and j with dj s = 2d2j2 / 2d - 4dj + 2d s = d(j2- 4j + 2)
After dividing all equations by d, this reduces to Case 2. |
Case 5: replace d with d2, replace j with dj:
Eq. 24: l = 2j2 / d - d Replace d with d2 and j with dj l = 2d2j2 / d2 - d2 l = 2j2 - d2
Eq. 25: e = 2j2 / d - 2j + d Replace d with d2 and j with dj e = 2d2j2 / d2 - 2dj + d2 e = 2j2 - 2dj + d2
Eq. 26: s = 2j2 / d - 4j + d Replace d with d2 and j with dj s = 2d2j2 / d2 - 4dj + d2 s = 2j2 - 4dj + d2
This produces unique solutions, as long as d and j are relatively prime. | Case 6: replace d with 2d2, replace j with dj:
Eq. 24: l = 2j2 / d - d Replace d with 2d2 and j with dj l = 2d2j2 / 2d2 - 2d2 l = j2 - 2d2
Eq. 25: e = 2j2 / d - 2j + d Replace d with 2d2 and j with dj e = 2d2j2 / 2d2 - 2dj + 2d2 e = j2 - 2dj + 2d2
Eq. 26: s = 2j2 / d - 4j + d Replace d with 2d2 and j with dj s = 2d2j2 / 2d2 - 4dj + 2d2 s = j2 - 4dj + 2d2
If j is even, this can be reduced to Case 5 by dividing all equations by 2. If j is odd and d and j are relatively prime, this produces a valid solution.
|
This gives us the following formulas for producing unique Magic Triples:
Case 1:
l = 2j2 - 1
e = 2j2 - 2j + 1
s = 2j2 - 4j + 1
Case 2 (from Case 2, above, but replacing j with 2j + 1 to ensure an odd input):
l = 4j2 + 4j - 1
e = 4j2 + 1
s = 4j2 - 4j - 1
Case 5, where j and d are relatively prime:
l = 2j2 - d2
e = 2j2 - 2dj + d2
s = 2j2 - 4dj + d2
Case 6 (from Case 6, above, but replacing j with 2j + 1 to ensure an odd input):
l = 4j2 + 4j - 2d2 + 1
e = 4j2 + 4j - 4dj + 2d2 - 2d + 1
s = 4j2 + 4j - 8dj + 2d2 - 4d + 1
Since some of these equations have two inputs, they are not really simplifying the work that eqs. 20 - 22 do. It is simpler to use equations 15 - 17, and divide by GCF(l, e, s) if needed.
Side note: Constraints on ka in relation to Ja
We previously saw that A must be in the range:
E < A < (3/2)E.
Converting A and E, the perfect squares, to their roots, a and e:
E < A < (3/2)E
A = a2
E = e2
e2 < a2 < (3/2)e2/2
e < a < √(3/2)e
Our constraint on k is:
⌈(√2 - 1)ja⌉ ≤ ka ≤ ja - 1
In terms of the ratio of k to j, we have:
(√2 - 1) ≤ ka/ja ≤ 1
As the ratio of ka/ja varies from (√2 - 1) to 1, a/e varies from √2 to 1:

The point at which a/e = √(3/2) is at:
(1 + 2(ka/ja) - (ka/ja)2) / (1 + (ka/ja)2) = √(3/2)
For simplicity, let us temporarily replace (ka/ja) with k.
(1 + 2k - k2) / (1 + k2) = √(3/2)
1 + 2k - k2 = √(3/2) (1 + k2)
1 + 2k - k2 = √(3/2) + √(3/2) k2
(√(3/2) + 1) k2 - 2k + (√(3/2) - 1) = 0
k = (2 ± √(4 - 4*(√(3/2) + 1)( √(3/2) - 1))) / (2(√(3/2) + 1))
k = (2 ± √(4 - 4*(3/2 - 1))) / (√6 + 2)
k = (2 ± √(4 - 6 + 4)) / (2 + √6)
k = (2 ± √2) / (2 + √6)
ka/ja = (2 ± √2) / (2 + √6)
Checking the midpoint between those solutions, where (ka/ja) = 2 / (2 + √6):
(ja2 + 2jaka - k2) / (ja2 + ka2)
Let ja = 1 and ka = 2 / (2 + √6)
(1 + 2ka - k2) / (1 + ka2)
(1 + 2(2 / (2 + √6)) - (2 / (2 + √6))2) / (1 + (2 / (2 + √6))2)
(1+14√6)/25
This is greater than √(3/2), so we know that:
(2 - √2) / (2 + √6) < ka/ja < (2 + √2) / (2 + √6) produces (a/e)2 > 3/2.
Thus, we must have ka/ja < (2 - √2) / (2 + √6) or ka/ja > (2 - √2) / (2 + √6).
We still have the constraint that (√2 - 1) ≤ ka/ja ≤ 1. Since (2 - √2) / (2 + √6) < √2 - 1 < (2 + √2) / (2 + √6) < 1, our combined constraint for a is:
⌈ja * (2 + √2) / (2 + √6) ⌉ ≤ ka ≤ ja - 1
Side note: Constraints on kb, in relation to jb, given ja and ka
In the magic square, D = 4E - 2A - B. This gives us the constraint that 4E > 2A + B. We will rephrase it as:
2A + B < 4E
B < 4E - 2A
B/E < 4 - 2A/E
B/E < 4 - 2A/E
b2/e2 < 4 - 2a2/e2
b/e < √(4 - 2a2/e2)
Let m = √(4 - 2a2/e2)
Note that for the minimum value of a/e, 1, m = √2.
For the maximum value of a/e, √(3/2), m = 1.
So, m ranges from 1 to √2.
b/e < k
b/e = (jb2 + 2jbkb - kb2) / (jb2 + kb2)
b/e = (1 + 2kb/jb - kb2/jb2) / (1 + kb2/jb2)
(1 + 2kb/jb - kb2/jb2) / (1 + kb2/jb2) < k
Solving for kb/jb:
For simplicity in writing, temporarily substitute k = kb/jb
(1 + 2k - k2) / (1 + k2) < m
1 + 2k - k2 < m (1 + k2)
-k2 + 2k + 1 < m + mk2
-(m + 1) k2 + 2k + (1 - m) < 0
Solving the quadratic:
k = (-2 ± √(4 + 4(1+m)(1-m))) / -2(m + 1)
k = (-2 ± √(4 + 4(1 - m2))) / -2(m + 1)
k = (2 ± 2√(1 + 1 - m2)) / 2(m + 1)
k = (2 ± 2√(1 + 1 - m2)) / 2(m + 1)
k = (2 ± 2√(2 - m2)) / 2(m + 1)
k = (1 ± √(2 - m2)) / (m + 1)
We see that the inequality holds for:
k < (1 - √(2 - m2)) / (1 + m) and x > (1 + √(2 - m2)) / (1 + m)
For the range of possible values for m, (1 - √(2 - m2)) / (1 + m) produces values in the range k = 0 to k = √2 - 1. Since k represents kb/jb, this range is excluded by our previous constraint that k > √2 - 1. This leaves us:
k > (1 + √(2 - m2)) / (1 + m)
Thus, given ka and ja that meet their constraints, we have these constraints on kb and jb:
a = (ja2 + 2jaka - ka2)
ea = (ja2 + ka2)
m = √(4 - 2a2/ea2)
⌈jb * (1 + √(2 - m2)) / (1 + m)⌉ ≤ kb ≤ jb - 1



Comments