Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
1  
Be more explicit and check grammar please else you will soon get some down votes! –  PlatoManiac Sep 9 '12 at 16:27
    
Welcome to Mathematica.SE! Please consider registering your account so that any upvotes you get on this question are added to those you might get on future questions and answers. That way, over time you will be able to do more on the site (post graphics, edit things, etc): mathematica.stackexchange.com/privileges –  Vitaliy Kaurov Sep 9 '12 at 16:29
2  
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. –  J. M. Sep 9 '12 at 16:53
add comment

2 Answers

up vote 7 down vote accepted

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)}]

enter image description here

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.

share|improve this answer
    
Thanks for the help PlatoManiac. –  bill s Sep 9 '12 at 17:31
3  
Is 0.267949 the new integer? (There are no solutions in the two-dimensional plane) –  stevenvh Sep 9 '12 at 17:32
1  
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. –  Daniel Lichtblau Sep 10 '12 at 19:32
    
Thank you very much. –  minthao_2011 Sep 15 '12 at 14:50
add comment

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).

share|improve this answer
    
Orthogonal transformations with integral coefficients are not exactly plenntiful... (I gave it an upvote all the same). –  Daniel Lichtblau Sep 10 '12 at 19:30
    
@Daniel No, they're not--but they extend the affine transformations enough to generate a few more solutions :-). –  whuber Sep 10 '12 at 19:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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