003: Sum / Sums of two squares

Previous Page        Next Page
2. Form: x2+ny2 = zk


This is just a generalization of the form x2+y2 = zk.




x2+ny2 = (p2+nq2)k


Same technique of equating factors over Ö-n,


{x+yÖ-n, x-yÖ-n} = {(p+qÖ-n)k, (p-qÖ-n)k}


and then solve for x,y.  Example, for k=2,


(p2-nq2)2 + n(2pq)2 = (p2+nq2)2


which for n=1 gives the familiar and complete parametrization (after scaling) for Pythagorean triples.  For k = 3, we get,


(p3-3npq2)2 + n(3p2q-nq3)2 = (p2+nq2)3


However, for k > 2 this method does not generally give all solns (Pepin).  For example, for the particular case k = 3 and n = 47, a class of solns not given by the above is,


(13u3+60u2v-168uv2-144v3)2 + 47(u3-12u2v-24uv2+16v3)2 = 23(3u2+2uv+16v2)3


by Pepin.  This is also discussed in Quadratic Polynomials as a kth Power.



2b. Form: ax2+by2 = cz2


To solve this form for an infinite number of solns, all it takes is one initial point {x,y,z}.  Either of two methods can be used, each with their own strengths.


Method 1:   Use the identity,


ax2+bxy+cy2+dz2 = (am2+bmn+cn2+dp2)(u2+cdv2)2


where {x,y,z} = {mu2+cdmv2,  nu2-2pduv-d(bm+cn)v2,  pu2+(bm+2cn)uv-cdpv2}


For example, given m2+2n2 = 2p2 we have {a,b,c,d} = {1, 0, 2, -2}, and initial soln {m,n,p} = {4, 1, 3}.  Using these, we get the parametrization,


x2+2y2 = 2z2


where {x,y,z} = {4(u2-4v2),  u2+12uv+4v2,  3u2+4uv+12v2}.  Similarly for,


x2+y2 = 2z2


where {x,y,z} = {u2-2v2,  u2+4uv+2v2,  u2+2uv+2v2}, and so on.


Method 2:   Use instead,


ax12+bx22+cx32 = (ay12+by22+cy32)(az12+bz22+cz32)2


where {x1, x2, x3} = {uy1-vz1,  uy2-vz2,  uy3-vz3} with {u,v} = {az12+bz22+cz32, 2(ay1z1+by2z2+cy3z3)}


with initial soln {y1, y2, y3} and arbitrary {z1, z2, z3}, thus giving a three-variable parametrization.  Given the same ex, y12+2y22 = 2y32, we have {a,b,c} = {1, 2, -2} and small soln {y1, y2, y3} = {4, 1, 3}.  Substituting these in the formula for the xi, and letting {z1, z2, z3} = {x,y,z} for convenience, we get the alternative identity,


x12+2x22 = 2x32


where {x1, x2, x3} = {4(x+2y-2z)(x-y-z),  x2-8xy-2y2+12yz-2z2,  3x2+6y2-8xz-4yz+6z2}.


The advantage of the first method is that it yields simple forms and can be used on eqns with cross terms (i.e. where b is non-zero).  However, the second method is useful in that it can be generalized into n diagonal forms


Theorem:  "In general, given one solution to a1y12+a2y22+…+ anyn2 = 0, then an infinite more can be found."


Proof:  We simply generalize the soln given in Method 2.  For four addends,


ax12+bx22+cx32+dx42 = (ay12+by22+cy32+dy42)(az12+bz22+cz32+dz42)2


where {x1, x2, x3, x4} = {uy1-vz1,  uy2-vz2,  uy3-vz3, uy4-vz4} with {u,v} = {az12+bz22+cz32+dz42, 2(ay1z1+by2z2+cy3z3+dy4z4)}


with initial {y1, y2, y3, y4} for arbitrary {z1, z2, z3, z4}, thus now giving a four-variable parametrization.  And so on for any n addends as the pattern for the xi and {u,v} are easily seen.  (These methods are also discussed in Section 006.)



3. Form: ad-bc = ±1


This is inserted here because it is important to the next two forms, x2+y2 = z2±1.  One can solve ad-bc = ±1 in the integers using the transformation,


{a,b,c} = {q2, p+q, p-q}


such that it becomes the Pell equation,


p2-(d+1)q2 = ±1


Alternatively, let {a,b,c,d} = {p+s, -q+r, q+r, p-s} to transform it to,


p2+q2 ±1 = r2+s2


simple solns of which are,




(a+1)2 + (2a)2 + 1 = (2a+1)2 + (a-1)2


(2a2-b2+1)2 + (2ab)2 + 1 = (2a2+1)2 + (b2-1)2




(a2-c2+a+1)2 + (2c)2 + 1 = (a2-c2+a-1)2 + (2a+1)2


