5
$\begingroup$

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}]
$\endgroup$
6
  • $\begingroup$ Ummm... ${1,0),(0,1),{-1,0),(-1,1}$ perhaps? $\endgroup$ Aug 12, 2023 at 2:55
  • $\begingroup$ Look for Pythagorean triples with 25 as the third value, and mix and match as needed to get a square. $\endgroup$ Aug 12, 2023 at 2:56
  • $\begingroup$ For example,{x,y},{-y,x},{-x,-y},{y,-x} where {x,y} is Gaussian Integers. $\endgroup$
    – cvgmt
    Aug 12, 2023 at 3:17
  • $\begingroup$ 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 ] $\endgroup$
    – Syed
    Aug 12, 2023 at 4:51
  • $\begingroup$ @Syed I made a mistake. Thank you very much. $\endgroup$
    – Laurenso
    Aug 12, 2023 at 5:16

2 Answers 2

9
$\begingroup$
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

$\endgroup$
1
  • $\begingroup$ @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}; $\endgroup$
    – cvgmt
    Aug 12, 2023 at 15:15
4
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.