Can You See The Forest From The Trees?

A certain forest is a perfect square of 101 × 101 101 \times 101 very thin trees in a square grid. Precisely at the center of the forest one tree is missing. If you stand exactly at that location, you can see many of the trees-- but not all, because trees in the exact same direction overlap.

How many trees can you see from this position?

Assumptions and hints

Regard the trees as infinitely thin. They either eclipse each other completely because they are in the exact same direction, or are visible as separate trees.

If the forest were 11 × 11 11 \times 11 , you could see 80 trees, as shown in this sketch:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
  o o o o   o o o o  
o   o   o   o   o   o
o o   o o   o o   o o
o   o   o   o   o   o
o o o o o o o o o o o
        o x o
o o o o o o o o o o o
o   o   o   o   o   o
o o   o o   o o   o o
o   o   o   o   o   o
  o o o o   o o o o  


The answer is 6192.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

5 solutions

Otto Bretscher
Dec 17, 2015

Interesting problem!

The number of trees we see between due East and due North East (including) is equal to the number of distinct rational numbers on the interval ( 0 , 1 ] (0,1] with denominator 50 \leq 50 , which is k = 1 50 ϕ ( k ) = 774 \sum_{k=1}^{50}\phi(k)=774 . Thus the total number will be 8 × 774 = 6192 8\times 774=\boxed{6192} .

Great solution!!! What if we extend this from 2D to 3D or higher dimensions? E.g: 101 × 101 × 101 101 \times101 \times101 trees? surrounding you in all directions (still in grid form).

Pi Han Goh - 5 years, 5 months ago

Log in to reply

I ran my program for a 3-D forest of 101 x 101 x 101 and found 854,786 visible trees, or 82.96%.

I ran it again for 1001 x 1001 x 1001 trees and found 834,185,090 trees, or 83.17%.

My suspicion is of course that in n n dimensions the fraction of visible trees will be P ( n ) = 1 ζ ( n ) , P(n) = \frac1{\zeta(n)}, with ζ \zeta the Riemann zeta function. It works exactly for n = 2 n = 2 , and my number comes very close to the known value of 1 / ζ ( 3 ) 1/\zeta(3) , the inverse of Apery's constant: 1 ζ ( 3 ) = 1 1.202056903 = 0.83190737 \frac1{\zeta(3)} = \frac1{1.202056903\dots} = 0.83190737\dots

Indeed, the Wikipedia page about Apery's constant mentions as fact that 1 / ζ ( 3 ) 1/\zeta(3) is the probability that three integers are co-prime (which I assume to mean that they have gcd = 1; they need not be pairwise co-prime, e.g. (6, 10, 15) is considered co-prime).

Finally, I checked the four-dimensional case with 101 x 101 x 101 x 101 trees. Now there were 95,957,472 visible, or 92.21%. Compare this to 1 ζ ( 4 ) = 90 π 4 = 0.9239. \frac1{\zeta(4)} = \frac{90}{\pi^4} = 0.9239.

Arjen Vreugdenhil - 5 years, 5 months ago

Log in to reply

Yes, these limit formulas involving 1 ζ ( k ) \frac{1}{\zeta(k)} are correct... I remember hearing a talk on this topic long ago, without recalling any details (interestingly, Comrade @Pi Han Goh , the proof involved the Mobius function and convolutions). I was looking for a closed formula for a given number of trees, as we have in the 2-D case, but there may not be such a thing since there is no analogue to Euler's totient function, as far as I know.

Otto Bretscher - 5 years, 5 months ago

Good question indeed... I have no idea!

Otto Bretscher - 5 years, 5 months ago
Darryl Dennis
Jan 14, 2016

Interesting problem.

I plotted the lower right quadrant of the forest just for interest. I find it interesting how distinctive the prime number appear in this plot. It seams to me that there could likely be other problems that could be imagined with regard to the distribution of the numbers in the solution to this problem. I have considered posting a similar question. Sticking with the forest of trees description, One could stipulate some areas with no trees. perhaps a clear cut area with a given radius around the viewer, clear cut areas of different shapes placed somewhere in the forest, clear cut grid of roads removing entire columns or entire rows in the forest.

Ivan Koswara
Dec 21, 2015

Let the center be ( 0 , 0 ) (0,0) .

A tree ( x 1 , y 1 ) (x_1, y_1) is hidden iff there exists another tree ( x 2 , y 2 ) (x_2, y_2) such that x 1 = k x 2 , y 1 = k y 2 x_1 = kx_2, y_1 = ky_2 , where k 2 k \ge 2 is a positive integer. In other words, a tree is visible iff the GCD of their coordinates is 1. Now it's straightforward:

1
2
>>> sum((math.gcd(x,y) == 1) for x in range(-50,51) for y in range(-50,51))
6192

This is generalized easily to higher dimensions: a lattice point is visible from the origin iff the GCD of all their coordinates is 1.

Arjen Vreugdenhil
Dec 16, 2015

Call the central position ( 0 , 0 ) (0, 0) , then the forest corresponds to the set { ( x , y ) 50 x , y 50 } , \left\{(x, y)|-50 \leq x,y \leq 50\right\}, and you can see a tree precisely if the ratio x : y x:y cannot be reduced to smaller terms, i.e. if gcd ( x , y ) = 1. \text{gcd}(|x|,|y|) = 1. The implementation is straightforward:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
int trees = 0, size = 50;

for (int x = -size; x <= size; x++)
    for (int y = -size; y <= size; y++) if (x != 0 || y != 0) 
    {
        int a = (x < 0 ? -x : x), b = (y < 0 ? -y : y);
        while (b > 0) {
            int c = b; b = a % b; a = c;    // i.e. a = gcd(|x|, |y|);
        }
        if (a == 1) trees++;
    }

out.println(trees);

Output:

1
6192

Note : In this case 6192 / 10200 = 60.706 % 6192/10200 = 60.706\% of the trees are visible As the forest grows bigger, the fraction of visible trees approaches the odds that two arbitrarily chosen integers are coprime. This limiting probability is 6 / π 2 60.793 % 6/\pi^2 \approx 60.793\% .

I love how Basel problems is relevant here! +1

Pi Han Goh - 5 years, 5 months ago
Fletcher Mattox
Feb 1, 2020

just for the record, this is the sequence of coprime pairs, OEIS 137243, term 50.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...