**5x5 bimagic search technique**

A B C D E

F
G H I J

K L M N P

Q
R S T U

V W X Y Z

for MaxNo = 12 to 1000 [and hopefully greater]

for PartialSum
= (MaxNo + 66)/3 to 2(MaxNo + 1) [see Note 1]

List all 4-entry series adding to PartialSum using 1 to MaxNo.

Sort the
series by their sum of squares.

for each group of three disjoint series

with the same
sum and sum of squares

that contain both 1 and MaxNo [see
Note 2]

assign them to A,G,T,Z and
E,I,R,V and C,H,S,X such that

E + I + R + V = A + G + T + Z = C
+ H + S + X

E² + I² + R² + V² = A² + G² + T²
+ Z² = C² + H² + S² + X²

for each permutation of the 12 entries that satisfies the above,

Avoid permutations that can be reached by a rotation, reflection,
etc.

Delay permutations until they are needed. [see
Note 3]

3 choices for C,H,S,X line

3 choices
for (A,Z),(G,T) combo AGTZ AGZT AZTG

6
choices for (E,V),(I,R) combo

6 choices for (C,X),(H,S)
combo

Solve for L and N using Formula 1.

L
+ N = A + Z + E + V + C + X - G - T - I - R

L² + N² = A²
+ Z² + E² + V² + C² + X² - G² - T² - I² - R² Reject if not rational.

Solve for K and P using Formula 1.

K + P = A + Z + G
+ T - L - N

K² + P² = A² + Z² + G² + T² - L² - N² Reject
if not rational.

for each permutation involving swapping

E,V; I,R;
K,P; H,S [16 permutations]

Solve for J and Q using Formula 2.

J
- Q = A + K + V - G - H - I

J² - Q² = A² + K² + V² - G²
- H² - I² Reject if not integer.

Solve for U and M using Formula 2.

U - M = A + G + Z - Q - R - S

U²
- M² = A² + G² + Z² - Q² - R² - S² Reject if not integer.

Compute F = G + M + T + Z - K - V - Q

Verify F² = G² + M² + T² + Z² -
K² - V² - Q² Reject if not equal.

for each permutation involving swapping

L,N; C,X
[4 permutations]

Solve for W and D using Formula 2.

W - D = A + C + E
- G - L - R

W² - D² = A² + C² + E² - G² - L² - R² Reject
if not integer.

Compute Y = A + G + Z + M - D - I - N

Verify Y² = A² + G² + Z² + M² -
D² - I² - N² Reject if not equal.

Compute B = G + T + Z + M - C - D - E

Verify B² = G² + T² + Z² + M² -
C² - D² - E² Reject if not equal.

Output solution.

Given a and b, find x and y such that

x + y = a

x²
+ y² = b

x = (a + c)/2

y = (a - c)/2

where
c² = 2b - a²

Reject if c is not rational.

Note that if a and b are integer and c is
rational, then x and y will be integers.

Note also that the values of x and
y can be swapped.

**Formula 2**

Given a and b, find x and y such that

x - y = a

x²
- y² = b

This always has the rational solution

x = (b/a + a)/2

y
= (b/a - a)/2

but may not be integer.

The highest PartialSum value is 2(MaxNo + 1).

If a bimagic square existed
with a higher partial sum, you could subtract all of its entries from (MaxNo
+ 1) and get another bimagic square with a partial sum smaller than 2(MaxNo
+ 1) for the initial three series, which would have been found by an earlier
search.

**Note 2.**

1 and MaxNo are required to be in the initial 12 entries.

If they weren't
and a bimagic square was found, you could translate this solution to a range
using a smaller value of MaxNo, which would have been found by an earlier search.

**Note 3.**

The computation of L,N and K,P results in the same values if E and V are swapped, for example. If these extra swaps are done and the computation of L,N or K,P is rejected, you would be rejecting the same thing multiple times.

Return to the home page http://www.multimagie.com