If we multiply each entry with any square, then the squares turn
into squares and we obtain a scaled version of the magic square.
The only way to obtain a triangular number, having the form
t(t+1)/2, is to multiply one of the two remaining nonsquares, say s,
with a square, say y^2. This means that we have to solve the
equation
sy^2=t(t+1)/2
Multiply with 8 and reorganize
8sy^2=4t^2+4t
Which we may rewrite as
(2t+1)^2-8sy^2=1
This is a Pell’s equation which is known to have an infinite number
of solutions, if 8s is not a square, or which is the same condition
2s is not a square. One may find the smallest solution (2t+1,y) with
both 2t+1,y larger than 0 by using the convergent h/k of the regular
continued fraction of sqrt(8s) for which h^2-8k^2=1; h is always
odd, so we may retrieve t.
For s=222121 we’ll find (h,k)=(22632419659503,16978181966), as
given, belonging to a convergent having index 19. And find
t=(h-1)/2.
For s=360721 we’re not so lucky, the convergent has index 45 (which
also explains the rather large values of (h,k).
This smallest positive solution (h,k) is called the fundamental
solution to the Pell’s equation, lets call this (h[1],k[1]). All
other solutions where (h[n],k[n]) are positive can be found by
h[n]+k[n]*sqrt(8s)=(h[1]+k[1]*sqrt(8s))^n[/math]
where we consider numbers in the ring of integers Z[sqrt(8s)] in
which numbers have the form a+b*sqrt(8s) where a,b are integer.
As a recurrence equation it states
h[n]+k[n]*sqrt(8s)=(h[n-1]+k[n-1]*sqrt(8s))(h[1]+k[1]*sqrt(8s))
And if we expand we find
h[n]=h[n-1]h[0]+8s k[n-1]k[0]
k[n]=h[n-1]k[0]+k[n-1]h[0]
from which we obtain all solutions, given a fixed value of s such
that 2s is not a square. This answers Q1 and the answer to Q2 is
thus no.
If we are to find a solution (h,k) for two distinct values s, say
s[a],s[b], then this has to be a solution to the system of equations
h^2-8s[a]k^2=1, h^2-8s[b]k^2=1
Subtract both equations and we find that
8(s[b]-s[a])k^2=0
This equation only has solution k=0, since s[a] and s[b] are
distinct. The answer to Q3 is thus no.
Extra information.
This ring Z[\sqrt(n)], where n is not a square, is equipped with a
norm N(a+bsqrt(n))=(a+b sqrt(n))(a-b sqrt(n))=a^2-nb^2. The numbers
a+b sqrt(n) such that this norm equals 1 are called units. Those are
the numbers we are interested in!
On Continued
fraction - Wikipedia you may find an example where a
simple/regular continued fraction is found for a real number. We may
proceed likewise for a real number of the form sqrt(8s), the
exception being, that in our case the continued fraction will not
terminate but is periodic. Check that sqrt(7)=[2;1,1,1,4,…] where
the last 4 numbers repeat (this is called the repetend).
There is also a section that explains how you may compute the
convergents h/k, given this representation [2;1,1,1,4,…]. These
convergents have a special property, these are the fractions that
are the best approximations to a real number x, meaning that if h/k
is an approximation then | x – a/b| > | x-h/k| for all b<k. (Given
the denominator k, we can’t do better).
We know that we can’t find a positive solution to a^2-nb^2=0, since
n is supposed to be a nonsquare. Apparently we can find a solution
h^2-nk^2=1. The fraction h/k must thus be very close to a solution
of a^2-nb^2=0, that is h/k is an approximation to sqrt(n).