◀ Navigate through the Chaos pages ►

# Lather, Rinse, Repeat...

What happens to the sequence x, f(x), f(f(x)), etc...?

## Brief Explanation

This page lets you explore iterated functions — that is, you take the output of a function and plug it back into the function again. The sequence of values you get is called the orbit. First, enter a function in the f(x) field. Or, click one of the buttons in the “Interesting functions” list. You can only use the letter ‘x’ for a variable.

For advanced users: note that unless you have just one expression, like “sin(x)”, you must use JavaScript notation. For example, “Math.sin(x) + Math.cos(x)”. If there is only one expression, the “Math.” is automatically prepended.

Then click the “Step” button. The picture below shows what happens with each step. Depending on the function, repeated stepping may do one of several things:

• Settle down to a single stable value (called the attractor).
• Settle down to cycling through a finite set of values. (Hence the term “orbit”.)
• Follow a sequence that seems to have no pattern, and never repeats. (“Chaos”)
• Grow without bounds, in either the negative or positive directions. (Or both — try -2∙x.)

## Try It Yourself

To watch recursion in action, click the red button. For more sample functions, click the buttons in the “Interesting functions” section below.

Expression for f(x)Orbit values x, f(x), f(f(x)), ...

This sets x to be f(x)

### Interesting functions to try

• f(x) = As suggested above, this one “blows up” in both directions.
• f(x) = (This is the square root of x.) Start with numbers less than 1, then with numbers greater than 1.
• f(x) = What do you think will happen?
• f(x) = Now what?
• f(x) = This is the key example! Start with numbers between 0 and 1.
• f(x) = Again, start with numbers between 0 and 1. How does this differ from the previous example?
• f(x) = This is a very interesting function, defined on the integers. It is calculated this way:
• If x is even, f(x) = x/2
• If x is odd, f(x) = 3x + 1
It is believed that all orbits (for positive numbers) eventually lead to the cycle 4,2,1,4,2,1... See what happens with negative numbers like -1, -5, or -17. (Here is a picture of some of the orbits.)

## Remarks

What’s one of the first things a young student does when she gets a new tool like a calculator? Presses every button over and over, just to see what happens! This amounts to finding orbits, if the key is a specific function, like x squared, log(x), sin(x), and so on. This apparently trivial game takes the student into a very deep topic.

Part of the importance of this is that many phenomena in the world outside math can be modeled by a function that take the way things are today, and cranks out a prediction of how they will be tomorrow. Well... and what about the day after tomorrow? Of course, you take the prediction, and plug it back in the function. As in the diagram below. In other words, generate an orbit! The behavior of orbits of iterated functions can be either simple (periodic orbits) or complex (chaotic orbits). The functions with the green buttons above are versions of the logistic map, and are the topic of the next page to come in this sequence. In brief, as the coefficient varies from 0 to 4, the orbits have period 1, then 2, then 4... then 3, then 6, then 9... and for each possible period there is some coefficient . For example, when the coefficient is 3.5 the orbit will settle down into a period of 4. Can you find a coefficient that results in a period of 5? (Not easy!) When the coefficient is 4, the orbits are chaotic.

◀ Navigate through the Chaos pages ►