This form is discussed more in the section on Sums of Three Squares.


Q: Any more solns to p2+q2 ± 1 = r2+s2?



4. Form: x2+y2 = z2+1


In general, given an initial soln to x2+y2 = z2+h, one can find a quadratic parametrization (by this author) in the form,
(pn+a)2 + (pn2+2an+b)2 = (pn2+2an+c)2 + h,  if a2+b2 = c2+h


where p = 2(-b+c) for arbitrary {n,h}.
(p2q+p-q)2 + (2pq+1)2 = (p2q+p+q)2 + 1
A. Gerardin


(dx)2 + (d2y2-1)2 = (d2y2+d)2 + 1,  where x2-2(d+1)y2 = 1


More generally, one can convert this to a Pell equation for a broader class.




u2 + ((d-v2)/2)2 = ((d+v2)/2)2 ± 1,   where u2-dv2 = ±1.  (With d chosen such that terms are integers.)


Another way would be to use Euler’s complete soln for x2+y2 = z2+t2,


(ac+bd)2 + (ad-bc)2 = (ac-bd)2 + (ad+bc)2


and set one term, say, ad-bc = ±1, a form discussed previously.  Alternatively, using the simple identity,


(2m)2 + (2m2-n)2 = (2m2-n+1)2 + (2n-1)


set n = 1 or 0 to get,


(2m)2 + (2m2-1)2 = (2m2)2 + 1

(2m)2 + (2m2)2 = (2m2+1)2 - 1


the second of which is for the next section.



5. Form: x2+y2 = z2-1


For this form, starting with an initial identity, one can generate an infinite sequence of identities.
Proof (Piezas):


If a2+b2 = c2 ± d2, then,


(4ac-2bc+2t)2 + (2ac-4bc+2t)2 = (4ac-4bc+3t)2 - d4,   where t = a2+b2+c2
which implies one soln to u2+v2 = w2-x2 leads to another.  Furthermore, iterative use leads to u2+v2 = w2-xk with k a power of two, and x = 1 a special case.  For example, the identity given in the previous section, 
(2m)2 + (2m2)2 = (2m2+1)2 - 1

(8m4+16m3+12m2+8m+2)2 + (8m3+8m2+4m+2)2 = (8m4+16m3+16m2+8m+3)2 - 1

which, in turn, yields another, ad infinitum.  Other solns are,
E. Grigorief


((a2-b2+c2-d2)/2)2 + (ab+cd)2 = ((a2+b2+c2+d2)/2)2 - 1,  where ad-bc = ±1


One can also use Genocchi’s and Pepin’s method,


(2pq(r2-2s2))2 + (4pqrs)2 = (p2+(r4+4s4)q2)2 - 1,  if p2-(r4+4s4)q2 = ±1


which for the case r = 1 has a parametric soln to be discussed in Simultaneous Polynomials.  (This also discusses the complete soln, by Genocchi and Pepin, such that {x2+y2-1, x2-y2-1} are both squares and also involves solving a Pell eqn.)  As an overview, it turns out that,


x2+y2 = z2±1

x3+y3 = z3±1

x4+y4 = z2+1


can be solved using Pell equations, the higher powers to be discussed in their respective sections.  



6: Form x2+y2 = z2+nt2


This generalizes the two forms above.  For the special case when n = 1, this is discussed in mx2+ny2 = mz2+nt2, the last section below.




(1-ma)2 + (1-mb)2 = (mc)2 + 2,  if m = 2(a+b)/(a2+b2-c2)




(2a+bn)2 + (2b+an)2 = (2c-cn)2 + n(2a+2b)2,  if a2+b2 = c2


for some arbitrary constant n which was derived by modifying Gerardin’s.  For the special case t = 1, or Pythagorean-like triples x2+y2 = z2+h, it can be proven that for any h, there is an infinity of solns given by,


(2m+1)2 + (2m2+2m-n)2 = (2m2+2m-n+1)2 + 2n

(2m)2 + (2m2-n)2 = (2m2-n+1)2 + (2n-1)


and the general quadratic parametrization given earlier.  Q: Any other simple formulas that work for all h not derived from these two? 


Note:  For the case h = 0, or the Pythagorean triples x2+y2 = z2, it is known that the ratio N/B where N is the number of primitive solns with z below a bound B asymptotically approaches 1/(2π) ≈ 0.159154, a result established by Lehmer.  If we generalize this to x2+y2 = z2+h and define the ratio R(h) = N/B  for any h, it seems for h < 0, there might be asymptotics which involve 1/√-h.  For example, for h = -1, given N with increasing bound B = 10, 102, 103, and so on gives the sequence of ratios as,


R(-1) = 0.2,  0.14,  0.126,  0.1238,  0.1251,  0.12497,  0.12499, …


