0

Connect each point on an n by n lattice to all other points. How many of these line segments will have irrational lengths and what is the sum of all such lines? Can an estimate be found for this question?

  • ThanXXX for the edit after the machine did weirdness on my text. – J. M. Bergot Sep 28 '17 at 17:57
  • What's the source of this question? What are your thoughts on it? An estimate is likely all you're going to get; exact values would be very difficult. – Steven Stadnicki Sep 28 '17 at 18:24
  • At first glance, there are $\Theta(n^4)$ line segments, and since the lengths of most are 'roughly' of size $\Theta(n)$ the probability that any one of them is square is $\Theta(n^{-1/2})$; this suggests that the great majority (i.e. still $\Theta(n^4)$) will be irrational and that the total sum of irrational lengths will be proportional to $n^5$. Constants of proportionality would require a much more delicate analysis... – Steven Stadnicki Sep 28 '17 at 18:24
  • Of course, this is assuming as a heuristic that segment lengths are randomly distributed, which is almost certainly false, but I suspect it is 'heuristically good enough' to not affect the core order of magnitude of the final result. – Steven Stadnicki Sep 28 '17 at 18:28
  • Perhaps some courageous experimentation is needed for a clever programmer. Try some values of the n by n to get the exact number of such lines segments with irrational lengths and a decent addition of their lengths, then compare with theory. If one wishes eternal fame, find the number of triangles having integral lengths of their sides in a n by n grid and then send it into OEIS. – J. M. Bergot Sep 28 '17 at 18:44
  • The source of the question is my wonder just how far computer programming has advanced to solve geometric questions. I will perhaps toss in a further nightmare. – J. M. Bergot Sep 28 '17 at 18:46

1 Answers1

1

A square root of an integer is either an integer, or it is irrational (see this question). I'm assuming this is a two dimensional lattice on integer points (generalizing to higher dimensions is an interesting question!)

One must count all the Pythagorean triples in the $n\times n$ lattice. This is a challenge, as can be seen in this book or this page on Wolfram's MathWorld.

First we count the number of non-diagonal straight lines that will evidently have integer length. In one row there will be $(n-1)$ connections of length $1$, $(n-2)$ of length 2, etc... so there are $\left[(n-1) + (n-2) + \ldots + 1\right]$ such connections in a single row, which sums to be $n (n-1) / 2$. Thus there is a total
$$ \text{Number of flat connections} = n^2 (n-1) $$ in the whole lattice when we consider all rows and all columns.

Now count the integer length diagonals, or Pythagorean triples in the lattice. If $s$ has a prime factorisation $$ s = 2^{\alpha_0} p_1^{\alpha_1} \cdots p_d^{\alpha_d} $$ then the number of Pythagorean triples with $s$ as a non-hypotenuse leg (side) is given by $$ L(s) = \frac{1}{2} \begin{cases} \left[ (2\alpha_1 + 1) (2\alpha_2+1) \cdots (2\alpha_d+1) - 1\right] & \text{if } \alpha_0 = 0 \\ \left[ (2\alpha_0 - 1)(2\alpha_1 + 1) \cdots (2\alpha_d+1) - 1\right] & \text{otherwise.} \end{cases} $$ (note that this doesn't include triples with a 0, so does not overlap with the previous quantity of "flat" connections)

But this doesn't tell us anything about the size of the other leg, so it can't tell us whether a Pythagorean triple associated with any given $s$ would fit in the lattice.

Ultimately it seems that there is no closed-form expression for the proportion of connections that are of integer length. One could look at asymptotics, but that is another question.

I tried a few calculations in Python here, have a look and a play if you'd like.

  • Left to be done is to find the lengths of all these irrational line segments Is there an accurate average length? A few computer experiments would give strong evidence of the correctness of your answer. – J. M. Bergot Sep 29 '17 at 18:41
  • Actually, there's an error in the calculation above. I'm just checking it now. Stay tuned – occassional user Oct 02 '17 at 09:33
  • I didn't want to say anything but I found your formula to be incorrect. I looked into OEIS and found A228108, which covers the question. It does not provide a formula from Grand Theory but just plows through the n by n insearch of Pythagorean triples, primitive or mutiples. If you want to put your brain onto true torture: find a method for finding all line segments having RATIONAL lengths. This would mean that diagonals could be divided into rational lengths when Pythagorean triples are discovered. Even a computer program for this would be quite the challenge. Do NOT write it in Vegas. – J. M. Bergot Oct 02 '17 at 17:23
  • Yep, it's very incorrect. I'm going to edit now and put in a few thoughts. I've written a Python script to do the calculation, and I'm close, but not close enough... – occassional user Oct 03 '17 at 07:45