Fibonacci Fables

The Fibonacci Sequence is a sequence of numbers where each number equals the sum of the two preceding numbers. Except, of course, for the second number in the series, because it only has one number preceding it. So we cheat a little at the start, putting two ones there to get the thing going.

This is a Plain English program that lists all the Fibonacci Numbers less than 1000:

To run:
Start up.
Put 1 into a first number. Write the first on the console.
Put 1 into a second number. Write the second on the console.
Loop.
Add the first to the second giving a third number.
If the third is greater than 1000, break.
Write the third on the console.
Put the second into the first.
Put the third into the second.
Repeat.
Wait for the escape key.
Shut down.

These are the numbers we get when we run that:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987

Now here’s a little program that does something interesting with the first few of those numbers:

To run:
Start up.
Clear the screen with the tan color.
Start in the middle of the screen facing south.
Move 1-3/4 inches right and 1 inch down.
Draw some fibonacci squares starting with 1/4 inch.
Refresh the screen.
Wait for the escape key.
Shut down.

To draw some fibonacci squares starting with a length:
Use the brown pen.
Put the length into a first length. Draw a fibonacci square using the first length.
Put the length into a second length. Draw the fibonacci square using the second length.
Loop.
Add the first length to the second length giving a third length.
Draw the fibonacci square using the third length.
If the third length is greater than 4 inches, break.
Put the second length into the first length.
Put the third length into the second length.
Repeat.

To draw a fibonacci square given a length:
Stroke the length. Turn left.
Stroke the length. Turn left.
Stroke the length. Turn left.
Stroke the length. Turn left.
Move the length. Turn left. Move the length.

The result on the screen looks like this:

You can see that once we get rolling, each square mates with the two squares that came before it.

And with just two more routines, we can lay a Fibonacci Spiral on top of those Fibonacci Squares. Here are the additional routines:

To draw a fibonacci spiral starting with a length:
Use the fat black pen.
Put the length into a first length.
Draw a quarter circle the first length times 2 wide (backwards).
Put the length into a second length.
Draw the quarter circle the second length times 2 wide (backwards).
Loop.
Add the first length to the second length giving a third length.
Draw the quarter circle the third length times 2 wide (backwards).
If the third length is greater than 4 inches, break.
Put the second length into the first length.
Put the third length into the second length.
Repeat.

To draw a quarter circle a width wide (backwards):
Put the width times 355/113 divided by 96 into a segment length.
Loop.
Turn left 1/96 of the way.
Stroke the segment length.
Add 1 to a count.
If the count is 24, exit.
Repeat.

When we run that, the nifty result we get looks like this:

You probably noticed that I had to use an approximation for pi (355/113) because Plain English is a whole-number-only language. I wasn’t entirely happy with that, so I got into our built-in wysiwyg page editor to see if I could get to a Fibonacci Spiral without using pi, or an approximation of pi, at all. I started by drawing the Fibonacci Squares, by hand:

It was easy because our editor has a handy snap-to-grid feature. Then I colored that “grid” light blue and drew a simple polygon on top of it in black:

Finally, I smoothed that polygon three times. Et voila! An almost-Fibonacci Spiral:

Our all-integer smoothing technique is described in another article I’ve posted on this blog.

I admit the two spirals aren’t exactly the same, but then neither are all the supposed Fibonacci Spirals in the real world. It is nearly (if not entirely) impossible, for example, to fit a Fibonacci Spiral to a real-life Nautilus shell. Check it out. Look closely at all those overlaid images on Google and you’ll see that the supposed correspondence is just one more mathemagical myth; a Fibonacci Fable, we might say.

But I don’t want to leave this article on a negative note, so let’s have a little fun with a simpler kind of spiral that is drawn with this routine:

To draw a spiral starting with some twips;
To draw a spiral given a size:
Privatize the size.
Loop.
Draw a half circle given the size.
Divide the size by 2.
Add 1 to a count. If the count is 5, break.
Repeat.

But let’s not just draw one; let’s draw lot’s of ’em:

To run:
Start up.
Clear the screen with the tan color.
Start in the middle of the screen facing north.
Move 2 inches left and 1 inch down.
Loop.
Use the brown pen. Use the fat pen.
Draw a spiral starting with 6 inches.
Turn 1/10 of the way around.
Add 1 to a count. If the count is 5, break.
Repeat.
Refresh the screen.
Wait for the escape key.
Shut down.

Here’s the result:

As Israel Kamakawiwo’ole used to sing, “What a Wonderful World!” It’s cool that we have the privilege, as Johannes Kepler put it, “of thinking God’s thoughts after Him.” Credit where credit is due. I suspect that when we finally figure out exactly what makes a Nautilus shell what it is, we’ll find it’s more like an algorithm than an equation.

One thought on “Fibonacci Fables

  1. “I suspect that when we finally figure out exactly what makes a Nautilus shell what it is, we’ll find it’s more like an algorithm than an equation.”
    I’m sure we will. Chaos theory was full of algorithms, and while I don’t think anyone quite understood it, it turned up a whole lot of striking resemblances to the natural world.

    Like

Leave a reply to Ethan Gardener Cancel reply