which seem to be converging to 0.125 = 1/8.  For small square-free h at bound B = 106 and R(h) rounded to five decimal places, paired with its conjectured asymptotic value:


    R(-2) = 0.17679

1/(4√2)  = 0.17677


    R(-3) = 0.28868

1/(2√3)  = 0.28867


    R(-5) = 0.22366

1/(2√5)  = 0.22360


    R(-6) = 0.20396

1/(2√6)  = 0.20412


     R(-7) = 0.37799

     1/√7  = 0.37796


    R(-10) = 0.15814

1/(2√10)  = 0.15811


is highly suggestive considering the simplicity of the form. Interestingly, for h > 0, the R(h) do not seem to have simple ones involving √h.  (Note: Computing R(h) is time-consuming, and I’m grateful to the Mathematica code provided by Daniel Lichtblau of Wolfram Research, as well as help provided by Andrzej Kozlowski and James Waldby.  If someone can prove the exact values are in fact the correct asymptotics, pls let me know.)



7. Form: x2+y2 = z2+ntk


J. Rose


(4n2)2 + (4n3)2 = (4n2(n-1))2 + (2n)5




x2 + y2 = z2 + (a2+b2)5


{x,y,z} = {(a2+b2)(a2-b2)b, ((a2+1)(a2+b2)2+4b4)/2, ((a2-1)(a2+b2)2-4b4)/2}


E. Barisien


((n+2)(n2-2n-2))2 + (4n(n+1))2 = (2(n+1)(n+2))2 + n6


These can be generalized by the identity given previously by this author for Pythagorean-like triples where the constant term 2n or 2n-1 can be equated to any kth power pk, and n then easily solved for.


Q: Can Mehmed-Nadir’s identity be generalized to x2 + y2 = z2 + (a2+b2)k for other k not using the identity for Pythagorean-like triples? See also sum of three squares x2 + y2 + z2 = (a2+b2)k, one of which is also by Mehmed-Nadir.



8. Form: x2+y2 = mz2+nt2


The parallelogram law states that given a parallelogram's four sides {t,t,z,z} (since it necessarily has opposite sides equal) and two diagonals {x,y}, then,
x2+y2 = 2z2+2t2      (eq.1)
If the diagonals are equal as well, or x = y, then the parallelogram law reduces to the well-known Pythagorean theorem, a2+b2 = c2.  (See also the quadrilateral law, on the form a2+b2+c2+d2 = x2+y2+z2.)  Solns to eq.1 are,




{x,y,z,t} = {2(pr-qs),  2(ps+qr),  (p+q)r-(p-q)s,  (p-q)r+(p+q)s}


M. Gruber


{x,y,z,t} = {4(p-q)q-2s,  4(p-q)r,  s,  4p(p-q)-s}, where s = 2p2-q2-r2


Paul Cheffers
{x,y} = {z+t, z-t}
More completely, by using the transformation {2z, 2t} = {p+q, p-q} on (eq.1), it suffices to solve the form x2+y2 = p2+q2, which can be done completely.  Alternatively, if n is a constant that is the sum of two squares n = a2+b2,


x2+y2 = n(z2+t2)


then this has soln {x,y} = {az+bt,  bz-at} for constant {a,b} and arbitrary {z,t} since this yields,


x2+y2 = (a2+b2)(z2+t2)


For example, x2+y2 = 5(z2+t2) has {x,y} = {2z+t, z-2t}, with Cheffer's as the case {a,b} = {1,1}, and so on. 


Q: Any soln to the more general form x2+y2 = mz2+nt2?



9. Form: c1(x2+ny2) = c2(z2+nt2)


