1
00:00:01,570 --> 00:00:04,217
In this unit I'll introduce iteration.
2
00:00:04,217 --> 00:00:09,487
Iteration is a simple idea and it'll form the basis for the rest of the course.
3
00:00:09,487 --> 00:00:19,820
I'll introduce iteration through a series of examples in this unit and the next. Let's get started.
4
00:00:19,820 --> 00:00:23,016
So here is the idea behind iteration.
5
00:00:23,016 --> 00:00:33,098
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).
6
00:00:33,098 --> 00:00:41,320
To iterate a function, we just turn this process into a loop, like this.
7
00:00:41,320 --> 00:00:50,097
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.
8
00:00:50,097 --> 00:01:02,377
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.
9
00:01:02,377 --> 00:01:09,987
f of x equals three x. Suppose I start with a number 2.
10
00:01:09,987 --> 00:01:31,071
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.
11
00:01:31,071 --> 00:01:38,320
Move it around here, it's the input again, I triple it again and I get eighteen.
12
00:01:38,320 --> 00:01:48,136
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.
13
00:01:48,136 --> 00:01:58,237
And then I could triple that again.
14
00:01:58,237 --> 00:02:10,737
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.
15
00:02:10,737 --> 00:02:13,986
Let's try one more example.
16
00:02:13,986 --> 00:02:24,298
Let's suppose I start with a half, zero point five. So 0.5 would be my input. I triple that.
17
00:02:24,298 --> 00:02:43,016
0.5 times 3, I get 1.5. Then I need to triple that. 1.5 times 3, 4.5.
18
00:02:43,016 --> 00:03:03,818
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.
19
00:03:03,818 --> 00:03:11,820
So, iterating a function is just applying a function over and over again, using the output as the next input.
20
00:03:11,820 --> 00:03:17,320
There is a good chance that you've iterated functions before.
21
00:03:17,320 --> 00:03:27,857
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.
22
00:03:27,857 --> 00:03:37,857
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.
23
00:03:37,857 --> 00:03:47,070
Perhaps, you've just entered a number, and then hit a key, a function key, again and again. Maybe the squaring button.
24
00:03:47,070 --> 00:03:56,857
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.
25
00:03:56,857 --> 00:04:05,856
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.
26
00:04:05,856 --> 00:04:10,903
Okay, it's not a very fun game, but you know, we only had calculators. It was the best we could do.
27
00:04:10,903 --> 00:04:23,376
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.
28
00:04:23,376 --> 00:04:29,297
You start with 5, it gives 25. And the output of that function, you do the function again to that, and so on.
29
00:04:29,297 --> 00:04:41,153
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.
30
00:04:41,153 --> 00:04:45,153
Anyway, let's continue with examples, and look at iteration in a little bit more detail, and introduce some important terminology and notation.