Useful General Formulas
This appendix contains general formulas and identities that are useful
for magic and multimagic formulations and proofs.
Most of the formulas are in terms of rational numbers.
This is fitting since if any magic or multimagic square has a solution
in rational numbers, all terms can be multiplied by their common
denominator producing an integer solution.
Sum of Two Squares in Multiple Ways
Difference of Two Squares in Multiple Ways
y^2 - x^2 = A; y ± x = B
A Cube is the Difference of Two Squares
Sum of Two Cubes
Sum of Two Cubes in Two Ways
Sum of Two Squares in Multiple Ways
Given rational numbers A and B, determine all rational number solutions
for x and y such that
x2 + y2 = A2 + B2.
General parametric solution.
Given any rational A, B, and t, where t is not 0, 1, or -1,
x = [-2tB - (1-t2)A] / (1+t2),
y = [-2tA + (1-t2)B] / (1+t2).
A sample use is for the 5x5 structured bimagic square formulations
requiring a solution to numbers representable as the sum of two squares
in four different ways. You can generate all solutions directly.
Pick any A, B, and distinct values for t1, t2, t3, and then
xj = [-2tjB - (1-tj2)A] / (1+tj2),
yj = [-2tjA + (1-tj2)B] / (1+tj2),
for j = 1,2,3, will satisfy
x12 + y12 = x22 + y22 = x32 + y32 = A2 + B2.
Difference of Two Squares in Multiple Ways
Given rational numbers A and B, determine all rational number solutions
for x and y such that
y2 - x2 = B2 - A2.
General parametric solution.
Given any rational A, B, and t, where t is not 0, 1, or -1,
x = [ 2tB - (1+t2)A] / (1-t2),
y = [-2tA + (1+t2)B] / (1-t2).
y2 - x2 = A; y ± x = B
y2 - x2 = A,
y - x = B,
has the solution
x = (A - B2) / (2B),
y = (A + B2) / (2B),
y2 - x2 = A,
y + x = B,
has the solution
x = (B2 - A) / (2B),
y = (B2 + A) / (2B).
A sample use is for the local block 5x5 structured bimagic square formulation.
A Cube is the Difference of Two Squares
x3 = [x(x+1)/2]2 - [x(x-1)/2]2.
Sum of Two Cubes
Identities
x3 + y3 = (x + y)(x2 - xy + y2).
x3 - y3 = (x - y)(x2 + xy + y2).
Given
u3 + v3 = n,
make the rational change of variables
n = m/4,
u = [9m + y]/(6x),
v = [9m - y]/(6x),
or
m = 4n,
x = (12n)/(u+v),
y = (36n)(u-v)/(u+v),
and get the elliptic curve (a Mordell curve)
y2 = x3 - 27m2.
The following is said to be a general solution, but I can't prove it.
x = a2 + 3b2,
y = a3 - 9ab2,
m = a2b - b2.
Sum of Two Cubes in Two Ways
x3 + y3 = u3 + v3
has the trivial solutions
x = y = 0 with u = -v,
x = u with y = v,
and the general rational solution
x = c[1 - (a-3b)(a2+3b2)],
y = c[(a+3b)(a2+3b2) - 1],
u = c[(a+3b) - (a2+3b2)2],
v = c[(a2+3b2)2 - (a-3b)],
where
a, b, and c are any rational numbers with c not 0.