In geospace, how do I find coordinates of the vertices of an equilateral triangle whose vertices have integral coordinates? How do I tell Mathematica to do that?
-
1$\begingroup$ Be more explicit and check grammar please else you will soon get some down votes! $\endgroup$– PlatoManiacCommented Sep 9, 2012 at 16:27
-
2$\begingroup$ See this math.SE question. As noted there, in 3D, you can have an equilateral triangle with integer coordinates (it is easy to construct an octahedron with integer coordinates, and its faces are equilateral triangles); in 2D, this is impossible. $\endgroup$– J. M.'s missing motivation ♦Commented Sep 9, 2012 at 16:53
2 Answers
You can always find equilateral triangles that have any two points as vertices. For instance, the function
eqTri[x1_, y1_, x2_, y2_] :=
FullSimplify[Solve[{(x1 - x3)^2 + (y1 - y3)^2 == (x1 - x2)^2 + (y1 - y2)^2,
(x2 -x3)^2 + (y2 - y3)^2 == (x1 - x2)^2 + (y1 - y2)^2}, {x3,y3}]]
uses the definition that the length of the line from point1 to point2 must equal both the length of the line from point1 to point3 and the length of the line from point2 to point3, where point1={x1,y1}
, point2={x2,y2}
, and the unknown point3={x3,y3}
. For example,
pts = (eqTri[1, 2, 3, 4] // N)
gives two answers (as should be expected)
{{x3 -> 0.267949, y3 -> 4.73205}, {x3 -> 3.73205, y3 -> 1.26795}}
We can verify that it's an equilateral triangle using:
GraphicsGrid[{Graphics[{EdgeForm[Thick], Pink,
Polygon[{{1, 2}, {3, 4}, #}]}, Frame -> True] & /@ (pts /.Rule[a_, b_] -> b)}]
Of course, this does not address the issue of integer-valued vertices. You can see that there are none by looking at the answer that eqTri[ ]
calculates:
eqTri[x1, y1, x2, y2]
{{x3 -> 1/2 (x1 + x2 - Sqrt[3] Sqrt[(y1 - y2)^2]), y3 -> (y1^2 + Sqrt[3] (x1 - x2) Sqrt[(y1 - y2)^2] - y2^2)/(2 (y1 - y2))}, {x3 -> 1/2 (x1 + x2 + Sqrt[3] Sqrt[(y1 - y2)^2]), y3 -> (y1^2 + Sqrt[3] (-x1 + x2) Sqrt[(y1 - y2)^2] - y2^2)/(2 (y1 - y2))}}
Taking the first of these x3
's and simplifying yields:
FullSimplify[1/2 (x1 + x2 - Sqrt[3] Sqrt[(y1 - y2)^2]),
Assumptions -> {x1 \[Element] Reals, y1 \[Element] Reals,
x2 \[Element] Reals, y2 \[Element] Reals}]
1/2 (x1 + x2 - Sqrt[3] Abs[y1 - y2])
Now, by assumption, x1, x2, y1
and y2
are all integers. Clearly x3 can't be an integer since it must be the product of an integer (Abs[y1-y2])
times Sqrt[3]
. Since the same thing holds for the second answer, there is no such (integer-valued) triangle, at least in 2D.
Another indirect way to sense the insolvability is
res = FindInstance[{(x1 - x3)^2 + (y1 - y3)^2 == (x1 - x2)^2 + (y1 -
y2)^2, (x2 - x3)^2 + (y2 - y3)^2 == (x1 - x2)^2 + (y1 -
y2)^2}, {x1, y1, x2, y2, x3, y3}, Integers, 2]
{{x1 -> -94, y1 -> -8, x2 -> -94, y2 -> -8, x3 -> -94, y3 -> -8}, {x1 -> 47, y1 -> -6, x2 -> 47, y2 -> -6, x3 -> 47, y3 -> -6}}
One can see these solutions are not able to define triangle in 2D.
-
-
3$\begingroup$ Is 0.267949 the new integer? (There are no solutions in the two-dimensional plane) $\endgroup$– stevenvhCommented Sep 9, 2012 at 17:32
-
1$\begingroup$ No, it's a decimal. But it is in fact a close approximation to a new integer. Which is really neat in a way. Hithertoo new integers had only been found at the leftmost or rightmost ends of the number line. This is the first time since the discovery of zero that a gap has been plugged by a newly discovered integer. $\endgroup$ Commented Sep 10, 2012 at 19:32
A mindless brute-force solution in $d \gt 2$ dimensions can be obtained with FindInstance
:
d = 3;
{x, y, z} = Unique[ConstantArray[#, d]] & /@ {"x", "y", "z"}; (* Create variables *)
{x, y, z} /. First[FindInstance[(y - x).(y - x) == (z - y).(z - y) == (x - z).(x - z) > 0,
x~Join~y~Join~z, Integers]] (* Find one solution *)
{{1, 0, 1}, {1, 1, 0}, {0, 0, 0}}
(0.01 seconds execution time.)
Of course this can be hugely simplified with a little analysis (e.g., one of the vertices can be translated to the origin, $d$ can be restricted to $3$ with the remaining components padded out to a full $d$ dimensions with zeros, and any orthogonal or affine transformation with integral coefficients can be applied to the result to yield a large set of solutions).
-
$\begingroup$ Orthogonal transformations with integral coefficients are not exactly plentiful... (I gave it an upvote all the same). $\endgroup$ Commented Sep 10, 2012 at 19:30
-
$\begingroup$ @Daniel No, they're not--but they extend the affine transformations enough to generate a few more solutions :-). $\endgroup$– whuberCommented Sep 10, 2012 at 19:33