In this unit I'll introduce iteration.
Iteration is a simple idea and it'll form the basis for the rest of the course.
I'll introduce iteration through a series of examples in this unit and the next. Let's get started.
So here is the idea behind iteration.
As we've seen, a function is an action. It takes an input x, it does something to it, the function acts on it and there is an output called f(x).
To iterate a function, we just turn this process into a loop, like this.
I take the output of a function and feed it back in as the input. So, I am repeatedly applying this function, over and over to a number.
I start with a number and I use the function's output as the next input. So, let's say, we were working again with the tripling function.
f of x equals three x. Suppose I start with a number 2.
When I apply f to two, I triple it. And I get six. Now, what if I apply f to six? I would triple that, and I would get eighteen. So I started with two, I triple it I get six.
Move it around here, it's the input again, I triple it again and I get eighteen.
For the next one, I'll need to triple 18. Maybe if I'm not feeling confident about my multiplication, I could do it on a calculator.
And then I could triple that again.
So I am applying the function f to 2, I get 6. I apply f to 6 I get 18. I apply f to 18, I get 54, and so on.
Let's try one more example.
Let's suppose I start with a half, zero point five. So 0.5 would be my input. I triple that.
0.5 times 3, I get 1.5. Then I need to triple that. 1.5 times 3, 4.5.
Then I would need to triple 4.5. 4.5 times 3, 13.5. Let's do one more. 13.5 times 3, it's 40.5.
So, iterating a function is just applying a function over and over again, using the output as the next input.
There is a good chance that you've iterated functions before.
When I was in high school, we didn't have laptops to entertain us. We didn't have cell phones, smartphones or this dumb phone like mine.
But we did have calculators. And maybe you've played the following game on a calculator when you were in a class that was, perhaps, a little boring, or you needed something to do.
Perhaps, you've just entered a number, and then hit a key, a function key, again and again. Maybe the squaring button.
And if you've started...I started with the number 5, eventually the number gets too big and it overflows the calculator and you feel a moment of triumph.
And then maybe you try another number too, and you hit that button again and again. And it also overflows the calculator, again you feel a moment of triumph.
Okay, it's not a very fun game, but you know, we only had calculators. It was the best we could do.
But the point is that this act of hitting a button over and over again on a calculator, you enter a number and then you iterate the function, whatever is on that key again and again and again.
You start with 5, it gives 25. And the output of that function, you do the function again to that, and so on.
This is iteration. So if you've ever played this game on a calculator, and my experience is that many people have, because you're often bored and all you have to entertain yourself is a calculator, then you've iterated functions before.
Anyway, let's continue with examples, and look at iteration in a little bit more detail, and introduce some important terminology and notation.
Subtitles by the Amara.org community