Lesson goal: The spiraling bug walk

Previous: Consecutive integer sums of 100 | Home | Next: The serpentine number grid

In the 1980 MAA Annual High School Mathematics Examination (Problem #13), contestants tackled this coordinate motion puzzle:

"A bug (of negligible size) starts at the origin on the coordinate plane. First it moves 1 unit right to $(1, 0)$. Then it makes a $90^\circ$ turn counterclockwise and travels $1/2$ unit to $(1, 1/2)$. If it continues in this fashion, each time making a $90^\circ$ turn counterclockwise and traveling half as far as in the previous move, to which of the following points will it come closest? (A) $(2/3, 2/3)$ (B) $(4/5, 2/5)$ (C) $(2/3, 4/5)$ (D) $(2/3, 1/3)$ (E) $(4/5, 3/5)$."

Let's track the bug's movements along the $x$ and $y$ axes separately:
  • Horizontal moves ($x$): First $+1$ unit east, then $-1/4$ west, then $+1/16$ east, then $-1/64$ west: $$x = 1 - \frac{1}{4} + \frac{1}{16} - \frac{1}{64} + \dots$$ This is an infinite geometric series with first term $a = 1$ and common ratio $r = -1/4$: $$x = \frac{a}{1 - r} = \frac{1}{1 - (-1/4)} = \frac{1}{5/4} = \frac{4}{5} = \mathbf{0.8}$$
  • Vertical moves ($y$): First $+1/2$ north, then $-1/8$ south, then $+1/32$ north: $$y = \frac{1}{2} - \frac{1}{8} + \frac{1}{32} - \dots$$ This geometric series has first term $a = 1/2$ and common ratio $r = -1/4$: $$y = \frac{1/2}{1 - (-1/4)} = \frac{1/2}{5/4} = \frac{2}{5} = \mathbf{0.4}$$
The bug spirals directly toward the limit point $(\mathbf{0.8}, \mathbf{0.4}) = (4/5, 2/5)$!

In this lesson, we simulate the bug's step-by-step turns with a loop and observe how the coordinates converge to $(0.8, 0.4)$.

Now you try. Replace ???? with 2 and run the code to verify that the bug converges to x = 0.8 and y = 0.4.

Type your code here:


See your results here: