Square-Triangle Theorem

Author

Eric W. Weisstein
April 27, 2006

This notebook downloaded from http://mathworld.wolfram.com/notebooks/DiophantineEquations/Square-TriangleTheorem.nb.

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

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

Solutions

Table[{n,{x,y,z}/.FindInstance[n==x^2+(2y)^2+z(z+1)/2,{x,y,z},Integers,10]},{n,20}]//ColumnForm

Numbers of Solutions

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

solns=Table[Reduce[n==x^2+(2y)^2+z(z+1)/2,{x,y,z},Integers,Backsubstitution->True],{n,10^4}];//Timing

Length/@Take[solns,100]

Having a solution with no 0s

(nopos=Position[Or@@@Table[FreeQ[#,0]&/@({x,y,z}/.{ToRules[Reduce[n==x^2+(2y)^2+z(z+1)/2,{x,y,z},Integers,Backsubstitution->True]]}),{n,100}],False]//Flatten)//Timing

(nopos=Position[Or@@@(FreeQ[#,0]&/@({x,y,z}/.{ToRules[#]})&/@Take[solns,All]),False]//Flatten)//Timing

Union[Length/@solns]

First Requiring n

pairs=Split[Sort[MapIndexed[{#1,#2[[1]]}&,Length/@solns]],First[#1]==First[#2]&];

first=First/@pairs;

Length[first]

Position[-Subtract@@@Partition[First/@first,2,1],Except[2],1,1,Heads->False]

Last/@Take[first,14]

last=Last/@pairs;

Position[-Subtract@@@Partition[First/@last,2,1],Except[2],1,1,Heads->False]

Last/@Take[last,14]

High-Water Marks

HighWaterMarks[Length/@solns]