Jumping Flea



This is a "story problem" and not the description of a real situation.

Imagine a flea that is jumping around in a random fashion. At each jump, it chooses a direction, and any direction has the same chance of being chosen as any other. Also it chooses the length of each jump, which can be any number between 0 and some maximal length. The flea starts its jumping in the center of a circle with a radius that is 10 times longer than its longest jump.
       
Can you guess how much ground it will cover before it leaves the circle by jumping randomly?

This story introduces the concept of a "random walk", which is important in solving some problems (e.g. in physics).

The task is to write an animated simulation that will trace the jumps of an imaginary flea and compute the total distance the flea covers.

                A solution on the TI-84 Plus C

Set the MODE: CLASSIC, DEGREE, PARAMETRIC
Set the FORMAT: CoordOff, Axes:Off
Use ZOOM to set window: ZStandard, ZSquare
Set the window: Tmin=0, Tmax=360,Tstep=3
Define a circle of radius 10,
\X1T=10cos(T)
 Y1T=10sin(T)

Enter this program:                         Number of the line of code:

PROGRAM:FLEA 

:0→A:0→B:0→L:ClrDraw (1)
:While A2+B2<100 (2)
:360rand→Q:rand→S (3)
:A+Scos(Q)→C:B+Ssin(Q)→D (4)
:Line(A,B,C,D) (5)
:C→A:D→B:L+S→L (6)
:DispGraph:End:Disp L (7)


Comments on each line of code:
 (1) A and B hold the coordinates x and y of the fly before it jumps.
 (2) The program stops when the flea crosses the rim of the circle.
 (3) The angle Q and the size S of a jump are chosen randomly.
 (4) Coordinates C and D of the landing are computed.
 (5) The flea jumps. The jump is shown as a short line drawn on the screen.
 (6) The landing point becomes the starting point of the next jump. The distance traveled so far is updated.
 (7) You see what happens as an animation.

After the program stops, you see the total distance that the flea traveled.  (It was inside a circle with a radius of 10 units.)  In order to see the picture again, press GRAPH.  In order to see the distance again, press alpha L ENTER

Here are several runs. The third one below had a length of  230.7.






















Webpage Maintained by Owen Ramsey
Lesson Index