1 00:00:00,499 --> 00:00:02,830 The following content is provided under a Creative 2 00:00:02,830 --> 00:00:04,340 Commons license. 3 00:00:04,340 --> 00:00:06,680 Your support will help MIT OpenCourseWare 4 00:00:06,680 --> 00:00:11,050 continue to offer high-quality educational resources for free. 5 00:00:11,050 --> 00:00:13,670 To make a donation or view additional materials 6 00:00:13,670 --> 00:00:17,555 from hundreds of MIT courses, visit MIT OpenCourseWare 7 00:00:17,555 --> 00:00:18,180 at ocw.mit.edu. 8 00:00:22,745 --> 00:00:23,620 PROFESSOR: All right. 9 00:00:23,620 --> 00:00:25,960 So last time we talked about methods 10 00:00:25,960 --> 00:00:28,040 for solving recurrences, and we spent 11 00:00:28,040 --> 00:00:31,624 most of our time talking about divide-and-conquer recurrences. 12 00:00:31,624 --> 00:00:33,790 These are recurrences where you break the problem up 13 00:00:33,790 --> 00:00:37,210 into much smaller sub-problems, like half the size 14 00:00:37,210 --> 00:00:39,570 or 2/3 the size. 15 00:00:39,570 --> 00:00:41,690 And they come up quite a bit in computer science 16 00:00:41,690 --> 00:00:45,150 when you're doing algorithm design and algorithm analysis. 17 00:00:45,150 --> 00:00:46,720 Today, we're going to spend our time 18 00:00:46,720 --> 00:00:48,880 talking about a different kind of recurrence that's 19 00:00:48,880 --> 00:00:50,770 called a linear recurrence. 20 00:00:50,770 --> 00:00:52,610 They also come up in computer science 21 00:00:52,610 --> 00:00:55,360 and a lot of other fields. 22 00:00:55,360 --> 00:00:57,390 Now, I'm going to give you the formal definition 23 00:00:57,390 --> 00:00:59,650 of a linear recurrence later. 24 00:00:59,650 --> 00:01:02,990 First I want to start with an example, 25 00:01:02,990 --> 00:01:05,480 and this is an example of a linear recurrence that comes up 26 00:01:05,480 --> 00:01:06,800 in population modeling. 27 00:01:06,800 --> 00:01:10,260 In fact, it comes up in a lot of places. 28 00:01:10,260 --> 00:01:13,460 And to start it off, we're going to analyze a particular problem 29 00:01:13,460 --> 00:01:16,760 that we call the graduate student job 30 00:01:16,760 --> 00:01:21,810 problem or the graduate student job nightmare. 31 00:01:21,810 --> 00:01:26,150 And the question here is, will your TAs 32 00:01:26,150 --> 00:01:28,350 be able to get a job as a professor somewhere 33 00:01:28,350 --> 00:01:29,425 when they get their PhD? 34 00:01:36,100 --> 00:01:39,040 So this is a problem they worry about a lot. 35 00:01:39,040 --> 00:01:43,280 And the idea in this problem is that there's some discipline, 36 00:01:43,280 --> 00:01:45,270 say computer science. 37 00:01:45,270 --> 00:01:48,310 And if you look in all the universities in the world, 38 00:01:48,310 --> 00:01:51,640 there's M faculty lines. 39 00:01:51,640 --> 00:02:02,790 So the total number of jobs is M, and that's a fixed value. 40 00:02:02,790 --> 00:02:04,690 Because of budgetary constraints, 41 00:02:04,690 --> 00:02:07,330 universities aren't growing, and so they're not 42 00:02:07,330 --> 00:02:10,680 going to create more computer science faculty positions. 43 00:02:10,680 --> 00:02:12,680 It's going to stay fixed over time. 44 00:02:19,900 --> 00:02:22,990 So it's a constant. 45 00:02:22,990 --> 00:02:29,610 And every year, professors generate more graduates 46 00:02:29,610 --> 00:02:31,680 who become professors. 47 00:02:31,680 --> 00:02:35,830 And in particular, we're going to assume that in this field 48 00:02:35,830 --> 00:02:39,130 every professor graduates 1 student who 49 00:02:39,130 --> 00:02:43,650 goes on to become a professor, or tries to if there's jobs. 50 00:02:43,650 --> 00:02:54,910 So each professor generates 1 graduate 51 00:02:54,910 --> 00:03:00,740 who becomes a new professor, as long as there's jobs, per year. 52 00:03:03,460 --> 00:03:07,280 With one exception, and that's first-year professors 53 00:03:07,280 --> 00:03:09,760 because they're too busy learning how to teach, 54 00:03:09,760 --> 00:03:12,540 getting grants, doing administrative stuff, 55 00:03:12,540 --> 00:03:14,682 just figuring out how it all works. 56 00:03:14,682 --> 00:03:16,890 So they don't have time to produce any grad students. 57 00:03:23,510 --> 00:03:27,830 So first year or new professors don't produce anything. 58 00:03:33,340 --> 00:03:37,105 Except first-year profs-- oops, let me correct that. 59 00:03:43,280 --> 00:03:44,750 So first-year profs have 0. 60 00:03:53,340 --> 00:03:56,130 Now, matters are made worse by the fact 61 00:03:56,130 --> 00:03:59,280 that Congress passed a law, and this is true, 62 00:03:59,280 --> 00:04:04,730 that more or less bars mandatory retirements in colleges. 63 00:04:04,730 --> 00:04:09,780 And so that means there are no retirements in this problem, 64 00:04:09,780 --> 00:04:14,150 and we're going to assume the faculty live forever. 65 00:04:14,150 --> 00:04:16,870 And so once you fill a position, it's filled forever. 66 00:04:16,870 --> 00:04:18,160 It doesn't exist anymore. 67 00:04:18,160 --> 00:04:21,149 In fact, if you walk around the math department, 68 00:04:21,149 --> 00:04:23,150 you can see the impact of this. 69 00:04:23,150 --> 00:04:23,650 [LAUGHTER] 70 00:04:23,650 --> 00:04:29,347 I think the median age is now well into the 70s. 71 00:04:29,347 --> 00:04:31,680 And there will be actually a phenomenon over the next 10 72 00:04:31,680 --> 00:04:35,150 years as the math faculty progress into their 80s 73 00:04:35,150 --> 00:04:38,044 where they actually, in reality, probably do start to retire. 74 00:04:38,044 --> 00:04:39,460 And there will be a whole new wave 75 00:04:39,460 --> 00:04:42,460 of people hired in mathematics, just as happened back 76 00:04:42,460 --> 00:04:45,720 in the '50s and '60s after the Sputnik crisis where 77 00:04:45,720 --> 00:04:47,810 a lot of mathematicians were hired. 78 00:04:47,810 --> 00:04:50,700 And then they stayed in those positions, for our purposes, 79 00:04:50,700 --> 00:04:52,530 forever. 80 00:04:52,530 --> 00:04:56,380 Now, the question is, when do all the jobs get filled? 81 00:05:04,640 --> 00:05:09,130 So when are all M jobs filled by this process? 82 00:05:12,830 --> 00:05:14,600 Now, to be able to answer this question, 83 00:05:14,600 --> 00:05:18,790 we need one more piece of information. 84 00:05:18,790 --> 00:05:21,296 Can anybody think about one more fact 85 00:05:21,296 --> 00:05:23,670 here that we need before we start going off and answering 86 00:05:23,670 --> 00:05:26,380 this question, analyzing it? 87 00:05:26,380 --> 00:05:26,880 Yeah? 88 00:05:26,880 --> 00:05:28,580 AUDIENCE: How many professors do we start with? 89 00:05:28,580 --> 00:05:30,580 PROFESSOR: How many professors do we start with? 90 00:05:30,580 --> 00:05:32,320 What's the boundary condition? 91 00:05:32,320 --> 00:05:35,300 What's the base case if we were doing an induction? 92 00:05:35,300 --> 00:05:35,800 All right. 93 00:05:35,800 --> 00:05:45,280 So let's say the boundary condition, 94 00:05:45,280 --> 00:05:48,170 and this always is important with recurrences, 95 00:05:48,170 --> 00:05:53,346 is that the first professor is hired in year 1, 96 00:05:53,346 --> 00:05:54,970 and there were none before that person. 97 00:05:59,190 --> 00:05:59,690 All right? 98 00:05:59,690 --> 00:06:01,339 So in year 1 there's 1 professor, 99 00:06:01,339 --> 00:06:02,380 and that professor's new. 100 00:06:04,680 --> 00:06:05,180 OK. 101 00:06:05,180 --> 00:06:06,650 So now we have all the information 102 00:06:06,650 --> 00:06:08,990 necessary to solve the problem. 103 00:06:08,990 --> 00:06:11,025 So let's do that and set up a recurrence. 104 00:06:16,290 --> 00:06:25,770 We're going to define f of n to be the number of professors 105 00:06:25,770 --> 00:06:26,570 during year n. 106 00:06:31,880 --> 00:06:35,700 And we know from our boundary condition that in year 0 107 00:06:35,700 --> 00:06:43,330 there were none, and in year 1 there was 1, a new one. 108 00:06:43,330 --> 00:06:47,230 What is f of 2? 109 00:06:47,230 --> 00:06:50,360 How many professors are there in year 2? 110 00:06:50,360 --> 00:06:51,327 AUDIENCE: 1. 111 00:06:51,327 --> 00:06:53,160 PROFESSOR: 1, because the one that was there 112 00:06:53,160 --> 00:06:54,368 was too young to do anything. 113 00:06:54,368 --> 00:06:59,540 So he or she is the only one left, all right, in year 2. 114 00:06:59,540 --> 00:07:01,370 What is f of 3? 115 00:07:01,370 --> 00:07:05,000 How many profs are there in year 3? 116 00:07:05,000 --> 00:07:08,870 2-- the one you had, and by that point that one is old enough 117 00:07:08,870 --> 00:07:12,045 to produce a new one. 118 00:07:12,045 --> 00:07:12,590 All right. 119 00:07:12,590 --> 00:07:13,910 What's f of 4? 120 00:07:16,542 --> 00:07:18,360 AUDIENCE: 3. 121 00:07:18,360 --> 00:07:20,890 PROFESSOR: 3, the 2 you had, and there 122 00:07:20,890 --> 00:07:23,520 was one who's been there 2 years to produce a new one. 123 00:07:27,901 --> 00:07:28,400 All right. 124 00:07:28,400 --> 00:07:33,008 And let's do one more, f of 5? 125 00:07:33,008 --> 00:07:33,507 AUDIENCE: 5. 126 00:07:33,507 --> 00:07:35,050 PROFESSOR: 5. 127 00:07:35,050 --> 00:07:41,120 These guys produced 1 each, and you had 3 existing. 128 00:07:41,120 --> 00:07:41,770 All right. 129 00:07:41,770 --> 00:07:44,680 So we can actually write down the recurrence now 130 00:07:44,680 --> 00:07:49,840 by sort of the process we just went through. 131 00:07:49,840 --> 00:07:55,850 For years 2 and beyond, the number of professors in year n 132 00:07:55,850 --> 00:07:59,240 is the number that we had last year-- that's 133 00:07:59,240 --> 00:08:05,190 the previous ones-- plus the number that were generated, 134 00:08:05,190 --> 00:08:08,900 new professors, the graduate students that graduated. 135 00:08:08,900 --> 00:08:11,250 In terms of f, how many new ones are there? 136 00:08:11,250 --> 00:08:12,830 AUDIENCE: f of n minus 2. 137 00:08:12,830 --> 00:08:14,580 PROFESSOR: f of n minus 2, because that's 138 00:08:14,580 --> 00:08:17,080 the number of professors that were there a couple years ago, 139 00:08:17,080 --> 00:08:19,150 and they are now generating them. 140 00:08:19,150 --> 00:08:23,200 So that's the new ones there. 141 00:08:23,200 --> 00:08:26,720 Do people recognize that recurrence? 142 00:08:26,720 --> 00:08:28,390 Yeah, it's pretty famous. 143 00:08:28,390 --> 00:08:29,810 How many people have not seen? 144 00:08:29,810 --> 00:08:31,525 This is called the Fibonacci recurrence. 145 00:08:31,525 --> 00:08:33,720 It produces the Fibonacci numbers. 146 00:08:33,720 --> 00:08:36,480 How many people have not seen it? 147 00:08:36,480 --> 00:08:37,640 Yeah, very famous. 148 00:08:37,640 --> 00:08:40,780 Yeah, pretty much everybody has seen that. 149 00:08:40,780 --> 00:08:43,280 Actually, this is the first recurrence 150 00:08:43,280 --> 00:08:47,020 that was known to be studied of all recurrences. 151 00:08:47,020 --> 00:08:51,260 It was published by Leonardo Fibonacci of Pisa 152 00:08:51,260 --> 00:08:55,620 in 1202, all right, so over 800 years ago, 153 00:08:55,620 --> 00:08:59,120 and he studied it for modeling the population 154 00:08:59,120 --> 00:09:00,680 growth of rabbits. 155 00:09:00,680 --> 00:09:04,450 And the idea is that you have a pair of rabbits, 156 00:09:04,450 --> 00:09:06,880 and in every month after their first year 157 00:09:06,880 --> 00:09:08,910 of life-- sorry, first month of life-- 158 00:09:08,910 --> 00:09:11,221 they produce two new rabbits. 159 00:09:11,221 --> 00:09:11,720 All right? 160 00:09:11,720 --> 00:09:13,053 So it's the same notion as here. 161 00:09:13,053 --> 00:09:15,630 The first pair you do nothing, but after that you're 162 00:09:15,630 --> 00:09:18,450 reproducing one for one. 163 00:09:18,450 --> 00:09:20,480 And that's an abstraction, but it 164 00:09:20,480 --> 00:09:24,170 produces the same recurrence. 165 00:09:24,170 --> 00:09:27,440 Now, Fibonacci is credited with discovering it. 166 00:09:27,440 --> 00:09:30,010 Really that means he's the one that told the Europeans 167 00:09:30,010 --> 00:09:31,680 about it back then. 168 00:09:31,680 --> 00:09:35,800 And in fact, it's now been traced back in to about 200 BC. 169 00:09:35,800 --> 00:09:37,900 The Indian mathematicians knew all 170 00:09:37,900 --> 00:09:40,950 about Fibonacci's recurrence, and they 171 00:09:40,950 --> 00:09:44,410 were using it to study certain properties of grammar and music 172 00:09:44,410 --> 00:09:47,190 way back at 200 BC. 173 00:09:47,190 --> 00:09:50,150 This recurrence comes up in all sorts of applications. 174 00:09:50,150 --> 00:09:52,710 Kepler used it in the 16th century 175 00:09:52,710 --> 00:09:55,900 while studying how the leaves of a flower 176 00:09:55,900 --> 00:09:58,460 are arranged around the stem-- how many leaves 177 00:09:58,460 --> 00:10:02,270 you have in sort of each level coming out around a stem. 178 00:10:02,270 --> 00:10:05,820 The first solution was discovered by de Moivre 179 00:10:05,820 --> 00:10:06,654 in the 18th century. 180 00:10:06,654 --> 00:10:09,153 And we're going to talk about how to solve this in a minute. 181 00:10:09,153 --> 00:10:11,500 But he was the first one to figure out a closed form 182 00:10:11,500 --> 00:10:13,840 expression for f of n. 183 00:10:13,840 --> 00:10:16,270 Lame used it in the 19th century when 184 00:10:16,270 --> 00:10:19,170 he was studying the Euclidean GCD algorithm. 185 00:10:19,170 --> 00:10:21,990 You know that pulverizer thing and doing GCDs? 186 00:10:21,990 --> 00:10:25,690 It turns out that if you want to analyze the running time, 187 00:10:25,690 --> 00:10:27,920 well, you get a Fibonacci recurrence comes 188 00:10:27,920 --> 00:10:31,720 into play there, and that was discovered in the 19th century. 189 00:10:31,720 --> 00:10:34,980 In the 20th century, it was used in the study of optics, 190 00:10:34,980 --> 00:10:38,470 economics, and algorithms, and it was named for Fibonacci. 191 00:10:38,470 --> 00:10:41,540 It got a name in the 19th century. 192 00:10:41,540 --> 00:10:43,570 In fact, this is so popular and used 193 00:10:43,570 --> 00:10:47,200 in so many places there is a journal in mathematics called 194 00:10:47,200 --> 00:10:49,560 the Fibonacci Quarterly Journal where they 195 00:10:49,560 --> 00:10:53,087 study these kinds of things. 196 00:10:53,087 --> 00:10:55,420 So today what we're going to do is solve this recurrence 197 00:10:55,420 --> 00:10:58,060 and actually solve a much broader family of recurrences 198 00:10:58,060 --> 00:11:01,370 called linear recurrences. 199 00:11:01,370 --> 00:11:02,980 And we're going to get a closed form. 200 00:11:02,980 --> 00:11:05,021 I mean, you can produce the Fibonacci numbers one 201 00:11:05,021 --> 00:11:07,880 after another, but we're going to derive a formula 202 00:11:07,880 --> 00:11:11,041 for the n-th Fibonacci number. 203 00:11:11,041 --> 00:11:12,540 And when we're going to do it, we're 204 00:11:12,540 --> 00:11:16,710 going to do it more broadly for a class of linear recurrences. 205 00:11:16,710 --> 00:11:18,155 So let me define what that is. 206 00:11:23,950 --> 00:11:32,740 So a recurrence is said to be linear 207 00:11:32,740 --> 00:11:47,500 if it is of the form f of n equals a constant a1 times 208 00:11:47,500 --> 00:11:55,570 f of n minus 1 plus a2 times f of n minus 2 plus dot dot 209 00:11:55,570 --> 00:12:02,800 dot d'th constant ad times f of n minus d. 210 00:12:02,800 --> 00:12:06,440 And we could simplify that as the sum 211 00:12:06,440 --> 00:12:14,590 i equals 1 to d of a sub i times f of n minus i. 212 00:12:14,590 --> 00:12:19,190 And the constants are fixed here, 213 00:12:19,190 --> 00:12:25,280 so for fixed a sub i and d. 214 00:12:25,280 --> 00:12:27,420 So the number of terms has to be a constant, 215 00:12:27,420 --> 00:12:30,510 and each coefficient has to be a constant. 216 00:12:30,510 --> 00:12:32,030 Can't vary. 217 00:12:32,030 --> 00:12:36,870 And we define d to be the order of the recurrence. 218 00:12:36,870 --> 00:12:40,300 So d is the order of the recurrence. 219 00:12:42,820 --> 00:12:44,790 OK? 220 00:12:44,790 --> 00:12:47,095 And you can see, of course, that Fibonacci's recurrence 221 00:12:47,095 --> 00:12:48,660 is linear. 222 00:12:48,660 --> 00:12:51,080 What's its order? 223 00:12:51,080 --> 00:12:52,190 2. 224 00:12:52,190 --> 00:12:54,880 And the coefficients, the a's, are just 1. 225 00:12:54,880 --> 00:12:58,410 So it's a simple linear recurrence. 226 00:12:58,410 --> 00:12:58,910 All right. 227 00:12:58,910 --> 00:13:00,790 So let's see how to solve it. 228 00:13:00,790 --> 00:13:02,330 Well, actually, before we do that, 229 00:13:02,330 --> 00:13:05,390 can you see the difference between this recurrence, 230 00:13:05,390 --> 00:13:08,140 linear, and divide-and-conquer recurrences? 231 00:13:11,180 --> 00:13:13,050 Right? 232 00:13:13,050 --> 00:13:16,120 What do I have here inside for a divide-and-conquer recurrence? 233 00:13:19,400 --> 00:13:21,640 I get a fraction of n, right? 234 00:13:21,640 --> 00:13:23,630 And here, I'm subtracting a constant 235 00:13:23,630 --> 00:13:26,730 from n, usually like 1, 2, 3, an integer from n. 236 00:13:26,730 --> 00:13:30,940 So linear is when inside you have n minus 1, n minus 2. 237 00:13:30,940 --> 00:13:33,945 Divide and conquer, you got n/2 or 3/4 n. 238 00:13:33,945 --> 00:13:37,992 And it makes a huge difference in the solution. 239 00:13:37,992 --> 00:13:38,780 All right. 240 00:13:38,780 --> 00:13:41,529 So what I'm going to do is give you a closed-form solution 241 00:13:41,529 --> 00:13:42,820 for these kinds of recurrences. 242 00:13:42,820 --> 00:13:47,690 And it won't be completely easy because it took Europeans 243 00:13:47,690 --> 00:13:51,501 six centuries to find the solution to this. 244 00:13:51,501 --> 00:13:52,000 Right? 245 00:13:52,000 --> 00:13:53,720 Fibonacci discovers the thing in 1200 246 00:13:53,720 --> 00:13:55,210 and tells everybody about it. 247 00:13:55,210 --> 00:13:58,305 And it wasn't until 600 years later 248 00:13:58,305 --> 00:14:00,620 that they figured out a closed-form solution. 249 00:14:03,824 --> 00:14:04,920 So let's do that. 250 00:14:08,040 --> 00:14:11,480 Now, what we're going to do to do it this first time 251 00:14:11,480 --> 00:14:13,610 ourselves, and we don't have the formula, 252 00:14:13,610 --> 00:14:15,750 is to use guess and verify. 253 00:14:15,750 --> 00:14:17,620 So we're going to guess a solution 254 00:14:17,620 --> 00:14:19,750 and check that it works. 255 00:14:19,750 --> 00:14:23,030 And we're going to guess, really, a class of solutions. 256 00:14:23,030 --> 00:14:29,966 We're going to try f of n is an exponential in n, alpha 257 00:14:29,966 --> 00:14:32,180 to the n for some constant alpha. 258 00:14:38,310 --> 00:14:40,590 Now, we're going to figure out what 259 00:14:40,590 --> 00:14:45,130 alpha is as we go along during the verification process. 260 00:14:45,130 --> 00:14:45,630 All right? 261 00:14:45,630 --> 00:14:50,830 So let's try to verify this guess and plug it in. 262 00:14:50,830 --> 00:14:56,595 We know that f of n is f of n minus 1 plus f of n minus 2. 263 00:14:56,595 --> 00:15:00,120 Well, let's plug that in and see what we get. 264 00:15:00,120 --> 00:15:03,310 That gives us alpha to the n equals alpha to the n 265 00:15:03,310 --> 00:15:08,880 minus 1 plus alpha to the n minus 2. 266 00:15:08,880 --> 00:15:09,710 All right? 267 00:15:09,710 --> 00:15:15,300 Now, that means I can divide by alpha to the n minus 2, 268 00:15:15,300 --> 00:15:20,920 and I get alpha squared equals alpha plus 1. 269 00:15:20,920 --> 00:15:25,220 And now I can use the quadratic formula to solve for alpha. 270 00:15:25,220 --> 00:15:25,720 All right? 271 00:15:25,720 --> 00:15:30,550 That means that alpha squared minus alpha minus 1 272 00:15:30,550 --> 00:15:38,760 equals 0, which means that alpha equals-- minus minus 1 273 00:15:38,760 --> 00:15:42,680 is 1 plus or minus the square root of-- minus 1 squared 274 00:15:42,680 --> 00:15:49,961 is 1 minus 4ac plus 4 over 2. 275 00:15:49,961 --> 00:15:50,460 OK? 276 00:15:50,460 --> 00:15:54,990 So there's two possible solutions here. 277 00:15:54,990 --> 00:15:57,910 This is 1 plus or minus the square root of 5 over 2. 278 00:16:00,670 --> 00:16:05,670 So it works if f of n equals either-- well, we'll 279 00:16:05,670 --> 00:16:08,450 call the roots here alpha 1 and alpha 2. 280 00:16:14,870 --> 00:16:18,370 Alpha 1 will be the positive case, 1 281 00:16:18,370 --> 00:16:21,176 plus square root of 5 over 2. 282 00:16:21,176 --> 00:16:23,830 And alpha 2 will be the negative case, 1 283 00:16:23,830 --> 00:16:28,580 minus square root of 5 over 2. 284 00:16:28,580 --> 00:16:29,080 All right? 285 00:16:29,080 --> 00:16:35,700 So guess and verify works so far if we have an exponential 286 00:16:35,700 --> 00:16:39,260 with either one of those bases. 287 00:16:39,260 --> 00:16:41,570 All right? 288 00:16:41,570 --> 00:16:45,905 By the way, does anybody recognize that number? 289 00:16:49,220 --> 00:16:50,742 It's a famous number. 290 00:16:50,742 --> 00:16:51,700 AUDIENCE: Golden ratio. 291 00:16:51,700 --> 00:16:53,360 PROFESSOR: The golden ratio, which 292 00:16:53,360 --> 00:16:56,230 is supposed to have all these magical mystical properties. 293 00:16:56,230 --> 00:16:58,000 That when you look at a building, 294 00:16:58,000 --> 00:17:02,060 if its aspect ratio is that, it's perfect to the human eye. 295 00:17:02,060 --> 00:17:02,930 I don't know. 296 00:17:02,930 --> 00:17:05,180 But there's a lot of stuff about the golden ratio that 297 00:17:05,180 --> 00:17:07,235 happens to come up here. 298 00:17:07,235 --> 00:17:07,735 OK? 299 00:17:10,240 --> 00:17:14,790 Now in fact, there's more than just these two solutions. 300 00:17:14,790 --> 00:17:18,819 It turns out that whenever you have a linear recurrence 301 00:17:18,819 --> 00:17:21,810 and you've got two or more solutions like that, 302 00:17:21,810 --> 00:17:25,430 any linear combination is also a solution. 303 00:17:25,430 --> 00:17:25,930 All right? 304 00:17:25,930 --> 00:17:29,160 So we're just going to state that as a fact. 305 00:17:29,160 --> 00:17:31,630 It's not too hard to prove, but we won't prove it in class. 306 00:17:35,110 --> 00:17:39,420 So if f of n equals alpha 1 to the n-- 307 00:17:39,420 --> 00:17:44,590 and this is true for any alpha 1 and alpha 2-- and f of n 308 00:17:44,590 --> 00:17:53,200 equals alpha 2 to the n are solutions 309 00:17:53,200 --> 00:18:04,030 to a linear recurrence-- and here I mean 310 00:18:04,030 --> 00:18:06,680 without yet applying the boundary conditions. 311 00:18:06,680 --> 00:18:08,860 So far, we've ignored the boundary conditions, 312 00:18:08,860 --> 00:18:11,580 and we'll just do that for a little longer. 313 00:18:11,580 --> 00:18:13,660 So if there are solutions without worrying 314 00:18:13,660 --> 00:18:24,710 about the boundary conditions, then f of n 315 00:18:24,710 --> 00:18:31,260 equals c1 times alpha 1 to the n plus c2 alpha 2 to the n 316 00:18:31,260 --> 00:18:34,550 is also a solution for any constants c1 and c2. 317 00:18:56,130 --> 00:18:56,630 All right? 318 00:18:56,630 --> 00:19:01,320 So any linear combination of our solutions also works. 319 00:19:01,320 --> 00:19:05,580 If you plugged it in to do verify, it would be fine. 320 00:19:05,580 --> 00:19:14,380 So that means that f of n equals c1 times 321 00:19:14,380 --> 00:19:18,110 1 plus square root of 5 over 2 to the n 322 00:19:18,110 --> 00:19:25,090 plus c2 1 minus square root of 5 over 2 to the n 323 00:19:25,090 --> 00:19:33,500 is a solution-- oops-- to Fibonacci's recurrence 324 00:19:33,500 --> 00:19:35,320 without boundary conditions again. 325 00:19:41,410 --> 00:19:41,910 All right? 326 00:19:41,910 --> 00:19:46,750 So I could plug this expression into the recurrence, 327 00:19:46,750 --> 00:19:49,885 and it would satisfy it. 328 00:19:49,885 --> 00:19:50,910 I won't do that. 329 00:19:54,180 --> 00:19:57,790 But we haven't dealt with the boundary conditions yet. 330 00:19:57,790 --> 00:19:59,970 And in fact, dealing with the boundary conditions 331 00:19:59,970 --> 00:20:04,270 is what determines the values of these constants. 332 00:20:04,270 --> 00:20:09,010 I could have Fibonacci's recurrence where f of 0 was 10 333 00:20:09,010 --> 00:20:12,040 and f of 1 was 20 if I wanted to, 334 00:20:12,040 --> 00:20:15,860 and then the recurrence would be the same afterwards. 335 00:20:15,860 --> 00:20:19,680 And it will turn out I get different constants here. 336 00:20:19,680 --> 00:20:20,180 All right? 337 00:20:20,180 --> 00:20:22,880 But otherwise, the form is going to look like this. 338 00:20:22,880 --> 00:20:24,340 So let's see how to make that work. 339 00:20:24,340 --> 00:20:26,340 Let's see how to determine the constant factors. 340 00:20:48,770 --> 00:20:49,390 OK. 341 00:20:49,390 --> 00:21:05,360 So to determine the constant factors, 342 00:21:05,360 --> 00:21:08,180 we plug in the boundary conditions. 343 00:21:08,180 --> 00:21:14,590 So we have f of 0 equals 0 from the boundary condition. 344 00:21:14,590 --> 00:21:17,190 And now we plug that into our formula over there. 345 00:21:20,050 --> 00:21:26,740 That's c1 times alpha 1 to the 0 plus c2 alpha 2 to the 0. 346 00:21:26,740 --> 00:21:29,600 Of course, anything to the 0 is just 1. 347 00:21:32,480 --> 00:21:38,471 And that means that c2 equals minus c1. 348 00:21:38,471 --> 00:21:39,902 All right? 349 00:21:39,902 --> 00:21:42,280 And now I'll use the next boundary condition 350 00:21:42,280 --> 00:21:44,180 to nail them down. 351 00:21:50,750 --> 00:21:51,250 All right? 352 00:21:51,250 --> 00:21:56,350 So I know also that f(1) is 1, and that 353 00:21:56,350 --> 00:22:02,380 equals c1 1 plus square root of 5 over 2 to the first power 354 00:22:02,380 --> 00:22:10,050 plus c2 1 minus the square root of 5 over 2 to the first power. 355 00:22:10,050 --> 00:22:13,720 I plug in c2 as minus c1. 356 00:22:13,720 --> 00:22:19,480 So I get c1 1 plus square root of 5 over 2 minus c1 1 357 00:22:19,480 --> 00:22:23,790 minus square root of 5 over 2. 358 00:22:23,790 --> 00:22:27,250 And now that I can factor out the c1, 359 00:22:27,250 --> 00:22:33,890 I get 1 minus 1 square root of 5 minus minus square root of 5, 360 00:22:33,890 --> 00:22:40,370 which gives me c1 2 square root of 5 over 2. 361 00:22:40,370 --> 00:22:42,790 These cancel. 362 00:22:42,790 --> 00:22:47,480 This was all equal to 1, so that means that c1 equals 1 363 00:22:47,480 --> 00:22:50,370 over the square root of 5. 364 00:22:50,370 --> 00:22:53,840 And of course, c2 is minus that. 365 00:22:53,840 --> 00:22:57,640 c2 is minus 1 over the square root of 5. 366 00:23:00,560 --> 00:23:02,815 Any questions so far? 367 00:23:05,585 --> 00:23:06,563 All right. 368 00:23:12,930 --> 00:23:15,660 Now I could write out the formula 369 00:23:15,660 --> 00:23:16,750 for the Fibonacci numbers. 370 00:23:22,630 --> 00:23:23,130 All right? 371 00:23:23,130 --> 00:23:32,380 So the solution is f of n equals c1, which 372 00:23:32,380 --> 00:23:36,810 is 1 over square root of 5, times the n-th power 373 00:23:36,810 --> 00:23:42,800 of the first root plus c2, which is minus 1 374 00:23:42,800 --> 00:23:46,180 over square root of 5, times the n-th power of the second root. 375 00:23:51,030 --> 00:23:54,900 And that is the formula for the n-th Fibonacci number. 376 00:23:57,580 --> 00:24:00,590 You wouldn't have guessed that to start with obviously. 377 00:24:00,590 --> 00:24:02,900 That would require pretty divine inspiration. 378 00:24:02,900 --> 00:24:06,140 And you can sort of see why it took them 600 years in Europe 379 00:24:06,140 --> 00:24:07,660 to figure out the answer. 380 00:24:07,660 --> 00:24:08,160 All right? 381 00:24:08,160 --> 00:24:09,610 It's not the first thing you'd think about. 382 00:24:09,610 --> 00:24:12,240 In fact, if somebody told you the answer and said this is it, 383 00:24:12,240 --> 00:24:14,230 you'd go, oh, give me a break. 384 00:24:14,230 --> 00:24:14,730 All right? 385 00:24:14,730 --> 00:24:17,450 It does not look like-- I mean, what are the chances that 386 00:24:17,450 --> 00:24:20,350 evaluates to an integer? 387 00:24:20,350 --> 00:24:20,850 All right? 388 00:24:20,850 --> 00:24:25,080 It's got square root of 5's all over the place. 389 00:24:25,080 --> 00:24:26,140 Right? 390 00:24:26,140 --> 00:24:30,470 And here I'm telling you that f of 6, 391 00:24:30,470 --> 00:24:34,240 the sixth Fibonacci number, which is 8, 3 plus 5, 392 00:24:34,240 --> 00:24:38,070 I'm telling you that is equal to 1 over square root of 5 1 393 00:24:38,070 --> 00:24:42,250 plus the square root of 5 over 2 to the sixth power minus 1 394 00:24:42,250 --> 00:24:46,290 over square root of 5 1 minus the square root of 5 over 2 395 00:24:46,290 --> 00:24:48,350 to the sixth power. 396 00:24:48,350 --> 00:24:51,350 I mean, would you believe me if I told you that? 397 00:24:51,350 --> 00:24:52,970 Probably not. 398 00:24:52,970 --> 00:24:54,560 What are the chances that's true? 399 00:24:54,560 --> 00:24:58,450 Somehow, magically, all those square root of 5's all go away, 400 00:24:58,450 --> 00:25:02,890 and you're just left with 8, a simple integer. 401 00:25:02,890 --> 00:25:03,390 OK? 402 00:25:06,130 --> 00:25:08,180 All right. 403 00:25:08,180 --> 00:25:13,895 Yeah, there's sort of some more interesting things about this. 404 00:25:13,895 --> 00:25:17,890 What happens to this value here as n gets large? 405 00:25:20,450 --> 00:25:22,938 What does it do as n gets large? 406 00:25:22,938 --> 00:25:26,260 AUDIENCE: Gets small. 407 00:25:26,260 --> 00:25:30,210 PROFESSOR: It gets small Because 1 minus the square root of 5 408 00:25:30,210 --> 00:25:34,480 over 2 is about 0.6. 409 00:25:34,480 --> 00:25:39,120 This is about, here, this is about 0.618 something or other. 410 00:25:39,120 --> 00:25:42,050 And if I take a fraction less than 1 to the n-th power, 411 00:25:42,050 --> 00:25:44,440 it goes to 0. 412 00:25:44,440 --> 00:25:46,430 It goes away. 413 00:25:46,430 --> 00:25:50,140 So in fact, as n gets large, this 414 00:25:50,140 --> 00:25:54,050 is what the n-th Fibonacci number starts to look like. 415 00:25:54,050 --> 00:25:58,250 In particular, f of n equals just that first one-- 1 416 00:25:58,250 --> 00:26:05,530 over square root of 5 times the golden ratio to the n-th power 417 00:26:05,530 --> 00:26:09,260 plus some error term, delta n. 418 00:26:09,260 --> 00:26:17,770 And delta n is less than a 1/10 for n greater than 4. 419 00:26:20,300 --> 00:26:27,330 And it is little l of 1 in general going to 0. 420 00:26:27,330 --> 00:26:29,070 So in fact, the n-th Fibonacci number 421 00:26:29,070 --> 00:26:31,720 is about the n-th power of the golden ratio divided 422 00:26:31,720 --> 00:26:35,020 by square root of 5. 423 00:26:35,020 --> 00:26:35,922 Yeah? 424 00:26:35,922 --> 00:26:38,064 AUDIENCE: [INAUDIBLE] top of the right board-- 425 00:26:38,064 --> 00:26:38,730 PROFESSOR: Yeah? 426 00:26:38,730 --> 00:26:43,158 AUDIENCE: --you say that you can pick sort of any constants that 427 00:26:43,158 --> 00:26:44,009 satisfy it? 428 00:26:44,009 --> 00:26:44,634 PROFESSOR: Yep. 429 00:26:44,634 --> 00:26:46,602 AUDIENCE: Does that shift the sequence 430 00:26:46,602 --> 00:26:48,570 over, or what does that do? 431 00:26:48,570 --> 00:26:50,046 I guess I don't understand. 432 00:26:50,046 --> 00:26:51,810 PROFESSOR: OK. 433 00:26:51,810 --> 00:26:55,609 You're asking, what are these things doing here? 434 00:26:55,609 --> 00:26:56,234 AUDIENCE: Yeah. 435 00:26:56,234 --> 00:26:58,570 And why [? isn't there-- ?] why are they also solutions? 436 00:26:58,570 --> 00:27:00,125 Because this is the right ones? 437 00:27:00,125 --> 00:27:01,166 PROFESSOR: The right one. 438 00:27:01,166 --> 00:27:01,760 OK. 439 00:27:01,760 --> 00:27:05,120 So there's two parts to a recurrence. 440 00:27:05,120 --> 00:27:11,120 There's this part, OK, and there's 441 00:27:11,120 --> 00:27:17,250 the boundary conditions-- f(0) equals 0 and f(1) equals 1. 442 00:27:17,250 --> 00:27:19,450 There are really two parts to it. 443 00:27:19,450 --> 00:27:21,610 If you change the boundary conditions, 444 00:27:21,610 --> 00:27:26,240 you would change the rest of the terms, right? 445 00:27:26,240 --> 00:27:28,460 If I started with 10 and 20, f of 2 446 00:27:28,460 --> 00:27:34,510 would be 30, OK, if I'm using this recurrence form for n 447 00:27:34,510 --> 00:27:36,522 bigger than or equal to 2. 448 00:27:36,522 --> 00:27:40,200 Now, so when I'm computing a solution, first I'm saying, 449 00:27:40,200 --> 00:27:41,860 let's ignore the boundary conditions 450 00:27:41,860 --> 00:27:45,770 and look at all the recurrences that share this part. 451 00:27:45,770 --> 00:27:49,960 And that family of recurrences, I'm claiming, 452 00:27:49,960 --> 00:27:51,580 have these solutions. 453 00:27:51,580 --> 00:27:54,130 This is the solution space if I just 454 00:27:54,130 --> 00:27:59,460 worry about this part and not the boundary conditions. 455 00:27:59,460 --> 00:28:03,160 Now, once I plug the boundary conditions in, 456 00:28:03,160 --> 00:28:08,220 that determines which values of c1 and c2 I get. 457 00:28:08,220 --> 00:28:11,740 And so if I take the version of the recurrence where f(0) 458 00:28:11,740 --> 00:28:16,400 is 0 and f(1) is 1, then c1 is going to be 1 over root 5, 459 00:28:16,400 --> 00:28:19,720 and c2 is going to be negative 1 over root 5. 460 00:28:19,720 --> 00:28:23,660 If I use this recurrence with f(0) 461 00:28:23,660 --> 00:28:28,430 equals 10 and f(1) equals 20, I get different constants, 462 00:28:28,430 --> 00:28:31,362 but these powers stay the same. 463 00:28:31,362 --> 00:28:33,320 In fact, maybe we'll make an exercise like that 464 00:28:33,320 --> 00:28:35,069 from the problem set to figure out what it 465 00:28:35,069 --> 00:28:37,450 is if I started with 10 and 20. 466 00:28:37,450 --> 00:28:38,020 OK? 467 00:28:38,020 --> 00:28:40,240 So that's what the constants have 468 00:28:40,240 --> 00:28:43,160 to do-- they come from the boundary condition, which 469 00:28:43,160 --> 00:28:45,591 is sort of a cool fact. 470 00:28:45,591 --> 00:28:47,280 Does that make sense? 471 00:28:47,280 --> 00:28:48,060 AUDIENCE: Yeah. 472 00:28:48,060 --> 00:28:51,570 PROFESSOR: Any other questions about what I was doing? 473 00:28:51,570 --> 00:28:56,590 So we used guess and verify, but I sort of guessed a form first. 474 00:28:56,590 --> 00:29:01,390 And as I verified, I sort of revised my guess along the way. 475 00:29:01,390 --> 00:29:01,890 All right? 476 00:29:01,890 --> 00:29:03,160 So I started guessing this. 477 00:29:03,160 --> 00:29:05,290 And then I said, well, let's refine 478 00:29:05,290 --> 00:29:11,307 that guess so that really it's one of these two guys. 479 00:29:11,307 --> 00:29:12,890 And then I said-- I used a fact that I 480 00:29:12,890 --> 00:29:14,681 didn't prove-- that said I could use really 481 00:29:14,681 --> 00:29:17,570 any linear combination, plugged it into the base cases, 482 00:29:17,570 --> 00:29:20,301 and got my constants. 483 00:29:20,301 --> 00:29:20,800 All right? 484 00:29:20,800 --> 00:29:23,269 Now, this will lead up to a formula or an approach 485 00:29:23,269 --> 00:29:25,310 so you don't have to go through this on your own. 486 00:29:25,310 --> 00:29:27,710 You just plug in the formula in general. 487 00:29:30,300 --> 00:29:30,800 OK. 488 00:29:33,402 --> 00:29:35,360 Let's get back to the original question of when 489 00:29:35,360 --> 00:29:37,660 all the jobs are filled. 490 00:29:37,660 --> 00:29:43,091 For what value of n is f of n bigger than M? 491 00:29:43,091 --> 00:29:43,590 All right? 492 00:29:48,790 --> 00:29:49,420 Let's do that. 493 00:30:03,940 --> 00:30:04,450 OK. 494 00:30:04,450 --> 00:30:20,130 To see when all the jobs are filled, all M jobs, 495 00:30:20,130 --> 00:30:24,876 for the n when f of n is bigger and equal to M, 496 00:30:24,876 --> 00:30:28,300 when we got a Fibonacci number that's bigger than M. 497 00:30:28,300 --> 00:30:31,770 And we just showed that basically f of n, 498 00:30:31,770 --> 00:30:35,090 well, it equals this where that's a tiny thing. 499 00:30:35,090 --> 00:30:35,590 All right? 500 00:30:35,590 --> 00:30:40,020 So we need to figure out when is 1 over square root of 5 times 501 00:30:40,020 --> 00:30:44,080 the golden ratio to the n-th power-- plus 502 00:30:44,080 --> 00:30:47,430 I have this tiny little thing that doesn't matter-- 503 00:30:47,430 --> 00:30:50,200 is bigger than or equal to M? 504 00:30:50,200 --> 00:30:54,790 So I can solve for n now by subtracting the delta term, 505 00:30:54,790 --> 00:30:57,300 multiplying by square root of 5. 506 00:30:57,300 --> 00:31:02,260 That gives me the golden ratio to the n-th power 507 00:31:02,260 --> 00:31:06,240 bigger than or equal to square root 5 times 508 00:31:06,240 --> 00:31:08,050 M minus the tiny thing. 509 00:31:10,800 --> 00:31:14,040 Now I take logs. 510 00:31:14,040 --> 00:31:21,450 And I'm in trouble when n is bigger than or equal to log 511 00:31:21,450 --> 00:31:30,825 of this over log of the base. 512 00:31:38,710 --> 00:31:41,070 In other words, this is theta. 513 00:31:41,070 --> 00:31:42,550 What's this theta of here? 514 00:31:45,830 --> 00:31:48,500 That goes away. 515 00:31:48,500 --> 00:31:50,434 I can skip all the constant factors. 516 00:31:50,434 --> 00:31:52,225 What's this theta of here, this expression, 517 00:31:52,225 --> 00:31:56,224 in terms of theta of something to do with some function of M? 518 00:31:56,224 --> 00:31:57,220 AUDIENCE: Log of M? 519 00:31:57,220 --> 00:32:02,910 PROFESSOR: Log of M. So the jobs get filled in log of M years. 520 00:32:02,910 --> 00:32:05,250 And in fact, if I plugged in, for example, 521 00:32:05,250 --> 00:32:07,810 M equals 10,000 into this expression, 522 00:32:07,810 --> 00:32:09,290 I would find that all the jobs are 523 00:32:09,290 --> 00:32:12,540 filled in 20 years, which is more or less what 524 00:32:12,540 --> 00:32:14,780 happened in computer science. 525 00:32:14,780 --> 00:32:18,221 Ballpark, those numbers are roughly correct. 526 00:32:18,221 --> 00:32:18,720 All right? 527 00:32:18,720 --> 00:32:21,530 But you can solve it exactly now by just plugging in whatever M 528 00:32:21,530 --> 00:32:22,490 you want. 529 00:32:22,490 --> 00:32:23,870 That's a fraction less than 1/10. 530 00:32:23,870 --> 00:32:25,286 And you can solve to find out when 531 00:32:25,286 --> 00:32:26,973 your population gets that big. 532 00:32:29,851 --> 00:32:30,350 OK. 533 00:32:30,350 --> 00:32:30,933 Any questions? 534 00:32:36,410 --> 00:32:36,910 OK. 535 00:32:36,910 --> 00:32:39,250 So now what I want to do is show you 536 00:32:39,250 --> 00:32:43,495 how to use this same idea to solve any linear recurrence, 537 00:32:43,495 --> 00:32:45,620 and this is the process you'll go through to do it. 538 00:33:01,625 --> 00:33:02,310 All right. 539 00:33:02,310 --> 00:33:06,420 So we're going to solve a general linear recurrence. 540 00:33:20,040 --> 00:33:27,440 So in this case, we've got f of n is the sum from i 541 00:33:27,440 --> 00:33:30,590 equals 1 to d, for an order d recurrence, 542 00:33:30,590 --> 00:33:34,530 a sub i f of n minus i. 543 00:33:34,530 --> 00:33:38,280 And we've got to have boundary conditions. 544 00:33:38,280 --> 00:33:46,570 So we'll have f of 0 is b0, f of 1 is b1. 545 00:33:46,570 --> 00:33:48,100 And how many boundary conditions do 546 00:33:48,100 --> 00:33:49,599 you think I'm going to need to have? 547 00:33:49,599 --> 00:33:51,790 Any guesses? 548 00:33:51,790 --> 00:33:54,242 I had two for Fibonacci. 549 00:33:54,242 --> 00:33:56,320 In this case, I've got d terms. 550 00:33:56,320 --> 00:33:57,059 AUDIENCE: d. 551 00:33:57,059 --> 00:33:57,600 PROFESSOR: d. 552 00:33:57,600 --> 00:33:59,266 I'm going to need d boundary conditions. 553 00:33:59,266 --> 00:34:03,650 So we'll go all the way to f of d minus 1 554 00:34:03,650 --> 00:34:05,370 equal to b of d minus 1. 555 00:34:07,992 --> 00:34:08,780 All right? 556 00:34:08,780 --> 00:34:16,839 And now I'm going to try f of n is alpha to the n. 557 00:34:16,839 --> 00:34:20,989 We're going to plug it into this expression. 558 00:34:20,989 --> 00:34:25,090 And then when we do, we get alpha to the n 559 00:34:25,090 --> 00:34:31,480 equals a1 alpha to the n minus 1 plus 560 00:34:31,480 --> 00:34:37,360 a2 alpha to the n minus 2 all the way down to a sub 561 00:34:37,360 --> 00:34:44,310 d alpha to the n minus d. 562 00:34:44,310 --> 00:34:44,810 All right? 563 00:34:44,810 --> 00:34:47,280 Just plugging into there. 564 00:34:47,280 --> 00:34:50,790 I can divide everything by alpha to the n minus d, 565 00:34:50,790 --> 00:34:54,290 and that gives me alpha to the d equals 566 00:34:54,290 --> 00:35:04,320 a1 alpha to the d minus 1 a2 alpha to the d minus 2 ad times 567 00:35:04,320 --> 00:35:08,760 alpha to the 0, which is just 1. 568 00:35:08,760 --> 00:35:12,805 And I can rewrite this as a polynomial equal to 0. 569 00:35:22,800 --> 00:35:26,255 So that means that alpha to the d minus 570 00:35:26,255 --> 00:35:34,420 a1 alpha to the d minus 1 minus a2 alpha to the d minus 2 571 00:35:34,420 --> 00:35:38,600 minus ad is 0. 572 00:35:38,600 --> 00:35:41,460 This is called the characteristic equation 573 00:35:41,460 --> 00:35:42,210 of the recurrence. 574 00:35:56,770 --> 00:35:58,490 OK? 575 00:35:58,490 --> 00:36:03,590 Now, what you need to do is compute the roots of this, 576 00:36:03,590 --> 00:36:08,610 and we'll use the roots to get the solution to the recurrence. 577 00:36:08,610 --> 00:36:10,780 Now, the simple case is when all the roots 578 00:36:10,780 --> 00:36:15,120 are different-- so let's do that first-- like there 579 00:36:15,120 --> 00:36:16,530 was in the Fibonacci example. 580 00:36:21,440 --> 00:36:30,280 All d roots are different, and let's call 581 00:36:30,280 --> 00:36:33,440 them alpha 1 to alpha d. 582 00:36:39,610 --> 00:36:44,070 In that case, the solution is all linear combinations 583 00:36:44,070 --> 00:36:49,490 of their n-th powers, just like it 584 00:36:49,490 --> 00:36:56,180 was with Fibonacci without the boundary conditions. 585 00:36:56,180 --> 00:37:00,040 c1 alpha 1 to the n plus c2 alpha 2 586 00:37:00,040 --> 00:37:08,580 to the n plus cd alpha d to the n. 587 00:37:08,580 --> 00:37:09,080 All right? 588 00:37:09,080 --> 00:37:11,340 Same thing happens that happened in Fibonacci, 589 00:37:11,340 --> 00:37:14,780 that this becomes the solution before the boundary 590 00:37:14,780 --> 00:37:16,690 conditions are applied. 591 00:37:16,690 --> 00:37:17,190 All right? 592 00:37:30,500 --> 00:37:33,730 And by the way, if your characteristic equation has 593 00:37:33,730 --> 00:37:36,930 imaginary roots, that's fine. 594 00:37:36,930 --> 00:37:39,480 It doesn't matter because the imaginary i 595 00:37:39,480 --> 00:37:41,900 term will disappear just like the square root of 5 596 00:37:41,900 --> 00:37:43,350 disappeared. 597 00:37:43,350 --> 00:37:49,130 Has to because we know f of n, in this case, is a real number. 598 00:37:49,130 --> 00:37:51,110 All right? 599 00:37:51,110 --> 00:37:51,610 OK. 600 00:37:51,610 --> 00:37:54,600 Now, to find out the values of the coefficients, what 601 00:37:54,600 --> 00:37:57,710 are we going to do? 602 00:37:57,710 --> 00:37:58,710 What is it? 603 00:37:58,710 --> 00:37:59,960 AUDIENCE: Boundary conditions. 604 00:37:59,960 --> 00:38:01,490 PROFESSOR: Boundary conditions, yep. 605 00:38:01,490 --> 00:38:13,870 So now we solve for c1, c2, cd from the boundary conditions. 606 00:38:13,870 --> 00:38:20,270 That is, f of i is b of i for i from 0 to d. 607 00:38:23,030 --> 00:38:28,960 So for example, we know that f of 0 608 00:38:28,960 --> 00:38:35,650 is c1 times alpha 1 to the 0, which is 1, c2 alpha 2 609 00:38:35,650 --> 00:38:40,480 to the 0 plus cd. 610 00:38:40,480 --> 00:38:45,950 And that's going to be equal to b0 and so forth. 611 00:38:45,950 --> 00:38:48,600 So you get a system of equations, d equations 612 00:38:48,600 --> 00:38:53,820 in d variables, that you solve to find the coefficients. 613 00:38:53,820 --> 00:38:57,170 And that will give the unique and correct solution 614 00:38:57,170 --> 00:39:00,360 to the recurrence. 615 00:39:00,360 --> 00:39:00,860 All right? 616 00:39:00,860 --> 00:39:05,620 Now, turns out this system of equations is never degenerate. 617 00:39:05,620 --> 00:39:07,550 It always has a solution. 618 00:39:07,550 --> 00:39:11,860 And you can prove that, but we won't do that. 619 00:39:11,860 --> 00:39:17,760 Any questions about how to do that? 620 00:39:17,760 --> 00:39:18,420 All right. 621 00:39:18,420 --> 00:39:19,209 Yeah? 622 00:39:19,209 --> 00:39:21,083 AUDIENCE: Sorry, I just had a quick question. 623 00:39:21,083 --> 00:39:25,700 But what exactly was the distance there between n and d? 624 00:39:25,700 --> 00:39:29,710 d is like the degree of-- which the terms you go back to. 625 00:39:29,710 --> 00:39:35,260 PROFESSOR: Yes, Yeah. d is how far back you're going. 626 00:39:35,260 --> 00:39:39,339 You go as far back as f of n minus d. 627 00:39:39,339 --> 00:39:39,880 AUDIENCE: OK. 628 00:39:39,880 --> 00:39:40,340 Cool. 629 00:39:40,340 --> 00:39:41,965 PROFESSOR: And that becomes the degree, 630 00:39:41,965 --> 00:39:45,177 and that is a constant-- 2, 3, 4. 631 00:39:45,177 --> 00:39:47,510 Well, I don't think we'll ever ask you anything beyond 4 632 00:39:47,510 --> 00:39:49,660 because it gets to be a pain to do. 633 00:39:49,660 --> 00:39:53,450 Typically, it's 2 or 3, sometimes even just 1. 634 00:39:53,450 --> 00:39:55,450 And then that becomes the power of 635 00:39:55,450 --> 00:39:58,010 your characteristic equation. 636 00:39:58,010 --> 00:40:01,797 It's the order of the characteristic equation. 637 00:40:01,797 --> 00:40:02,630 Any other questions? 638 00:40:05,240 --> 00:40:05,740 All right. 639 00:40:05,740 --> 00:40:08,550 That was the nice case where all the roots 640 00:40:08,550 --> 00:40:11,660 of your characteristic equation were different. 641 00:40:11,660 --> 00:40:14,625 If they're not all different, it's a little more complicated. 642 00:40:33,380 --> 00:40:42,010 So the tricky case is repeated roots. 643 00:40:49,320 --> 00:40:54,550 Now, the theorem, which we won't prove but tells you what to do, 644 00:40:54,550 --> 00:41:10,460 is that if alpha is a root of the characteristic equation 645 00:41:10,460 --> 00:41:16,530 and it is repeated r times-- so x minus alpha to the r-th power 646 00:41:16,530 --> 00:41:39,576 is a factor-- then alpha to the n, n times alpha to the n, 647 00:41:39,576 --> 00:41:43,350 n squared times alpha to the n, all the way up 648 00:41:43,350 --> 00:41:47,790 to n to the r minus 1 times alpha to the n 649 00:41:47,790 --> 00:41:49,570 are all solutions to the recurrence. 650 00:42:04,460 --> 00:42:04,960 All right? 651 00:42:04,960 --> 00:42:07,090 And then you would treat them just 652 00:42:07,090 --> 00:42:08,420 as you would the other roots. 653 00:42:08,420 --> 00:42:10,380 You take linear combinations, just 654 00:42:10,380 --> 00:42:13,560 like you did with the other roots to put it all together. 655 00:42:17,470 --> 00:42:22,020 By the way, is anybody starting to recognize a similarity 656 00:42:22,020 --> 00:42:24,615 with something else that you've studied in the past? 657 00:42:24,615 --> 00:42:25,990 AUDIENCE: Differential equations. 658 00:42:25,990 --> 00:42:27,910 PROFESSOR: Differential equations. 659 00:42:27,910 --> 00:42:32,550 This is the discrete analog of differential equations. 660 00:42:32,550 --> 00:42:33,050 All right? 661 00:42:33,050 --> 00:42:35,390 Recurrences is the same thing. 662 00:42:35,390 --> 00:42:37,450 All the math we're going to do henceforth 663 00:42:37,450 --> 00:42:39,840 is going to look just like what you did 664 00:42:39,840 --> 00:42:42,409 with differential equations. 665 00:42:42,409 --> 00:42:44,950 So that's sort of good news and, I guess, bad news, depending 666 00:42:44,950 --> 00:42:45,820 on whether you like that stuff. 667 00:42:45,820 --> 00:42:46,612 AUDIENCE: Bad news. 668 00:42:46,612 --> 00:42:47,445 PROFESSOR: Bad news. 669 00:42:47,445 --> 00:42:48,020 Yeah, OK. 670 00:42:51,810 --> 00:42:54,520 All right, let's do an example that uses maybe 671 00:42:54,520 --> 00:42:57,480 the repeated roots case. 672 00:42:57,480 --> 00:43:00,140 Suppose there's a plant out there, 673 00:43:00,140 --> 00:43:04,510 and this plant lives forever but only reproduces 674 00:43:04,510 --> 00:43:08,070 in the first year of life and then never again. 675 00:43:08,070 --> 00:43:11,000 And it reproduces one for one. 676 00:43:11,000 --> 00:43:11,500 All right? 677 00:43:11,500 --> 00:43:13,530 Let's see what happens in that case. 678 00:43:19,890 --> 00:43:22,310 Actually, there's a plant sort of like this in Hawaii. 679 00:43:22,310 --> 00:43:27,517 I think it's called the century plant, and it's rare. 680 00:43:27,517 --> 00:43:29,225 We'll see why when we solve this problem. 681 00:43:31,990 --> 00:43:46,290 So it reproduces one for one during the first year of life, 682 00:43:46,290 --> 00:43:56,825 then never again, and the plant lives forever. 683 00:44:05,500 --> 00:44:10,951 So our question is, how fast does the plant population grow? 684 00:44:10,951 --> 00:44:11,450 All right? 685 00:44:11,450 --> 00:44:15,010 In year n, how many plants there are. 686 00:44:15,010 --> 00:44:18,035 So to figure that out, we're going to set up a recurrence. 687 00:44:21,200 --> 00:44:26,330 We're going to let f of n be the number of plants in year n. 688 00:44:33,150 --> 00:44:36,610 And we're going to say that the first plant miraculously comes 689 00:44:36,610 --> 00:44:39,090 into existence in year 1. 690 00:44:39,090 --> 00:44:43,060 So that in year 0 there's none of them, and in year 1 691 00:44:43,060 --> 00:44:45,512 there's 1. 692 00:44:45,512 --> 00:44:47,720 And now we want to know how many there are in year n. 693 00:45:05,540 --> 00:45:06,070 OK. 694 00:45:06,070 --> 00:45:07,361 So let's set up the recurrence. 695 00:45:10,190 --> 00:45:15,200 f of n equals-- well, the previous year, 696 00:45:15,200 --> 00:45:20,155 how many plants were there in terms of f? 697 00:45:20,155 --> 00:45:21,030 AUDIENCE: [INAUDIBLE] 698 00:45:21,030 --> 00:45:23,300 PROFESSOR: f of n minus 1. 699 00:45:23,300 --> 00:45:23,800 All right? 700 00:45:23,800 --> 00:45:25,341 That's how many there were last year, 701 00:45:25,341 --> 00:45:27,120 and they're all still alive, plus 702 00:45:27,120 --> 00:45:31,360 we've got to add the number of new plants. 703 00:45:31,360 --> 00:45:34,810 Well, that would be-- yeah, well, 704 00:45:34,810 --> 00:45:36,330 how many new plants are there? 705 00:45:36,330 --> 00:45:40,560 It's all the plants that were one-year-old last year. 706 00:45:40,560 --> 00:45:44,650 So that's all the ones that were alive 707 00:45:44,650 --> 00:45:47,370 last year minus the ones that were alive the year before. 708 00:45:50,450 --> 00:45:52,850 That's how many new plants there were last year, 709 00:45:52,850 --> 00:45:56,186 and they each produce 1 new one this year. 710 00:45:56,186 --> 00:45:56,915 Is that OK? 711 00:45:56,915 --> 00:45:57,706 Everybody buy that? 712 00:46:00,265 --> 00:46:00,765 OK. 713 00:46:03,500 --> 00:46:10,020 So that equals 2 f of n minus 1 minus f of n minus 2. 714 00:46:14,840 --> 00:46:16,280 OK. 715 00:46:16,280 --> 00:46:19,148 What's my characteristic equation for this recurrence? 716 00:46:24,140 --> 00:46:24,680 Yeah? 717 00:46:24,680 --> 00:46:29,440 AUDIENCE: Alpha squared minus 2 alpha plus 1. 718 00:46:29,440 --> 00:46:31,344 PROFESSOR: Yes. 719 00:46:31,344 --> 00:46:32,180 OK? 720 00:46:32,180 --> 00:46:39,931 alpha squared minus 2 alpha plus 1. 721 00:46:39,931 --> 00:46:40,430 All right? 722 00:46:40,430 --> 00:46:41,730 We jumped to that answer. 723 00:46:41,730 --> 00:46:45,863 I could have written down alpha to the n minus 2 times alpha 724 00:46:45,863 --> 00:46:49,139 to the n minus 1 plus alpha to the n minus 2 725 00:46:49,139 --> 00:46:50,930 and then divided by alpha to the n minus 2. 726 00:46:50,930 --> 00:46:54,570 But pretty quickly, you want to start just reading it off. 727 00:46:54,570 --> 00:46:56,420 That's the characteristic equation. 728 00:46:56,420 --> 00:46:58,760 I get alpha squared, and then bringing this over, 729 00:46:58,760 --> 00:47:03,000 a minus 2 alpha, bring this over, plus 1 equals 0. 730 00:47:05,680 --> 00:47:10,000 Any questions on that? 731 00:47:10,000 --> 00:47:11,790 This is the process now you will always 732 00:47:11,790 --> 00:47:13,420 use that we're going through. 733 00:47:13,420 --> 00:47:13,920 All right. 734 00:47:13,920 --> 00:47:15,294 What are the roots to this thing? 735 00:47:18,117 --> 00:47:20,200 What are the roots to the characteristic equation? 736 00:47:20,200 --> 00:47:24,184 AUDIENCE: Alpha minus 1 [INAUDIBLE]. 737 00:47:24,184 --> 00:47:24,850 PROFESSOR: Yeah. 738 00:47:24,850 --> 00:47:26,850 Alpha minus 1 times alpha minus 1 739 00:47:26,850 --> 00:47:29,300 is 0, which means alpha equals? 740 00:47:29,300 --> 00:47:29,800 AUDIENCE: 1. 741 00:47:29,800 --> 00:47:30,830 PROFESSOR: 1. 742 00:47:30,830 --> 00:47:37,590 So the roots are alpha equals 1, and it's a double root. 743 00:47:37,590 --> 00:47:39,070 OK? 744 00:47:39,070 --> 00:47:40,040 It's a double root. 745 00:47:40,040 --> 00:47:48,110 It occurs twice because this is alpha minus 1 squared. 746 00:47:48,110 --> 00:47:49,550 OK. 747 00:47:49,550 --> 00:47:54,590 So what solutions am I going to use to my recurrence? 748 00:48:00,330 --> 00:48:04,350 What's f of n going to be now before I 749 00:48:04,350 --> 00:48:07,466 put in the boundary conditions? 750 00:48:07,466 --> 00:48:13,516 Well, it's going to be c1 times what to the n? 751 00:48:13,516 --> 00:48:14,448 AUDIENCE: 1. 752 00:48:14,448 --> 00:48:15,140 PROFESSOR: 1. 753 00:48:15,140 --> 00:48:16,960 That's the first root. 754 00:48:16,960 --> 00:48:17,600 What's here? 755 00:48:17,600 --> 00:48:21,780 What's the next thing I'm going to put here? 756 00:48:21,780 --> 00:48:22,740 AUDIENCE: [INAUDIBLE]. 757 00:48:22,740 --> 00:48:24,555 PROFESSOR: n times 1 to the n. 758 00:48:24,555 --> 00:48:27,540 All right? 759 00:48:27,540 --> 00:48:30,150 Because I've got a root that's repeated twice, 760 00:48:30,150 --> 00:48:34,790 r equals 2, so I have alpha to the n and n alpha to the n. 761 00:48:34,790 --> 00:48:37,435 Just happens alpha's 1, which makes it really easy. 762 00:48:39,770 --> 00:48:40,270 All right? 763 00:48:40,270 --> 00:48:43,000 So this is now my solution before the boundary conditions. 764 00:48:46,270 --> 00:48:48,630 In fact, that gets even simpler. 765 00:48:48,630 --> 00:48:49,130 That's 1. 766 00:48:49,130 --> 00:48:51,308 That's c1 plus c2 times n. 767 00:48:54,520 --> 00:48:56,025 And now all that's left is to plug 768 00:48:56,025 --> 00:48:57,150 in the boundary conditions. 769 00:49:10,680 --> 00:49:14,140 So let's do that. 770 00:49:14,140 --> 00:49:17,225 Well, f of 0 equals 0. 771 00:49:21,330 --> 00:49:23,514 If I plug it into here, what happens for f of 0? 772 00:49:23,514 --> 00:49:24,430 What does that become? 773 00:49:24,430 --> 00:49:25,800 AUDIENCE: [INAUDIBLE]. 774 00:49:25,800 --> 00:49:27,430 PROFESSOR: C1. 775 00:49:27,430 --> 00:49:28,690 So c1 equals 0. 776 00:49:28,690 --> 00:49:29,990 That's good. 777 00:49:29,990 --> 00:49:32,990 f of 1 equals 1. 778 00:49:32,990 --> 00:49:37,060 And now that's going to be c1 plus c2. 779 00:49:37,060 --> 00:49:40,570 c1 is 0, so it means c2 equals 1. 780 00:49:43,031 --> 00:49:43,530 All right. 781 00:49:43,530 --> 00:49:45,390 So this is really easy. 782 00:49:45,390 --> 00:49:48,430 What's f of n equal? 783 00:49:48,430 --> 00:49:50,520 n. 784 00:49:50,520 --> 00:49:53,593 So we went through a lot of work to get an answer that probably 785 00:49:53,593 --> 00:49:55,940 we could have guessed pretty easily by just 786 00:49:55,940 --> 00:49:58,107 plugging in a few examples. 787 00:49:58,107 --> 00:50:00,190 But the nice thing is this works for all the cases 788 00:50:00,190 --> 00:50:05,890 when it's not so easy to guess by plugging in the examples. 789 00:50:05,890 --> 00:50:09,850 Yeah, now you can see why this is a relatively rare plant. 790 00:50:09,850 --> 00:50:12,080 Its population is growing very slowly. 791 00:50:14,990 --> 00:50:15,540 OK. 792 00:50:15,540 --> 00:50:17,140 Any questions about that? 793 00:50:17,140 --> 00:50:18,140 That had repeated roots. 794 00:50:21,790 --> 00:50:22,520 All right. 795 00:50:22,520 --> 00:50:23,020 Yeah? 796 00:50:23,020 --> 00:50:24,700 AUDIENCE: So we just guessed that f of n 797 00:50:24,700 --> 00:50:26,890 is equal to alpha to the n, and we 798 00:50:26,890 --> 00:50:29,680 don't know if that works for like different [INAUDIBLE]. 799 00:50:29,680 --> 00:50:32,170 But how do you know that it works until you plug it in? 800 00:50:32,170 --> 00:50:35,170 If you tried it out [INAUDIBLE]? 801 00:50:35,170 --> 00:50:37,294 PROFESSOR: Yeah. 802 00:50:37,294 --> 00:50:38,710 We didn't go through and prove it. 803 00:50:38,710 --> 00:50:42,750 We used some facts along the way that we didn't prove, 804 00:50:42,750 --> 00:50:43,590 which you can do. 805 00:50:43,590 --> 00:50:47,100 Like, in particular, the fact we didn't prove that theorem there 806 00:50:47,100 --> 00:50:48,800 that those will be the roots. 807 00:50:48,800 --> 00:50:50,940 And we didn't prove that any linear combination 808 00:50:50,940 --> 00:50:52,781 would be a solution. 809 00:50:52,781 --> 00:50:55,280 But those are facts you could take from-- you could actually 810 00:50:55,280 --> 00:50:55,779 prove them. 811 00:50:55,779 --> 00:50:57,490 They're not too hard to prove. 812 00:50:57,490 --> 00:50:59,760 But otherwise, I think we went through every step 813 00:50:59,760 --> 00:51:01,031 and narrowed it in. 814 00:51:01,031 --> 00:51:02,530 If we wanted to be really sure, we'd 815 00:51:02,530 --> 00:51:03,990 go back and prove it by induction 816 00:51:03,990 --> 00:51:06,020 against the original recurrence. 817 00:51:06,020 --> 00:51:10,030 And we'd say this would be the induction hypothesis. 818 00:51:10,030 --> 00:51:12,930 We'd cover the base cases-- f of 0 and f of 1. 819 00:51:12,930 --> 00:51:16,610 And then we'd plug this into the recurrence up there, 820 00:51:16,610 --> 00:51:22,050 which is, does n equal twice n minus 1 minus n minus 2, 821 00:51:22,050 --> 00:51:23,100 is what we would do. 822 00:51:23,100 --> 00:51:24,790 And you see that it's true. 823 00:51:24,790 --> 00:51:29,000 So you could really prove it by induction 824 00:51:29,000 --> 00:51:30,720 for any of the solutions we ever get. 825 00:51:30,720 --> 00:51:33,740 And if you worked this way to get the solution, 826 00:51:33,740 --> 00:51:35,390 it will always work. 827 00:51:35,390 --> 00:51:38,172 This method never fails, gives you the wrong answer. 828 00:51:38,172 --> 00:51:39,630 In fact, that's an important point. 829 00:51:39,630 --> 00:51:41,963 When we tell you to solve a recurrence using this method 830 00:51:41,963 --> 00:51:45,450 on an exam or for homework, you don't 831 00:51:45,450 --> 00:51:47,460 have to verify it by induction unless we 832 00:51:47,460 --> 00:51:49,550 say verify by induction. 833 00:51:49,550 --> 00:51:51,130 Because we're giving you a method 834 00:51:51,130 --> 00:51:52,540 that is guaranteed to work. 835 00:51:52,540 --> 00:51:55,220 And if you do the method right, you're fine. 836 00:51:55,220 --> 00:51:57,960 There's no guessing here so far. 837 00:51:57,960 --> 00:52:00,440 In a minute, we're going to do a little guessing, 838 00:52:00,440 --> 00:52:03,573 but not so far. 839 00:52:03,573 --> 00:52:04,406 Any other questions? 840 00:52:07,670 --> 00:52:10,100 OK. 841 00:52:10,100 --> 00:52:17,301 This works for all homogeneous linear recurrences. 842 00:52:17,301 --> 00:52:17,800 All right? 843 00:52:17,800 --> 00:52:19,615 Remember homogeneous and inhomogeneous 844 00:52:19,615 --> 00:52:22,450 from differential equations? 845 00:52:22,450 --> 00:52:23,940 It's the same thing happens here. 846 00:52:31,600 --> 00:52:34,037 And now we're going to talk about the inhomogeneous case. 847 00:52:41,950 --> 00:52:42,450 All right. 848 00:52:42,450 --> 00:52:48,100 So we've been looking at linear recurrences, which 849 00:52:48,100 --> 00:52:54,450 means you have something like f of n minus a1 f of n minus 1 850 00:52:54,450 --> 00:53:01,892 minus ad f of n minus d equals 0, 851 00:53:01,892 --> 00:53:03,225 and that means it's homogeneous. 852 00:53:09,170 --> 00:53:11,930 Now, instead of 0, I might have had something else 853 00:53:11,930 --> 00:53:14,930 here, might have been equal to 1, 854 00:53:14,930 --> 00:53:21,040 maybe n squared, or some general function g of n. 855 00:53:21,040 --> 00:53:22,953 These cases are all inhomogeneous. 856 00:53:30,430 --> 00:53:31,800 OK? 857 00:53:31,800 --> 00:53:35,570 Now, solving inhomogeneous linear equations 858 00:53:35,570 --> 00:53:38,250 is just one step harder than homogeneous. 859 00:53:38,250 --> 00:53:38,750 Yeah? 860 00:53:38,750 --> 00:53:39,583 AUDIENCE: All right. 861 00:53:39,583 --> 00:53:41,577 Could you define homogeneous and inhomogeneous 862 00:53:41,577 --> 00:53:43,660 for people who didn't take differential equations? 863 00:53:43,660 --> 00:53:44,326 PROFESSOR: Yeah. 864 00:53:44,326 --> 00:53:49,170 Homogeneous means you have the 0 here. 865 00:53:49,170 --> 00:53:52,720 You got all these f terms here, right, 866 00:53:52,720 --> 00:53:54,380 and there's nothing else. 867 00:53:54,380 --> 00:53:57,940 f of n minus a1 f n minus 1 dot dot dot 868 00:53:57,940 --> 00:54:01,590 minus ad f n minus d equals 0. 869 00:54:01,590 --> 00:54:05,610 Like with Fibonacci numbers-- f of n minus f n 870 00:54:05,610 --> 00:54:09,640 minus 1 minus f n minus 2 is 0. 871 00:54:09,640 --> 00:54:11,250 OK? 872 00:54:11,250 --> 00:54:14,710 I could consider other recurrences 873 00:54:14,710 --> 00:54:17,770 where there's something else out here that it equals. 874 00:54:17,770 --> 00:54:19,550 Like I could have a Fibonacci recurrence 875 00:54:19,550 --> 00:54:23,300 where I have f(n) equals f of n minus 1 plus f(n) minus 2 876 00:54:23,300 --> 00:54:26,780 plus g of n, like n cubed. 877 00:54:26,780 --> 00:54:29,820 That would give me a Fibonacci-like recurrence. 878 00:54:29,820 --> 00:54:32,680 And as soon as you put a non-zero out here, 879 00:54:32,680 --> 00:54:34,775 then it's inhomogeneous. 880 00:54:34,775 --> 00:54:36,150 And now I'm going to tell you how 881 00:54:36,150 --> 00:54:37,960 to solve that kind of recurrence, 882 00:54:37,960 --> 00:54:41,460 which is more general. 883 00:54:41,460 --> 00:54:41,960 OK? 884 00:54:44,642 --> 00:54:45,142 OK. 885 00:54:48,905 --> 00:54:51,363 So let me outline the method, and then we'll do an example. 886 00:55:02,220 --> 00:55:02,840 All right. 887 00:55:02,840 --> 00:55:23,330 So the general inhomogeneous recurrence is exactly this. 888 00:55:23,330 --> 00:55:32,280 It's f of n minus a1 f of n minus 1 minus a sub d f of n 889 00:55:32,280 --> 00:55:38,270 minus d equals g of n, where that's some fixed function 890 00:55:38,270 --> 00:55:39,770 of n, nothing to do with f. 891 00:55:42,550 --> 00:55:46,240 And we solve it according to the following three-step method. 892 00:55:49,200 --> 00:55:59,280 In step 1, we replace g of n by 0, 893 00:55:59,280 --> 00:56:03,464 thereby creating the situation we already know how to solve. 894 00:56:06,330 --> 00:56:11,450 And we solve the homogeneous recurrence-- 895 00:56:11,450 --> 00:56:25,220 because you got a 0 there now-- but we don't go all the way. 896 00:56:25,220 --> 00:56:27,720 We ignore the boundary conditions for now. 897 00:56:35,321 --> 00:56:37,320 So you don't get all the way to the final answer 898 00:56:37,320 --> 00:56:39,420 where you plugged in the boundary conditions 899 00:56:39,420 --> 00:56:41,510 to get the constant coefficients. 900 00:56:41,510 --> 00:56:45,510 Leave the constant coefficients undecided. 901 00:56:45,510 --> 00:56:55,420 Then in step 2, we put back in g of n, 902 00:56:55,420 --> 00:57:05,880 and we find any what's called particular solution, again 903 00:57:05,880 --> 00:57:08,126 ignoring boundary conditions. 904 00:57:08,126 --> 00:57:10,392 So you'll have the constant factors there too. 905 00:57:20,141 --> 00:57:20,640 All right? 906 00:57:20,640 --> 00:57:24,990 And then step 3 is going to be to put the whole thing together 907 00:57:24,990 --> 00:57:27,371 and plug in the boundary conditions and solve it. 908 00:57:35,330 --> 00:57:41,675 So we add the homogeneous and particular-- 909 00:57:41,675 --> 00:57:54,420 and I'll show you how to do step 2 in a minute-- 910 00:57:54,420 --> 00:58:05,930 so we add the homogeneous and particular solutions together 911 00:58:05,930 --> 00:58:08,570 and then use the boundary conditions to get the answer. 912 00:58:30,560 --> 00:58:31,060 OK. 913 00:58:31,060 --> 00:58:32,110 So let's do an example. 914 00:58:35,750 --> 00:58:38,370 Let's go down here and do an example of the three steps. 915 00:58:57,480 --> 00:59:00,780 So let's say that our recurrence is 916 00:59:00,780 --> 00:59:09,190 this nasty-looking thing-- f of n equals 4 f of n minus 1 917 00:59:09,190 --> 00:59:12,850 plus 3 to the n. 918 00:59:12,850 --> 00:59:19,240 And the boundary condition is that f of 1 is 1. 919 00:59:19,240 --> 00:59:24,800 So step 1 says, ignore this 3 to the n thing 920 00:59:24,800 --> 00:59:28,130 and get back to just the homogeneous form, which 921 00:59:28,130 --> 00:59:32,490 is f of n minus 4 f of n minus 1 is 0. 922 00:59:32,490 --> 00:59:33,720 So let's solve that. 923 00:59:33,720 --> 00:59:36,720 What's the characteristic equation 924 00:59:36,720 --> 00:59:41,062 for the homogeneous part? 925 00:59:41,062 --> 00:59:42,520 What's the characteristic equation? 926 00:59:45,789 --> 00:59:46,723 What is it? 927 00:59:46,723 --> 00:59:49,012 AUDIENCE: Alpha [INAUDIBLE]. 928 00:59:49,012 --> 00:59:49,720 PROFESSOR: Close. 929 00:59:49,720 --> 00:59:52,873 It's-- you could either say alpha to the n minus 4 alpha 930 00:59:52,873 --> 00:59:54,780 to the n minus 1. 931 00:59:54,780 --> 00:59:59,080 But better to simplify it into an order 1 polynomial. 932 00:59:59,080 --> 01:00:04,470 So it would be alpha minus 4, really simple in this case. 933 01:00:04,470 --> 01:00:06,950 So the characteristic equation is alpha minus 4, 934 01:00:06,950 --> 01:00:12,850 alpha minus 4, all right, equals 0. 935 01:00:12,850 --> 01:00:16,600 And it's really easy to find the root of this thing. 936 01:00:16,600 --> 01:00:20,840 It's just alpha equals 4 is your only root. 937 01:00:20,840 --> 01:00:27,040 And that means the homogeneous solution 938 01:00:27,040 --> 01:00:32,134 is f of n equals a constant times 4 to the n. 939 01:00:34,761 --> 01:00:35,260 All right? 940 01:00:35,260 --> 01:00:36,150 So that's step 1. 941 01:00:43,670 --> 01:00:44,360 OK. 942 01:00:44,360 --> 01:00:48,155 Let's do step 2, which we've not tried before. 943 01:00:51,910 --> 01:00:56,830 We need to find a particular solution, 944 01:00:56,830 --> 01:01:04,520 and this just means any old solution 945 01:01:04,520 --> 01:01:13,590 to f of n minus 4 f of n minus 1 equals 3 to the n, 946 01:01:13,590 --> 01:01:15,970 without worrying about boundary conditions. 947 01:01:15,970 --> 01:01:21,395 Now, there's basic rules to use to figure out 948 01:01:21,395 --> 01:01:23,690 what to guess here. 949 01:01:23,690 --> 01:01:30,210 And basically, the idea is that you guess something for f of n 950 01:01:30,210 --> 01:01:34,800 that looks a whole lot like this g term out here. 951 01:01:34,800 --> 01:01:38,070 And in particular, if this g term is 3 to the n, 952 01:01:38,070 --> 01:01:41,270 you guess a constant times 3 to the n. 953 01:01:41,270 --> 01:01:44,680 If it's 5 to the n, you guess a constant times 5 to the n. 954 01:01:44,680 --> 01:01:49,420 If it's n squared, you guess a polynomial that's of degree 2 955 01:01:49,420 --> 01:01:51,590 and so forth. 956 01:01:51,590 --> 01:01:52,090 OK? 957 01:01:52,090 --> 01:01:58,920 So let's guess a constant times 3 to the n 958 01:01:58,920 --> 01:02:01,560 and see if we can make it work, not 959 01:02:01,560 --> 01:02:03,452 worrying about the boundary conditions. 960 01:02:13,890 --> 01:02:16,346 All right. 961 01:02:16,346 --> 01:02:20,220 And this is just like differential equations, right? 962 01:02:20,220 --> 01:02:22,400 Same guessing strategy exactly you 963 01:02:22,400 --> 01:02:26,250 use in differential equations, those of you who've had that. 964 01:02:26,250 --> 01:02:31,840 So we guess f of n equals a constant times 3 to the n, 965 01:02:31,840 --> 01:02:34,320 and let's plug it in. 966 01:02:34,320 --> 01:02:37,640 So we plug that in up there. 967 01:02:37,640 --> 01:02:44,300 We get c3 to the n minus c3 to the n minus 1 968 01:02:44,300 --> 01:02:47,601 equals 3 to the n. 969 01:02:47,601 --> 01:02:48,100 All right? 970 01:02:48,100 --> 01:02:50,240 So let's divide by 3 to the n here. 971 01:02:50,240 --> 01:02:56,710 We get 3c minus c equals 3. 972 01:02:56,710 --> 01:02:58,570 Did I do that right? 973 01:02:58,570 --> 01:03:01,815 No, I left off my 4 here, right, left off that. 974 01:03:01,815 --> 01:03:02,830 So there's a 4 here. 975 01:03:06,150 --> 01:03:10,900 And that means that c is minus 3. 976 01:03:10,900 --> 01:03:11,400 OK? 977 01:03:11,400 --> 01:03:15,600 So I got minus c equals 3, so c is minus 3. 978 01:03:15,600 --> 01:03:16,100 All right. 979 01:03:16,100 --> 01:03:27,860 That means that the particular solution is just f of n 980 01:03:27,860 --> 01:03:36,060 equals-- c is minus 3-- minus 3 to the n plus 1. 981 01:03:36,060 --> 01:03:36,560 All right? 982 01:03:36,560 --> 01:03:41,370 So now I found a solution where there's no constants involved. 983 01:03:41,370 --> 01:03:43,780 This time, the constant went away just 984 01:03:43,780 --> 01:03:46,830 plugging into the recurrence formula. 985 01:03:46,830 --> 01:03:49,130 I didn't use base cases yet. 986 01:03:49,130 --> 01:03:51,050 I just found a particular case that 987 01:03:51,050 --> 01:03:56,980 works for the recurrence-- minus 3 to the n plus 1. 988 01:03:56,980 --> 01:03:59,492 OK? 989 01:03:59,492 --> 01:04:01,430 All right. 990 01:04:01,430 --> 01:04:02,546 Now we go to step 3. 991 01:04:19,300 --> 01:04:19,800 All right. 992 01:04:19,800 --> 01:04:30,670 Step 3, we find the general solution 993 01:04:30,670 --> 01:04:33,520 by adding the homogeneous and the particular solution. 994 01:04:37,850 --> 01:04:43,810 So we take f of n equals c1 times 995 01:04:43,810 --> 01:04:50,790 4 to the n plus negative 3 to the n plus 1. 996 01:04:55,350 --> 01:04:58,660 And all I've got to do is determine c1, 997 01:04:58,660 --> 01:05:01,894 and I do that from the boundary conditions. 998 01:05:01,894 --> 01:05:02,560 Yeah, let's see. 999 01:05:02,560 --> 01:05:05,800 Where was my boundary condition here? 1000 01:05:05,800 --> 01:05:09,580 Ah, up there-- f of 1 is 1. 1001 01:05:09,580 --> 01:05:12,690 So f of 1 equals 1. 1002 01:05:12,690 --> 01:05:15,760 Plugging in 1 here, I get c1 times 4 1003 01:05:15,760 --> 01:05:21,430 to the 1 minus 3 squared. 1004 01:05:21,430 --> 01:05:21,930 All right? 1005 01:05:21,930 --> 01:05:25,120 So I have 4c1 minus 9. 1006 01:05:25,120 --> 01:05:30,100 Put the 9 over here, I get 10 equals 4c1. 1007 01:05:30,100 --> 01:05:32,905 And that means that c1 is 5/2. 1008 01:05:37,570 --> 01:05:39,870 And now I know the final solution for f(n). 1009 01:05:44,170 --> 01:05:49,845 It's 5/2 4 to the n minus 3 to the n plus 1. 1010 01:05:56,650 --> 01:05:58,244 Now, when you're all done with this, 1011 01:05:58,244 --> 01:05:59,660 you don't have-- we won't make you 1012 01:05:59,660 --> 01:06:03,579 do an inductive proof, which you could do to verify it's right. 1013 01:06:03,579 --> 01:06:05,370 If you wanted to be really, really careful, 1014 01:06:05,370 --> 01:06:06,950 you should do that. 1015 01:06:06,950 --> 01:06:10,952 But it is a good idea just to check a couple values of n 1016 01:06:10,952 --> 01:06:13,535 to make sure you didn't make a mistake because you might have. 1017 01:06:13,535 --> 01:06:16,440 With all these calculations, you might have made a mistake. 1018 01:06:16,440 --> 01:06:20,200 So let's check, for example, f of 2. 1019 01:06:23,000 --> 01:06:30,300 So by the recurrence, f of 2 is 4 times 1020 01:06:30,300 --> 01:06:39,960 f of 1-- it's 4 times 1-- plus 3 squared, which is 9, is 13. 1021 01:06:39,960 --> 01:06:43,790 And let's just check when we plug in 2 here. 1022 01:06:43,790 --> 01:06:52,590 f of 2 is 5/2 times 16 minus 27. 1023 01:06:52,590 --> 01:06:57,210 5 times 8 is 40, minus 27 is 13. 1024 01:06:57,210 --> 01:06:58,920 Just as a sanity check. 1025 01:06:58,920 --> 01:07:01,170 Because there's a decent chance if you made a mistake, 1026 01:07:01,170 --> 01:07:04,240 it'll catch it pretty quick with n equals 2 or 3. 1027 01:07:04,240 --> 01:07:04,740 All right? 1028 01:07:04,740 --> 01:07:07,880 Just to make sure you got it right. 1029 01:07:07,880 --> 01:07:14,280 Any questions about that? 1030 01:07:14,280 --> 01:07:16,630 So the tricky part here is guessing 1031 01:07:16,630 --> 01:07:18,730 the particular solution. 1032 01:07:18,730 --> 01:07:24,250 So let me give you the rules for that, just write those down, 1033 01:07:24,250 --> 01:07:26,100 and maybe I'll do one last example. 1034 01:07:40,320 --> 01:07:40,820 All right. 1035 01:07:40,820 --> 01:07:43,950 So we're guessing a particular solution. 1036 01:07:56,740 --> 01:08:03,570 So if g-- that's saying the non-homogeneous part-- 1037 01:08:03,570 --> 01:08:14,660 is exponential, you should try guessing an exponential 1038 01:08:14,660 --> 01:08:15,880 of the same type. 1039 01:08:20,740 --> 01:08:31,050 So for example, say that g is 2 to the n plus 3 to the n. 1040 01:08:31,050 --> 01:08:37,050 What you should do is guess some constant a times 2 to the n 1041 01:08:37,050 --> 01:08:40,279 plus some constant b times 3 to the n. 1042 01:08:40,279 --> 01:08:43,340 Plug it in-- not to the boundary conditions. 1043 01:08:43,340 --> 01:08:47,520 Plug it into the recurrence equation and solve for a and b. 1044 01:08:47,520 --> 01:08:50,939 And it generally will work. 1045 01:08:50,939 --> 01:09:00,450 If g is polynomial, you should guess a polynomial 1046 01:09:00,450 --> 01:09:01,420 of the same degree. 1047 01:09:07,840 --> 01:09:21,109 So for example, say g of n is n squared minus 1. 1048 01:09:21,109 --> 01:09:33,050 You should guess-- let's see-- guess an squared 1049 01:09:33,050 --> 01:09:36,229 plus bn plus c. 1050 01:09:36,229 --> 01:09:38,951 Plug that in for f of n. 1051 01:09:38,951 --> 01:09:39,450 All right? 1052 01:09:39,450 --> 01:09:44,186 So when we're doing these guesses, we're guessing f of n. 1053 01:09:44,186 --> 01:09:45,668 Same thing up here. 1054 01:10:07,930 --> 01:10:10,800 Now, say you mixed two together. 1055 01:10:10,800 --> 01:10:15,130 Suppose you have an example where g of n 1056 01:10:15,130 --> 01:10:18,710 equals 2 to the n plus n. 1057 01:10:18,710 --> 01:10:22,359 What do you suppose you do in that case? 1058 01:10:22,359 --> 01:10:24,190 AUDIENCE: [INAUDIBLE] to guess [INAUDIBLE]. 1059 01:10:24,190 --> 01:10:27,660 PROFESSOR: Yeah, guess each one separately, add them together. 1060 01:10:27,660 --> 01:10:33,550 So you're going to guess f of n equals a times 2 1061 01:10:33,550 --> 01:10:37,530 to the n plus bn plus c. 1062 01:10:37,530 --> 01:10:38,110 All right? 1063 01:10:38,110 --> 01:10:40,610 Because you take the guess for that plus the guess for that. 1064 01:10:44,050 --> 01:10:44,560 All right. 1065 01:10:44,560 --> 01:10:48,540 Now, there's one last thing that can go wrong here. 1066 01:10:48,540 --> 01:10:53,841 And that is you can try your guess, and it doesn't work. 1067 01:10:53,841 --> 01:10:54,340 All right? 1068 01:10:54,340 --> 01:10:55,940 So there's rules for that too. 1069 01:10:58,460 --> 01:11:06,140 For example, if, say, g(n) is 2 to the n 1070 01:11:06,140 --> 01:11:13,440 and your guess of a times 2 to the n, where a is a constant, 1071 01:11:13,440 --> 01:11:14,575 fails. 1072 01:11:14,575 --> 01:11:17,800 And we'll do an example in a minute where it fails. 1073 01:11:17,800 --> 01:11:22,900 What you do then is you guess a polynomial times 2 to the n. 1074 01:11:22,900 --> 01:11:28,630 So you'd guess an plus b times 2 to the n. 1075 01:11:28,630 --> 01:11:32,370 And if that fails, your next guess 1076 01:11:32,370 --> 01:11:39,130 would be an squared plus bn plus c times 2 to the n. 1077 01:11:39,130 --> 01:11:41,670 And it won't happen, but if that failed, 1078 01:11:41,670 --> 01:11:43,820 you'd guess a cubic times 2 to the n. 1079 01:11:43,820 --> 01:11:47,480 You keep pounding it with another factor of n in front 1080 01:11:47,480 --> 01:11:50,030 if the guess fails. 1081 01:11:50,030 --> 01:11:52,260 And that's true for anything at all 1082 01:11:52,260 --> 01:11:55,167 you would be doing like this, and that'll work. 1083 01:11:55,167 --> 01:11:57,500 And I don't think I've ever encountered an example where 1084 01:11:57,500 --> 01:12:00,760 you have to go very far to make that fly. 1085 01:12:04,180 --> 01:12:06,260 Same thing we had for repeated roots 1086 01:12:06,260 --> 01:12:09,310 in the characteristic equation. 1087 01:12:09,310 --> 01:12:11,610 Multiply those factors of n in front of it 1088 01:12:11,610 --> 01:12:13,811 to get to the answer. 1089 01:12:13,811 --> 01:12:14,310 All right. 1090 01:12:14,310 --> 01:12:17,210 Let's do one more example where it fails, 1091 01:12:17,210 --> 01:12:18,832 so we get to see what happens. 1092 01:12:39,970 --> 01:12:48,470 Let's try this recurrence-- f of n is 2 f of n minus 1 1093 01:12:48,470 --> 01:12:51,400 plus 2 to the n. 1094 01:12:51,400 --> 01:12:56,870 And the boundary condition is f of 0 is 1. 1095 01:12:56,870 --> 01:13:02,090 What's the first thing I do for this? 1096 01:13:02,090 --> 01:13:04,450 AUDIENCE: Set it equal to 0. 1097 01:13:04,450 --> 01:13:06,515 PROFESSOR: Set it equal to 0 and solve it. 1098 01:13:06,515 --> 01:13:07,962 Get the homogeneous solution. 1099 01:13:13,240 --> 01:13:13,820 OK. 1100 01:13:13,820 --> 01:13:16,740 So what's the characteristic polynomial? 1101 01:13:20,290 --> 01:13:24,520 Alpha minus 2 is 0. 1102 01:13:24,520 --> 01:13:26,541 What's my root? 1103 01:13:26,541 --> 01:13:27,040 2. 1104 01:13:29,790 --> 01:13:33,550 And therefore, my homogeneous solution 1105 01:13:33,550 --> 01:13:36,460 is c1 times 2 to the n. 1106 01:13:36,460 --> 01:13:38,900 Well, that's pretty simple. 1107 01:13:38,900 --> 01:13:39,892 What's the next step? 1108 01:13:43,860 --> 01:13:45,983 What do I have to find next? 1109 01:13:45,983 --> 01:13:46,858 AUDIENCE: Particular. 1110 01:13:46,858 --> 01:13:48,334 PROFESSOR: Particular solution. 1111 01:13:52,762 --> 01:13:53,270 All right. 1112 01:13:53,270 --> 01:13:55,282 So what am I going to guess? 1113 01:14:00,210 --> 01:14:01,690 a times 2 to the n. 1114 01:14:04,260 --> 01:14:05,340 All right? 1115 01:14:05,340 --> 01:14:08,110 So let's plug that in, a times 2 to the n. 1116 01:14:08,110 --> 01:14:10,720 I'm going to plug it in to here. 1117 01:14:10,720 --> 01:14:18,100 So I get a 2 to the n equals 2 times a times 2 1118 01:14:18,100 --> 01:14:23,200 to the n minus 1 plus 2 to the n. 1119 01:14:23,200 --> 01:14:24,760 Did I do that right? 1120 01:14:24,760 --> 01:14:27,190 Think so. 1121 01:14:27,190 --> 01:14:29,962 So I get 2 to the n, 2 to the n, 2 to the n. 1122 01:14:29,962 --> 01:14:36,040 I get a equals a plus 1. 1123 01:14:36,040 --> 01:14:38,510 Not so good. 1124 01:14:38,510 --> 01:14:39,650 All right? 1125 01:14:39,650 --> 01:14:42,586 There's no solution for a. 1126 01:14:42,586 --> 01:14:44,181 Well, that's bad. 1127 01:14:44,181 --> 01:14:44,680 All right. 1128 01:14:44,680 --> 01:14:45,960 So what do I do? 1129 01:14:52,701 --> 01:14:54,576 Any thoughts about what I'm going to do next? 1130 01:14:57,414 --> 01:14:58,360 AUDIENCE: [INAUDIBLE]. 1131 01:14:58,360 --> 01:14:58,940 PROFESSOR: What is it? 1132 01:14:58,940 --> 01:15:00,240 AUDIENCE: Change your guess. 1133 01:15:00,240 --> 01:15:01,200 PROFESSOR: Change the guess. 1134 01:15:01,200 --> 01:15:02,616 What's the next guess going to be? 1135 01:15:06,780 --> 01:15:07,580 Yeah, all right. 1136 01:15:07,580 --> 01:15:18,630 So now I'm going to guess f of n is an plus b 2 to the n. 1137 01:15:18,630 --> 01:15:19,840 We'll hope for better luck. 1138 01:15:19,840 --> 01:15:23,020 So let's plug that in. 1139 01:15:23,020 --> 01:15:32,100 an plus b 2 to the n into-- where am I, up there-- 1140 01:15:32,100 --> 01:15:42,013 equals 2 a n minus 1 plus b times 2 to the n minus 1 plus 2 1141 01:15:42,013 --> 01:15:44,435 to the n. 1142 01:15:44,435 --> 01:15:45,130 All right. 1143 01:15:45,130 --> 01:15:48,325 Now, I can divide out the 2 to the n's here like I did before. 1144 01:15:51,000 --> 01:16:04,510 And I get an plus b equals an minus a plus b plus 1. 1145 01:16:04,510 --> 01:16:09,240 That cancels here, b cancels. 1146 01:16:09,240 --> 01:16:13,511 So I got a solution-- a equals 1. 1147 01:16:13,511 --> 01:16:15,500 And I don't care what b is. 1148 01:16:15,500 --> 01:16:17,910 I didn't need to set it to anything. 1149 01:16:17,910 --> 01:16:20,880 So I'll make it 0 just to get it out of the way 1150 01:16:20,880 --> 01:16:22,960 because it didn't matter. 1151 01:16:22,960 --> 01:16:31,375 So my particular solution then is f of n-- a is 1. 1152 01:16:31,375 --> 01:16:34,370 b I can just make 0 because it didn't matter what I used, 1153 01:16:34,370 --> 01:16:35,790 so I'll make it simpler. 1154 01:16:35,790 --> 01:16:38,634 So I get n 2 to the n. 1155 01:16:38,634 --> 01:16:39,884 That's my particular solution. 1156 01:16:42,810 --> 01:16:46,190 And I've got my general solution up there as c1 times 2 1157 01:16:46,190 --> 01:16:48,830 to the n-- sorry, the homogeneous solution. 1158 01:16:51,530 --> 01:16:53,339 What's the next step? 1159 01:16:59,207 --> 01:17:00,300 What's step 3? 1160 01:17:04,570 --> 01:17:07,955 What do I do with these guys, this solution 1161 01:17:07,955 --> 01:17:09,387 and that solution? 1162 01:17:09,387 --> 01:17:10,532 [? AUDIENCE: Add them. ?] 1163 01:17:10,532 --> 01:17:11,740 PROFESSOR: Add them together. 1164 01:17:11,740 --> 01:17:12,240 Good. 1165 01:17:12,240 --> 01:17:23,380 So the general solution is I have f of n is the sum of c1 2 1166 01:17:23,380 --> 01:17:27,700 to the n plus the particular solutions n 2 to the n. 1167 01:17:27,700 --> 01:17:31,189 How do I figure out what c1 is? 1168 01:17:31,189 --> 01:17:32,730 AUDIENCE: Plugging in to [INAUDIBLE]. 1169 01:17:32,730 --> 01:17:37,050 PROFESSOR: Plugging in the boundary condition-- f(0) 1170 01:17:37,050 --> 01:17:38,275 equals 1. 1171 01:17:38,275 --> 01:17:40,400 f(0) equals 1. 1172 01:17:40,400 --> 01:17:47,240 Plug in 0, I get c1 2 to the 0 plus 0. 1173 01:17:47,240 --> 01:17:51,390 Well, that's pretty easy. c1 equals 1. 1174 01:17:51,390 --> 01:17:54,230 So I now have the final answer. 1175 01:17:54,230 --> 01:17:59,940 f of n equals 2 to the n plus n 2 to the n. 1176 01:17:59,940 --> 01:18:00,777 All right? 1177 01:18:00,777 --> 01:18:01,360 Any questions? 1178 01:18:05,730 --> 01:18:06,230 OK. 1179 01:18:06,230 --> 01:18:09,740 So it's a little tedious to do this. 1180 01:18:09,740 --> 01:18:12,560 But the really nice thing is any linear recurrence 1181 01:18:12,560 --> 01:18:17,390 you ever see, this method always works, which is handy. 1182 01:18:17,390 --> 01:18:17,890 OK. 1183 01:18:17,890 --> 01:18:20,040 That's it for today.