Pythagorean Quadruple

Author

Eric W. Weisstein
February 4, 2004

This notebook downloaded from http://mathworld.wolfram.com/notebooks/DiophantineEquations/PythagoreanQuadruple.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/PythagoreanQuadruple.html.

©2005 Wolfram Research, Inc. except for portions noted otherwise

Enumeration

Developer`SetSystemOptions["ReduceOptions"->{"DiscreteSolutionBound"->1000}];

solns={a,b,c,d}/.{ToRules[Reduce[a^2+b^2+c^2==d^2 &&d>0&&a≤b≤c&&Sequence@@(0<#<10&/@{a,b,c}),{a,b,c,d},Integers,Backsubstitution->True]]}

Primitive

Sort[Select[solns,GCD@@#==1&],Max[#1]<Max[#2]&]

Parametric Solutions

First

pars1={
a->2m p,
b->2n p,
c->p^2-(m^2+n^2),
d->p^2+(m^2+n^2)
}

a^2+b^2+c^2-d^2/.pars1//Simplify

solns1=With[{N=5},Union[Flatten[Table[{a,b,c,d}/.pars1,{m,N},{n,N},{p,Floor[Sqrt[m^2+n^2]]+1,N}],2]]]

Sort[Select[solns1,GCD@@#==1&],Max[#1]<Max[#2]&]

Second

Seems to be wrong...

pars2={
a->2m p+2n q,
b->2n p-2 m q,
c->p^2-(m^2+n^2),
d->p^2+(m^2+n^2)
}

a^2+b^2+c^2-d^2/.pars2//Simplify

solns1=With[{N=5},Union[Flatten[Table[{a,b,c,d}/.pars1,{m,N},{n,N},{p,Floor[Sqrt[m^2+n^2]]+1,N}],2]]]

Sort[Select[solns1,GCD@@#==1&],Max[#1]<Max[#2]&]