In a manner, this generalizes the previous section.  For constants m1, m2, given an equation of form,
Case 1:  m1(a2+b2) = (r2+s2)(c2+d2
Case 2m1(a2+b2) = m2(c2+d2)


these can be solved if m1, m2 are sums of two squares using the general identity,


(a2+b2)(p2+q2) = (c2+d2)(r2+s2)


where {a,b,c,d} = {ru+sv,  su-rv,  pu+qv,  qu-pv}.  For Case 1, it is constant {p,q} with arbitrary {r,s,u,v};  for Case 2, constant {p,q,r,s} with arbitrary {u,v}. 
Example 1: 
5(a2+b2) = (r2+s2)(c2+d2),  then {a,b,c,d} = {ru+sv,  su-rv,  u+2v,  2u-v}.
Example 2: 
5(a2+b2) = 13(c2+d2),  then {a,b,c,d} = {3u+2v,  2u-3v,  u+2v,  2u-v}.



10. Form: mx2+ny2 = mz2+nt2


Theorem: “There is a complete integral solution to ap2+bpq+cq2 = ar2+brs+cs2.”


First. we transform this to diagonal form by the transformation {p,q,r,s} = {u-bv, 2av, x-by, 2ay} to get,


u2-Dv2 = x2-Dy2


where D = b2-4ac is the discriminant.  This can be solved in an even more general form.


Theorem: “The equation mu2+nv2 = mx2+ny2 has the complete solution,


m(ac+bdn)2 + n(bc-adm)2 = m(ac-bdn)2 + n(bc+adm)2 = (ma2+nb2)(c2+mnd2

for arbitrary {a,b,c,d}.” 


This is also known as Brahmagupta's identity. Proof : Given any non-trivial soln {u,v,x,y}, one can always find rational {a,b,c,d} using the formulas,


{a,b,c} = {(y-v)/(2dm), (u-x)/(2dn), dn(v+y)/(u-x)}


where it can be set d=1 without loss of generality.  For example, substituting these into u = ac+bdn one finds it is true only if mu2+nv2 = mx2+ny2, and similarly for the other variables.  The idea was to solve for {a,b,c,d} and express them in terms of u,v,x,y.  These were found using Mathematica’s solve command,


Solve[{u,v,x} = {ac+bdn, bc-adm, ac-bdn}, {a,b,c}]


which finds {a,b,c} and where the resulting radical solns can then be simplified using the relation mu2+nv2 = mx2+ny2.  Incidentally, if we set the fourth variable y = bc+adm = 0, Brahmagupta’s identity reduces to,


m(ma2-nb2)2 + n(2abm)2 = m(ma2+nb2)2


which for m=n=1, not surprisingly, is the well-known formula for Pythagorean triples.  There are also other versions.


S. Realis (complete)


u2+nv2 = x2+ny2


{u,v,x,y} = {a2-n(a-b)2+n(a-c)2,  b2-(a-b)2+n(b-c)2,  a2+nb2-nc2,  c2-(a-c)2-n(b-c)2}


V. Lebesgue


(p+q+r-s)2 + (p+q-r+s)2 = (p-q+r+s)2 + (p-q-r-s)2,  if pq = rs


or, alternatively,


(p+q)2 + (r-s)2 = (r+s)2 + (p-q)2,  if pq = rs




x2+y2 = (m2+n2)z2


{x,y,z} = {(u2-dv2)m, nu2-2duv+dnv2,  u2-2nuv+dv2},  where d = m2+n2



11. Form: x2+y2 = zk+tk


(Update, 11/9/09):  W. Lewis asked if results were known for the eqn x2+y2 = z5+t5.  Since I didn't know of any relevant identity, my first thought was to use Mathematica's search function to look for small solns and see if a parametrization could be found.  One can use two approaches:


Method 1:  Use the Bramagupta-Fibonacci Two-Square Identity for the problem in its general case.  This is given by,


(pr+qs)2 + (ps-qr)2 = (p2+q2)(r2+s2)     (eq.1)


There are 4 free variables {p,q,r,s} to dispose of.  Select {p,q} = {xk, yk}.  The RHS, after distributing, becomes,


(pr+qs)2 + (ps-qr)2 = x2k(r2+s2) + y2k(r2+s2)


Then solve for r2+s2 = tk which was discussed in the previous page and is easy to do.  Eq. 1 then becomes,


(pr+qs)2 + (ps-qr)2 = (tx2)k + (ty2)k


For k = 3, this is satistied by {p,q,r,s,t} = {x3, y3,  u3-3uv2, 3u2v-v3, u2+v2} with 4 free variables.  For ex, let {u,v,x,y} = {2,1,3,4}, then,


7582 + 1692 = (5*9)3 + (5*16)3


Method 2:  For co-prime terms, the small solns given by Mathematica were enough to provide a clue for a parametrization to the eqn,


x2+y2 = zk+1


A. For all ODD k in terms of powers and near-powers of 2.  This is given by,


(2m+1)2 + (22m+1-1)2 = (24m+2)1 + 1


(23m+2)2 + (26m+3-1)2 = (24m+2)3 + 1


(25m+3)2 + (210m+5-1)2 = (24m+2)5 + 1


etc.  The pattern is easily seen and one can notice how z has a constant form regardless of k.


(Update, 2/19/11)Oliver Couto gave an EVEN k counterpart,


(nk/2(nk-2))2 + (2nk-1)2 = (n3)k + 1




(n(n2-2))2 + (2n2-1)2 = (n3)2 + 1


(n2(n4-2))2 + (2n4-1)2 = (n3)4 + 1


(n3(n6-2))2 + (2n6-1)2 = (n3)6 + 1





For EVEN k = 4m+2:


(n3-2n)2 + (2n2-1)2 = n6 + 1


(n5-2n3+2n)2 + (2n4-2n2+1)2 = n10 + 1


(n7-2n5+2n3-2n)2 + (2n6-2n4+2n2-1)2 = n14 + 1


and so on.



Previous Page        Next Page