5

I have a circle and I want to select four points to make a square so that its coordiantes are eight different integer numbers like this

{{7, 24}, {-24, 7}, {-7, -24}, {24, -7}}

I tried

ClearAll[a, b, r, c];
a = 0;
b = 0;
r = 25;
ss = Subsets[{x, y} /.
   Solve[{(x - a)^2 + (y - b)^2 == r^2, x != a, y != b, x > y}, {x, 
     y}, Integers], {4}]
xzczd
  • 65,995
  • 9
  • 163
  • 468
Laurenso
  • 1,032
  • 2
  • 11
  • Ummm... ${1,0),(0,1),{-1,0),(-1,1}$ perhaps? – David G. Stork Aug 12 '23 at 02:55
  • Look for Pythagorean triples with 25 as the third value, and mix and match as needed to get a square. – Daniel Lichtblau Aug 12 '23 at 02:56
  • For example,{x,y},{-y,x},{-x,-y},{y,-x} where {x,y} is Gaussian Integers. – cvgmt Aug 12 '23 at 03:17
  • Can eight different integers make a square? The example in the OP gives: pts = {{-15, -20}, {7, -24}, {20, 15}, {24, -7}}; Graphics[{ {Dashed, Black, CircleThrough[pts]} , {FaceForm[Lighter@Yellow], EdgeForm[Black], Polygon[SortBy[pts, ArcTan]]} , {Red, AbsolutePointSize[6], Point /@ pts} , Text[#, #, {-1.5, 0}] & /@ pts } , ImageSize -> 300 , Frame -> True ] – Syed Aug 12 '23 at 04:51
  • @Syed I made a mistake. Thank you very much. – Laurenso Aug 12 '23 at 05:16
  • Related: https://mathematica.stackexchange.com/q/15898/1871 – xzczd Aug 18 '23 at 00:20

2 Answers2

9
Clear[r, sol, a, b, pts, squares];
r = 25;
sol = Solve[x^2 + y^2 == r^2, {x, y}, PositiveIntegers]
{a, b} = {0, 0};
pts = Threaded@{a, b} + {{x, y}, {-y, x}, {-x, -y}, {y, -x}} /. sol;
squares = Map[Polygon, pts]
Graphics[{Circle[{a, b}, r], EdgeForm[RandomColor[]], 
    FaceForm[], #} & /@ squares]

{{x -> 7, y -> 24}, {x -> 15, y -> 20}, {x -> 20, y -> 15}, {x -> 24, y -> 7}}

enter image description here

cvgmt
  • 72,231
  • 4
  • 75
  • 133
  • @minhthien_2016 For example,the two squares are difference. square1 = {{x, y}, {-y, x}, {-x, -y}, {y, -x}} /. {x -> 7, y -> 24}; square2 = {{x, y}, {-y, x}, {-x, -y}, {y, -x}} /. {x -> 24, y -> 7}; – cvgmt Aug 12 '23 at 15:15
4

I have voted for @cvgmt. This is for fun:

The rational points of circle with denominator 25 can generated (excluding degenerate points):

r1 = 3/5 + 4/5 I;
r2 = 4/5 + 3/5 I;
pts = ReIm[
   Union[Times @@@ 
     Tuples[{1, r1, r2, Conjugate@r1, 
       Conjugate@r2, -r1, -r2, -Conjugate[r1], -Conjugate[r2]}, 
      2]]] /. {{x_, 0} :> Nothing, {0, x_} :> Nothing}

{{-(24/25), -(7/25)}, {-(24/25), 7/25}, {-(4/5), -(3/5)}, {-(4/5), 3/ 5}, {-(3/5), -(4/5)}, {-(3/5), 4/5}, {-(7/25), -(24/25)}, {-(7/25), 24/25}, {7/25, -(24/25)}, {7/25, 24/25}, {3/5, -(4/5)}, {3/5, 4/ 5}, {4/5, -(3/5)}, {4/5, 3/5}, {24/25, -(7/25)}, {24/25, 7/25}}

RelationGraph can be used to get the squares (and rescaling to get integers):

rg = RelationGraph[#1 . #2 == 0 &, 25 pts, 
   VertexCoordinates -> (25 pts), VertexLabels -> "Name"];

Visualizing:

lp = ListPlot[25 pts, AspectRatio -> Automatic, 
 Epilog -> Circle[{0, 0}, 25]];
Show[lp, rg, PlotRange -> Table[{-32, 32}, 2], Axes -> False]

enter image description here

ubpdqn
  • 60,617
  • 3
  • 59
  • 148