WEBVTT
00:00:00.499 --> 00:00:02.830
The following content is
provided under a Creative
00:00:02.830 --> 00:00:04.340
Commons license.
00:00:04.340 --> 00:00:06.680
Your support will help
MIT OpenCourseWare
00:00:06.680 --> 00:00:11.050
continue to offer high-quality
educational resources for free.
00:00:11.050 --> 00:00:13.670
To make a donation or
view additional materials
00:00:13.670 --> 00:00:17.555
from hundreds of MIT courses,
visit MIT OpenCourseWare
00:00:17.555 --> 00:00:18.180
at ocw.mit.edu.
00:00:22.745 --> 00:00:23.620
PROFESSOR: All right.
00:00:23.620 --> 00:00:25.960
So last time we
talked about methods
00:00:25.960 --> 00:00:28.040
for solving recurrences,
and we spent
00:00:28.040 --> 00:00:31.624
most of our time talking about
divide-and-conquer recurrences.
00:00:31.624 --> 00:00:33.790
These are recurrences where
you break the problem up
00:00:33.790 --> 00:00:37.210
into much smaller sub-problems,
like half the size
00:00:37.210 --> 00:00:39.570
or 2/3 the size.
00:00:39.570 --> 00:00:41.690
And they come up quite a
bit in computer science
00:00:41.690 --> 00:00:45.150
when you're doing algorithm
design and algorithm analysis.
00:00:45.150 --> 00:00:46.720
Today, we're going
to spend our time
00:00:46.720 --> 00:00:48.880
talking about a different
kind of recurrence that's
00:00:48.880 --> 00:00:50.770
called a linear recurrence.
00:00:50.770 --> 00:00:52.610
They also come up
in computer science
00:00:52.610 --> 00:00:55.360
and a lot of other fields.
00:00:55.360 --> 00:00:57.390
Now, I'm going to give
you the formal definition
00:00:57.390 --> 00:00:59.650
of a linear recurrence later.
00:00:59.650 --> 00:01:02.990
First I want to start
with an example,
00:01:02.990 --> 00:01:05.480
and this is an example of a
linear recurrence that comes up
00:01:05.480 --> 00:01:06.800
in population modeling.
00:01:06.800 --> 00:01:10.260
In fact, it comes up
in a lot of places.
00:01:10.260 --> 00:01:13.460
And to start it off, we're going
to analyze a particular problem
00:01:13.460 --> 00:01:16.760
that we call the
graduate student job
00:01:16.760 --> 00:01:21.810
problem or the graduate
student job nightmare.
00:01:21.810 --> 00:01:26.150
And the question here
is, will your TAs
00:01:26.150 --> 00:01:28.350
be able to get a job as
a professor somewhere
00:01:28.350 --> 00:01:29.425
when they get their PhD?
00:01:36.100 --> 00:01:39.040
So this is a problem
they worry about a lot.
00:01:39.040 --> 00:01:43.280
And the idea in this problem is
that there's some discipline,
00:01:43.280 --> 00:01:45.270
say computer science.
00:01:45.270 --> 00:01:48.310
And if you look in all the
universities in the world,
00:01:48.310 --> 00:01:51.640
there's M faculty lines.
00:01:51.640 --> 00:02:02.790
So the total number of jobs is
M, and that's a fixed value.
00:02:02.790 --> 00:02:04.690
Because of budgetary
constraints,
00:02:04.690 --> 00:02:07.330
universities aren't
growing, and so they're not
00:02:07.330 --> 00:02:10.680
going to create more computer
science faculty positions.
00:02:10.680 --> 00:02:12.680
It's going to stay
fixed over time.
00:02:19.900 --> 00:02:22.990
So it's a constant.
00:02:22.990 --> 00:02:29.610
And every year, professors
generate more graduates
00:02:29.610 --> 00:02:31.680
who become professors.
00:02:31.680 --> 00:02:35.830
And in particular, we're going
to assume that in this field
00:02:35.830 --> 00:02:39.130
every professor
graduates 1 student who
00:02:39.130 --> 00:02:43.650
goes on to become a professor,
or tries to if there's jobs.
00:02:43.650 --> 00:02:54.910
So each professor
generates 1 graduate
00:02:54.910 --> 00:03:00.740
who becomes a new professor, as
long as there's jobs, per year.
00:03:03.460 --> 00:03:07.280
With one exception, and
that's first-year professors
00:03:07.280 --> 00:03:09.760
because they're too busy
learning how to teach,
00:03:09.760 --> 00:03:12.540
getting grants, doing
administrative stuff,
00:03:12.540 --> 00:03:14.682
just figuring out
how it all works.
00:03:14.682 --> 00:03:16.890
So they don't have time to
produce any grad students.
00:03:23.510 --> 00:03:27.830
So first year or new professors
don't produce anything.
00:03:33.340 --> 00:03:37.105
Except first-year profs--
oops, let me correct that.
00:03:43.280 --> 00:03:44.750
So first-year profs have 0.
00:03:53.340 --> 00:03:56.130
Now, matters are made
worse by the fact
00:03:56.130 --> 00:03:59.280
that Congress passed a
law, and this is true,
00:03:59.280 --> 00:04:04.730
that more or less bars mandatory
retirements in colleges.
00:04:04.730 --> 00:04:09.780
And so that means there are no
retirements in this problem,
00:04:09.780 --> 00:04:14.150
and we're going to assume
the faculty live forever.
00:04:14.150 --> 00:04:16.870
And so once you fill a
position, it's filled forever.
00:04:16.870 --> 00:04:18.160
It doesn't exist anymore.
00:04:18.160 --> 00:04:21.149
In fact, if you walk
around the math department,
00:04:21.149 --> 00:04:23.150
you can see the impact of this.
00:04:23.150 --> 00:04:23.650
[LAUGHTER]
00:04:23.650 --> 00:04:29.347
I think the median age
is now well into the 70s.
00:04:29.347 --> 00:04:31.680
And there will be actually a
phenomenon over the next 10
00:04:31.680 --> 00:04:35.150
years as the math faculty
progress into their 80s
00:04:35.150 --> 00:04:38.044
where they actually, in reality,
probably do start to retire.
00:04:38.044 --> 00:04:39.460
And there will be
a whole new wave
00:04:39.460 --> 00:04:42.460
of people hired in mathematics,
just as happened back
00:04:42.460 --> 00:04:45.720
in the '50s and '60s after
the Sputnik crisis where
00:04:45.720 --> 00:04:47.810
a lot of mathematicians
were hired.
00:04:47.810 --> 00:04:50.700
And then they stayed in those
positions, for our purposes,
00:04:50.700 --> 00:04:52.530
forever.
00:04:52.530 --> 00:04:56.380
Now, the question is, when
do all the jobs get filled?
00:05:04.640 --> 00:05:09.130
So when are all M jobs
filled by this process?
00:05:12.830 --> 00:05:14.600
Now, to be able to
answer this question,
00:05:14.600 --> 00:05:18.790
we need one more
piece of information.
00:05:18.790 --> 00:05:21.296
Can anybody think
about one more fact
00:05:21.296 --> 00:05:23.670
here that we need before we
start going off and answering
00:05:23.670 --> 00:05:26.380
this question, analyzing it?
00:05:26.380 --> 00:05:26.880
Yeah?
00:05:26.880 --> 00:05:28.580
AUDIENCE: How many
professors do we start with?
00:05:28.580 --> 00:05:30.580
PROFESSOR: How many
professors do we start with?
00:05:30.580 --> 00:05:32.320
What's the boundary condition?
00:05:32.320 --> 00:05:35.300
What's the base case if we
were doing an induction?
00:05:35.300 --> 00:05:35.800
All right.
00:05:35.800 --> 00:05:45.280
So let's say the
boundary condition,
00:05:45.280 --> 00:05:48.170
and this always is
important with recurrences,
00:05:48.170 --> 00:05:53.346
is that the first professor
is hired in year 1,
00:05:53.346 --> 00:05:54.970
and there were none
before that person.
00:05:59.190 --> 00:05:59.690
All right?
00:05:59.690 --> 00:06:01.339
So in year 1
there's 1 professor,
00:06:01.339 --> 00:06:02.380
and that professor's new.
00:06:04.680 --> 00:06:05.180
OK.
00:06:05.180 --> 00:06:06.650
So now we have all
the information
00:06:06.650 --> 00:06:08.990
necessary to solve the problem.
00:06:08.990 --> 00:06:11.025
So let's do that and
set up a recurrence.
00:06:16.290 --> 00:06:25.770
We're going to define f of n
to be the number of professors
00:06:25.770 --> 00:06:26.570
during year n.
00:06:31.880 --> 00:06:35.700
And we know from our boundary
condition that in year 0
00:06:35.700 --> 00:06:43.330
there were none, and in year
1 there was 1, a new one.
00:06:43.330 --> 00:06:47.230
What is f of 2?
00:06:47.230 --> 00:06:50.360
How many professors
are there in year 2?
00:06:50.360 --> 00:06:51.327
AUDIENCE: 1.
00:06:51.327 --> 00:06:53.160
PROFESSOR: 1, because
the one that was there
00:06:53.160 --> 00:06:54.368
was too young to do anything.
00:06:54.368 --> 00:06:59.540
So he or she is the only one
left, all right, in year 2.
00:06:59.540 --> 00:07:01.370
What is f of 3?
00:07:01.370 --> 00:07:05.000
How many profs are
there in year 3?
00:07:05.000 --> 00:07:08.870
2-- the one you had, and by that
point that one is old enough
00:07:08.870 --> 00:07:12.045
to produce a new one.
00:07:12.045 --> 00:07:12.590
All right.
00:07:12.590 --> 00:07:13.910
What's f of 4?
00:07:16.542 --> 00:07:18.360
AUDIENCE: 3.
00:07:18.360 --> 00:07:20.890
PROFESSOR: 3, the 2
you had, and there
00:07:20.890 --> 00:07:23.520
was one who's been there 2
years to produce a new one.
00:07:27.901 --> 00:07:28.400
All right.
00:07:28.400 --> 00:07:33.008
And let's do one more, f of 5?
00:07:33.008 --> 00:07:33.507
AUDIENCE: 5.
00:07:33.507 --> 00:07:35.050
PROFESSOR: 5.
00:07:35.050 --> 00:07:41.120
These guys produced 1 each,
and you had 3 existing.
00:07:41.120 --> 00:07:41.770
All right.
00:07:41.770 --> 00:07:44.680
So we can actually write
down the recurrence now
00:07:44.680 --> 00:07:49.840
by sort of the process
we just went through.
00:07:49.840 --> 00:07:55.850
For years 2 and beyond, the
number of professors in year n
00:07:55.850 --> 00:07:59.240
is the number that we
had last year-- that's
00:07:59.240 --> 00:08:05.190
the previous ones-- plus the
number that were generated,
00:08:05.190 --> 00:08:08.900
new professors, the graduate
students that graduated.
00:08:08.900 --> 00:08:11.250
In terms of f, how many
new ones are there?
00:08:11.250 --> 00:08:12.830
AUDIENCE: f of n minus 2.
00:08:12.830 --> 00:08:14.580
PROFESSOR: f of n
minus 2, because that's
00:08:14.580 --> 00:08:17.080
the number of professors that
were there a couple years ago,
00:08:17.080 --> 00:08:19.150
and they are now
generating them.
00:08:19.150 --> 00:08:23.200
So that's the new ones there.
00:08:23.200 --> 00:08:26.720
Do people recognize
that recurrence?
00:08:26.720 --> 00:08:28.390
Yeah, it's pretty famous.
00:08:28.390 --> 00:08:29.810
How many people have not seen?
00:08:29.810 --> 00:08:31.525
This is called the
Fibonacci recurrence.
00:08:31.525 --> 00:08:33.720
It produces the
Fibonacci numbers.
00:08:33.720 --> 00:08:36.480
How many people
have not seen it?
00:08:36.480 --> 00:08:37.640
Yeah, very famous.
00:08:37.640 --> 00:08:40.780
Yeah, pretty much
everybody has seen that.
00:08:40.780 --> 00:08:43.280
Actually, this is
the first recurrence
00:08:43.280 --> 00:08:47.020
that was known to be
studied of all recurrences.
00:08:47.020 --> 00:08:51.260
It was published by
Leonardo Fibonacci of Pisa
00:08:51.260 --> 00:08:55.620
in 1202, all right,
so over 800 years ago,
00:08:55.620 --> 00:08:59.120
and he studied it for
modeling the population
00:08:59.120 --> 00:09:00.680
growth of rabbits.
00:09:00.680 --> 00:09:04.450
And the idea is that you
have a pair of rabbits,
00:09:04.450 --> 00:09:06.880
and in every month
after their first year
00:09:06.880 --> 00:09:08.910
of life-- sorry,
first month of life--
00:09:08.910 --> 00:09:11.221
they produce two new rabbits.
00:09:11.221 --> 00:09:11.720
All right?
00:09:11.720 --> 00:09:13.053
So it's the same notion as here.
00:09:13.053 --> 00:09:15.630
The first pair you do
nothing, but after that you're
00:09:15.630 --> 00:09:18.450
reproducing one for one.
00:09:18.450 --> 00:09:20.480
And that's an
abstraction, but it
00:09:20.480 --> 00:09:24.170
produces the same recurrence.
00:09:24.170 --> 00:09:27.440
Now, Fibonacci is credited
with discovering it.
00:09:27.440 --> 00:09:30.010
Really that means he's the
one that told the Europeans
00:09:30.010 --> 00:09:31.680
about it back then.
00:09:31.680 --> 00:09:35.800
And in fact, it's now been
traced back in to about 200 BC.
00:09:35.800 --> 00:09:37.900
The Indian
mathematicians knew all
00:09:37.900 --> 00:09:40.950
about Fibonacci's
recurrence, and they
00:09:40.950 --> 00:09:44.410
were using it to study certain
properties of grammar and music
00:09:44.410 --> 00:09:47.190
way back at 200 BC.
00:09:47.190 --> 00:09:50.150
This recurrence comes up in
all sorts of applications.
00:09:50.150 --> 00:09:52.710
Kepler used it in
the 16th century
00:09:52.710 --> 00:09:55.900
while studying how
the leaves of a flower
00:09:55.900 --> 00:09:58.460
are arranged around the
stem-- how many leaves
00:09:58.460 --> 00:10:02.270
you have in sort of each level
coming out around a stem.
00:10:02.270 --> 00:10:05.820
The first solution was
discovered by de Moivre
00:10:05.820 --> 00:10:06.654
in the 18th century.
00:10:06.654 --> 00:10:09.153
And we're going to talk about
how to solve this in a minute.
00:10:09.153 --> 00:10:11.500
But he was the first one
to figure out a closed form
00:10:11.500 --> 00:10:13.840
expression for f of n.
00:10:13.840 --> 00:10:16.270
Lame used it in the
19th century when
00:10:16.270 --> 00:10:19.170
he was studying the
Euclidean GCD algorithm.
00:10:19.170 --> 00:10:21.990
You know that pulverizer
thing and doing GCDs?
00:10:21.990 --> 00:10:25.690
It turns out that if you want
to analyze the running time,
00:10:25.690 --> 00:10:27.920
well, you get a Fibonacci
recurrence comes
00:10:27.920 --> 00:10:31.720
into play there, and that was
discovered in the 19th century.
00:10:31.720 --> 00:10:34.980
In the 20th century, it was
used in the study of optics,
00:10:34.980 --> 00:10:38.470
economics, and algorithms, and
it was named for Fibonacci.
00:10:38.470 --> 00:10:41.540
It got a name in
the 19th century.
00:10:41.540 --> 00:10:43.570
In fact, this is
so popular and used
00:10:43.570 --> 00:10:47.200
in so many places there is a
journal in mathematics called
00:10:47.200 --> 00:10:49.560
the Fibonacci Quarterly
Journal where they
00:10:49.560 --> 00:10:53.087
study these kinds of things.
00:10:53.087 --> 00:10:55.420
So today what we're going to
do is solve this recurrence
00:10:55.420 --> 00:10:58.060
and actually solve a much
broader family of recurrences
00:10:58.060 --> 00:11:01.370
called linear recurrences.
00:11:01.370 --> 00:11:02.980
And we're going to
get a closed form.
00:11:02.980 --> 00:11:05.021
I mean, you can produce
the Fibonacci numbers one
00:11:05.021 --> 00:11:07.880
after another, but we're
going to derive a formula
00:11:07.880 --> 00:11:11.041
for the n-th Fibonacci number.
00:11:11.041 --> 00:11:12.540
And when we're going
to do it, we're
00:11:12.540 --> 00:11:16.710
going to do it more broadly for
a class of linear recurrences.
00:11:16.710 --> 00:11:18.155
So let me define what that is.
00:11:23.950 --> 00:11:32.740
So a recurrence is
said to be linear
00:11:32.740 --> 00:11:47.500
if it is of the form f of n
equals a constant a1 times
00:11:47.500 --> 00:11:55.570
f of n minus 1 plus a2 times
f of n minus 2 plus dot dot
00:11:55.570 --> 00:12:02.800
dot d'th constant ad
times f of n minus d.
00:12:02.800 --> 00:12:06.440
And we could simplify
that as the sum
00:12:06.440 --> 00:12:14.590
i equals 1 to d of a sub
i times f of n minus i.
00:12:14.590 --> 00:12:19.190
And the constants
are fixed here,
00:12:19.190 --> 00:12:25.280
so for fixed a sub i and d.
00:12:25.280 --> 00:12:27.420
So the number of terms
has to be a constant,
00:12:27.420 --> 00:12:30.510
and each coefficient
has to be a constant.
00:12:30.510 --> 00:12:32.030
Can't vary.
00:12:32.030 --> 00:12:36.870
And we define d to be the
order of the recurrence.
00:12:36.870 --> 00:12:40.300
So d is the order
of the recurrence.
00:12:42.820 --> 00:12:44.790
OK?
00:12:44.790 --> 00:12:47.095
And you can see, of course,
that Fibonacci's recurrence
00:12:47.095 --> 00:12:48.660
is linear.
00:12:48.660 --> 00:12:51.080
What's its order?
00:12:51.080 --> 00:12:52.190
2.
00:12:52.190 --> 00:12:54.880
And the coefficients,
the a's, are just 1.
00:12:54.880 --> 00:12:58.410
So it's a simple
linear recurrence.
00:12:58.410 --> 00:12:58.910
All right.
00:12:58.910 --> 00:13:00.790
So let's see how to solve it.
00:13:00.790 --> 00:13:02.330
Well, actually,
before we do that,
00:13:02.330 --> 00:13:05.390
can you see the difference
between this recurrence,
00:13:05.390 --> 00:13:08.140
linear, and divide-and-conquer
recurrences?
00:13:11.180 --> 00:13:13.050
Right?
00:13:13.050 --> 00:13:16.120
What do I have here inside for
a divide-and-conquer recurrence?
00:13:19.400 --> 00:13:21.640
I get a fraction of n, right?
00:13:21.640 --> 00:13:23.630
And here, I'm
subtracting a constant
00:13:23.630 --> 00:13:26.730
from n, usually like 1,
2, 3, an integer from n.
00:13:26.730 --> 00:13:30.940
So linear is when inside you
have n minus 1, n minus 2.
00:13:30.940 --> 00:13:33.945
Divide and conquer,
you got n/2 or 3/4 n.
00:13:33.945 --> 00:13:37.992
And it makes a huge
difference in the solution.
00:13:37.992 --> 00:13:38.780
All right.
00:13:38.780 --> 00:13:41.529
So what I'm going to do is
give you a closed-form solution
00:13:41.529 --> 00:13:42.820
for these kinds of recurrences.
00:13:42.820 --> 00:13:47.690
And it won't be completely
easy because it took Europeans
00:13:47.690 --> 00:13:51.501
six centuries to find
the solution to this.
00:13:51.501 --> 00:13:52.000
Right?
00:13:52.000 --> 00:13:53.720
Fibonacci discovers
the thing in 1200
00:13:53.720 --> 00:13:55.210
and tells everybody about it.
00:13:55.210 --> 00:13:58.305
And it wasn't until
600 years later
00:13:58.305 --> 00:14:00.620
that they figured out
a closed-form solution.
00:14:03.824 --> 00:14:04.920
So let's do that.
00:14:08.040 --> 00:14:11.480
Now, what we're going to
do to do it this first time
00:14:11.480 --> 00:14:13.610
ourselves, and we
don't have the formula,
00:14:13.610 --> 00:14:15.750
is to use guess and verify.
00:14:15.750 --> 00:14:17.620
So we're going to
guess a solution
00:14:17.620 --> 00:14:19.750
and check that it works.
00:14:19.750 --> 00:14:23.030
And we're going to guess,
really, a class of solutions.
00:14:23.030 --> 00:14:29.966
We're going to try f of n is
an exponential in n, alpha
00:14:29.966 --> 00:14:32.180
to the n for some
constant alpha.
00:14:38.310 --> 00:14:40.590
Now, we're going
to figure out what
00:14:40.590 --> 00:14:45.130
alpha is as we go along during
the verification process.
00:14:45.130 --> 00:14:45.630
All right?
00:14:45.630 --> 00:14:50.830
So let's try to verify
this guess and plug it in.
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.
00:14:56.595 --> 00:15:00.120
Well, let's plug that
in and see what we get.
00:15:00.120 --> 00:15:03.310
That gives us alpha to the
n equals alpha to the n
00:15:03.310 --> 00:15:08.880
minus 1 plus alpha
to the n minus 2.
00:15:08.880 --> 00:15:09.710
All right?
00:15:09.710 --> 00:15:15.300
Now, that means I can divide
by alpha to the n minus 2,
00:15:15.300 --> 00:15:20.920
and I get alpha squared
equals alpha plus 1.
00:15:20.920 --> 00:15:25.220
And now I can use the quadratic
formula to solve for alpha.
00:15:25.220 --> 00:15:25.720
All right?
00:15:25.720 --> 00:15:30.550
That means that alpha
squared minus alpha minus 1
00:15:30.550 --> 00:15:38.760
equals 0, which means that
alpha equals-- minus minus 1
00:15:38.760 --> 00:15:42.680
is 1 plus or minus the square
root of-- minus 1 squared
00:15:42.680 --> 00:15:49.961
is 1 minus 4ac plus 4 over 2.
00:15:49.961 --> 00:15:50.460
OK?
00:15:50.460 --> 00:15:54.990
So there's two possible
solutions here.
00:15:54.990 --> 00:15:57.910
This is 1 plus or minus the
square root of 5 over 2.
00:16:00.670 --> 00:16:05.670
So it works if f of n
equals either-- well, we'll
00:16:05.670 --> 00:16:08.450
call the roots here
alpha 1 and alpha 2.
00:16:14.870 --> 00:16:18.370
Alpha 1 will be the
positive case, 1
00:16:18.370 --> 00:16:21.176
plus square root of 5 over 2.
00:16:21.176 --> 00:16:23.830
And alpha 2 will be
the negative case, 1
00:16:23.830 --> 00:16:28.580
minus square root of 5 over 2.
00:16:28.580 --> 00:16:29.080
All right?
00:16:29.080 --> 00:16:35.700
So guess and verify works so
far if we have an exponential
00:16:35.700 --> 00:16:39.260
with either one of those bases.
00:16:39.260 --> 00:16:41.570
All right?
00:16:41.570 --> 00:16:45.905
By the way, does anybody
recognize that number?
00:16:49.220 --> 00:16:50.742
It's a famous number.
00:16:50.742 --> 00:16:51.700
AUDIENCE: Golden ratio.
00:16:51.700 --> 00:16:53.360
PROFESSOR: The
golden ratio, which
00:16:53.360 --> 00:16:56.230
is supposed to have all these
magical mystical properties.
00:16:56.230 --> 00:16:58.000
That when you look
at a building,
00:16:58.000 --> 00:17:02.060
if its aspect ratio is that,
it's perfect to the human eye.
00:17:02.060 --> 00:17:02.930
I don't know.
00:17:02.930 --> 00:17:05.180
But there's a lot of stuff
about the golden ratio that
00:17:05.180 --> 00:17:07.235
happens to come up here.
00:17:07.235 --> 00:17:07.735
OK?
00:17:10.240 --> 00:17:14.790
Now in fact, there's more
than just these two solutions.
00:17:14.790 --> 00:17:18.819
It turns out that whenever
you have a linear recurrence
00:17:18.819 --> 00:17:21.810
and you've got two or
more solutions like that,
00:17:21.810 --> 00:17:25.430
any linear combination
is also a solution.
00:17:25.430 --> 00:17:25.930
All right?
00:17:25.930 --> 00:17:29.160
So we're just going to
state that as a fact.
00:17:29.160 --> 00:17:31.630
It's not too hard to prove,
but we won't prove it in class.
00:17:35.110 --> 00:17:39.420
So if f of n equals
alpha 1 to the n--
00:17:39.420 --> 00:17:44.590
and this is true for any alpha
1 and alpha 2-- and f of n
00:17:44.590 --> 00:17:53.200
equals alpha 2 to
the n are solutions
00:17:53.200 --> 00:18:04.030
to a linear recurrence--
and here I mean
00:18:04.030 --> 00:18:06.680
without yet applying
the boundary conditions.
00:18:06.680 --> 00:18:08.860
So far, we've ignored
the boundary conditions,
00:18:08.860 --> 00:18:11.580
and we'll just do that
for a little longer.
00:18:11.580 --> 00:18:13.660
So if there are solutions
without worrying
00:18:13.660 --> 00:18:24.710
about the boundary
conditions, then f of n
00:18:24.710 --> 00:18:31.260
equals c1 times alpha 1 to
the n plus c2 alpha 2 to the n
00:18:31.260 --> 00:18:34.550
is also a solution for
any constants c1 and c2.
00:18:56.130 --> 00:18:56.630
All right?
00:18:56.630 --> 00:19:01.320
So any linear combination
of our solutions also works.
00:19:01.320 --> 00:19:05.580
If you plugged it in to do
verify, it would be fine.
00:19:05.580 --> 00:19:14.380
So that means that f
of n equals c1 times
00:19:14.380 --> 00:19:18.110
1 plus square root
of 5 over 2 to the n
00:19:18.110 --> 00:19:25.090
plus c2 1 minus square
root of 5 over 2 to the n
00:19:25.090 --> 00:19:33.500
is a solution-- oops--
to Fibonacci's recurrence
00:19:33.500 --> 00:19:35.320
without boundary
conditions again.
00:19:41.410 --> 00:19:41.910
All right?
00:19:41.910 --> 00:19:46.750
So I could plug this
expression into the recurrence,
00:19:46.750 --> 00:19:49.885
and it would satisfy it.
00:19:49.885 --> 00:19:50.910
I won't do that.
00:19:54.180 --> 00:19:57.790
But we haven't dealt with
the boundary conditions yet.
00:19:57.790 --> 00:19:59.970
And in fact, dealing with
the boundary conditions
00:19:59.970 --> 00:20:04.270
is what determines the
values of these constants.
00:20:04.270 --> 00:20:09.010
I could have Fibonacci's
recurrence where f of 0 was 10
00:20:09.010 --> 00:20:12.040
and f of 1 was 20
if I wanted to,
00:20:12.040 --> 00:20:15.860
and then the recurrence
would be the same afterwards.
00:20:15.860 --> 00:20:19.680
And it will turn out I get
different constants here.
00:20:19.680 --> 00:20:20.180
All right?
00:20:20.180 --> 00:20:22.880
But otherwise, the form is
going to look like this.
00:20:22.880 --> 00:20:24.340
So let's see how
to make that work.
00:20:24.340 --> 00:20:26.340
Let's see how to determine
the constant factors.
00:20:48.770 --> 00:20:49.390
OK.
00:20:49.390 --> 00:21:05.360
So to determine the
constant factors,
00:21:05.360 --> 00:21:08.180
we plug in the
boundary conditions.
00:21:08.180 --> 00:21:14.590
So we have f of 0 equals 0
from the boundary condition.
00:21:14.590 --> 00:21:17.190
And now we plug that into
our formula over there.
00:21:20.050 --> 00:21:26.740
That's c1 times alpha 1 to the
0 plus c2 alpha 2 to the 0.
00:21:26.740 --> 00:21:29.600
Of course, anything
to the 0 is just 1.
00:21:32.480 --> 00:21:38.471
And that means that
c2 equals minus c1.
00:21:38.471 --> 00:21:39.902
All right?
00:21:39.902 --> 00:21:42.280
And now I'll use the
next boundary condition
00:21:42.280 --> 00:21:44.180
to nail them down.
00:21:50.750 --> 00:21:51.250
All right?
00:21:51.250 --> 00:21:56.350
So I know also that
f(1) is 1, and that
00:21:56.350 --> 00:22:02.380
equals c1 1 plus square root
of 5 over 2 to the first power
00:22:02.380 --> 00:22:10.050
plus c2 1 minus the square root
of 5 over 2 to the first power.
00:22:10.050 --> 00:22:13.720
I plug in c2 as minus c1.
00:22:13.720 --> 00:22:19.480
So I get c1 1 plus square
root of 5 over 2 minus c1 1
00:22:19.480 --> 00:22:23.790
minus square root of 5 over 2.
00:22:23.790 --> 00:22:27.250
And now that I can
factor out the c1,
00:22:27.250 --> 00:22:33.890
I get 1 minus 1 square root of
5 minus minus square root of 5,
00:22:33.890 --> 00:22:40.370
which gives me c1 2
square root of 5 over 2.
00:22:40.370 --> 00:22:42.790
These cancel.
00:22:42.790 --> 00:22:47.480
This was all equal to 1, so
that means that c1 equals 1
00:22:47.480 --> 00:22:50.370
over the square root of 5.
00:22:50.370 --> 00:22:53.840
And of course, c2 is minus that.
00:22:53.840 --> 00:22:57.640
c2 is minus 1 over
the square root of 5.
00:23:00.560 --> 00:23:02.815
Any questions so far?
00:23:05.585 --> 00:23:06.563
All right.
00:23:12.930 --> 00:23:15.660
Now I could write
out the formula
00:23:15.660 --> 00:23:16.750
for the Fibonacci numbers.
00:23:22.630 --> 00:23:23.130
All right?
00:23:23.130 --> 00:23:32.380
So the solution is f
of n equals c1, which
00:23:32.380 --> 00:23:36.810
is 1 over square root of
5, times the n-th power
00:23:36.810 --> 00:23:42.800
of the first root plus
c2, which is minus 1
00:23:42.800 --> 00:23:46.180
over square root of 5, times the
n-th power of the second root.
00:23:51.030 --> 00:23:54.900
And that is the formula for
the n-th Fibonacci number.
00:23:57.580 --> 00:24:00.590
You wouldn't have guessed
that to start with obviously.
00:24:00.590 --> 00:24:02.900
That would require pretty
divine inspiration.
00:24:02.900 --> 00:24:06.140
And you can sort of see why it
took them 600 years in Europe
00:24:06.140 --> 00:24:07.660
to figure out the answer.
00:24:07.660 --> 00:24:08.160
All right?
00:24:08.160 --> 00:24:09.610
It's not the first
thing you'd think about.
00:24:09.610 --> 00:24:12.240
In fact, if somebody told you
the answer and said this is it,
00:24:12.240 --> 00:24:14.230
you'd go, oh, give me a break.
00:24:14.230 --> 00:24:14.730
All right?
00:24:14.730 --> 00:24:17.450
It does not look like-- I
mean, what are the chances that
00:24:17.450 --> 00:24:20.350
evaluates to an integer?
00:24:20.350 --> 00:24:20.850
All right?
00:24:20.850 --> 00:24:25.080
It's got square root of
5's all over the place.
00:24:25.080 --> 00:24:26.140
Right?
00:24:26.140 --> 00:24:30.470
And here I'm telling
you that f of 6,
00:24:30.470 --> 00:24:34.240
the sixth Fibonacci number,
which is 8, 3 plus 5,
00:24:34.240 --> 00:24:38.070
I'm telling you that is equal
to 1 over square root of 5 1
00:24:38.070 --> 00:24:42.250
plus the square root of 5 over
2 to the sixth power minus 1
00:24:42.250 --> 00:24:46.290
over square root of 5 1 minus
the square root of 5 over 2
00:24:46.290 --> 00:24:48.350
to the sixth power.
00:24:48.350 --> 00:24:51.350
I mean, would you believe
me if I told you that?
00:24:51.350 --> 00:24:52.970
Probably not.
00:24:52.970 --> 00:24:54.560
What are the
chances that's true?
00:24:54.560 --> 00:24:58.450
Somehow, magically, all those
square root of 5's all go away,
00:24:58.450 --> 00:25:02.890
and you're just left
with 8, a simple integer.
00:25:02.890 --> 00:25:03.390
OK?
00:25:06.130 --> 00:25:08.180
All right.
00:25:08.180 --> 00:25:13.895
Yeah, there's sort of some more
interesting things about this.
00:25:13.895 --> 00:25:17.890
What happens to this value
here as n gets large?
00:25:20.450 --> 00:25:22.938
What does it do as n gets large?
00:25:22.938 --> 00:25:26.260
AUDIENCE: Gets small.
00:25:26.260 --> 00:25:30.210
PROFESSOR: It gets small Because
1 minus the square root of 5
00:25:30.210 --> 00:25:34.480
over 2 is about 0.6.
00:25:34.480 --> 00:25:39.120
This is about, here, this is
about 0.618 something or other.
00:25:39.120 --> 00:25:42.050
And if I take a fraction less
than 1 to the n-th power,
00:25:42.050 --> 00:25:44.440
it goes to 0.
00:25:44.440 --> 00:25:46.430
It goes away.
00:25:46.430 --> 00:25:50.140
So in fact, as n
gets large, this
00:25:50.140 --> 00:25:54.050
is what the n-th Fibonacci
number starts to look like.
00:25:54.050 --> 00:25:58.250
In particular, f of n equals
just that first one-- 1
00:25:58.250 --> 00:26:05.530
over square root of 5 times the
golden ratio to the n-th power
00:26:05.530 --> 00:26:09.260
plus some error term, delta n.
00:26:09.260 --> 00:26:17.770
And delta n is less than a
1/10 for n greater than 4.
00:26:20.300 --> 00:26:27.330
And it is little l of 1
in general going to 0.
00:26:27.330 --> 00:26:29.070
So in fact, the n-th
Fibonacci number
00:26:29.070 --> 00:26:31.720
is about the n-th power of
the golden ratio divided
00:26:31.720 --> 00:26:35.020
by square root of 5.
00:26:35.020 --> 00:26:35.922
Yeah?
00:26:35.922 --> 00:26:38.064
AUDIENCE: [INAUDIBLE]
top of the right board--
00:26:38.064 --> 00:26:38.730
PROFESSOR: Yeah?
00:26:38.730 --> 00:26:43.158
AUDIENCE: --you say that you can
pick sort of any constants that
00:26:43.158 --> 00:26:44.009
satisfy it?
00:26:44.009 --> 00:26:44.634
PROFESSOR: Yep.
00:26:44.634 --> 00:26:46.602
AUDIENCE: Does that
shift the sequence
00:26:46.602 --> 00:26:48.570
over, or what does that do?
00:26:48.570 --> 00:26:50.046
I guess I don't understand.
00:26:50.046 --> 00:26:51.810
PROFESSOR: OK.
00:26:51.810 --> 00:26:55.609
You're asking, what are
these things doing here?
00:26:55.609 --> 00:26:56.234
AUDIENCE: Yeah.
00:26:56.234 --> 00:26:58.570
And why [? isn't there-- ?]
why are they also solutions?
00:26:58.570 --> 00:27:00.125
Because this is the right ones?
00:27:00.125 --> 00:27:01.166
PROFESSOR: The right one.
00:27:01.166 --> 00:27:01.760
OK.
00:27:01.760 --> 00:27:05.120
So there's two parts
to a recurrence.
00:27:05.120 --> 00:27:11.120
There's this part,
OK, and there's
00:27:11.120 --> 00:27:17.250
the boundary conditions-- f(0)
equals 0 and f(1) equals 1.
00:27:17.250 --> 00:27:19.450
There are really
two parts to it.
00:27:19.450 --> 00:27:21.610
If you change the
boundary conditions,
00:27:21.610 --> 00:27:26.240
you would change the
rest of the terms, right?
00:27:26.240 --> 00:27:28.460
If I started with
10 and 20, f of 2
00:27:28.460 --> 00:27:34.510
would be 30, OK, if I'm using
this recurrence form for n
00:27:34.510 --> 00:27:36.522
bigger than or equal to 2.
00:27:36.522 --> 00:27:40.200
Now, so when I'm computing a
solution, first I'm saying,
00:27:40.200 --> 00:27:41.860
let's ignore the
boundary conditions
00:27:41.860 --> 00:27:45.770
and look at all the recurrences
that share this part.
00:27:45.770 --> 00:27:49.960
And that family of
recurrences, I'm claiming,
00:27:49.960 --> 00:27:51.580
have these solutions.
00:27:51.580 --> 00:27:54.130
This is the solution
space if I just
00:27:54.130 --> 00:27:59.460
worry about this part and
not the boundary conditions.
00:27:59.460 --> 00:28:03.160
Now, once I plug the
boundary conditions in,
00:28:03.160 --> 00:28:08.220
that determines which
values of c1 and c2 I get.
00:28:08.220 --> 00:28:11.740
And so if I take the version
of the recurrence where f(0)
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,
00:28:16.400 --> 00:28:19.720
and c2 is going to be
negative 1 over root 5.
00:28:19.720 --> 00:28:23.660
If I use this
recurrence with f(0)
00:28:23.660 --> 00:28:28.430
equals 10 and f(1) equals 20,
I get different constants,
00:28:28.430 --> 00:28:31.362
but these powers stay the same.
00:28:31.362 --> 00:28:33.320
In fact, maybe we'll make
an exercise like that
00:28:33.320 --> 00:28:35.069
from the problem set
to figure out what it
00:28:35.069 --> 00:28:37.450
is if I started with 10 and 20.
00:28:37.450 --> 00:28:38.020
OK?
00:28:38.020 --> 00:28:40.240
So that's what
the constants have
00:28:40.240 --> 00:28:43.160
to do-- they come from the
boundary condition, which
00:28:43.160 --> 00:28:45.591
is sort of a cool fact.
00:28:45.591 --> 00:28:47.280
Does that make sense?
00:28:47.280 --> 00:28:48.060
AUDIENCE: Yeah.
00:28:48.060 --> 00:28:51.570
PROFESSOR: Any other questions
about what I was doing?
00:28:51.570 --> 00:28:56.590
So we used guess and verify, but
I sort of guessed a form first.
00:28:56.590 --> 00:29:01.390
And as I verified, I sort of
revised my guess along the way.
00:29:01.390 --> 00:29:01.890
All right?
00:29:01.890 --> 00:29:03.160
So I started guessing this.
00:29:03.160 --> 00:29:05.290
And then I said,
well, let's refine
00:29:05.290 --> 00:29:11.307
that guess so that really
it's one of these two guys.
00:29:11.307 --> 00:29:12.890
And then I said-- I
used a fact that I
00:29:12.890 --> 00:29:14.681
didn't prove-- that
said I could use really
00:29:14.681 --> 00:29:17.570
any linear combination,
plugged it into the base cases,
00:29:17.570 --> 00:29:20.301
and got my constants.
00:29:20.301 --> 00:29:20.800
All right?
00:29:20.800 --> 00:29:23.269
Now, this will lead up to
a formula or an approach
00:29:23.269 --> 00:29:25.310
so you don't have to go
through this on your own.
00:29:25.310 --> 00:29:27.710
You just plug in the
formula in general.
00:29:30.300 --> 00:29:30.800
OK.
00:29:33.402 --> 00:29:35.360
Let's get back to the
original question of when
00:29:35.360 --> 00:29:37.660
all the jobs are filled.
00:29:37.660 --> 00:29:43.091
For what value of n is
f of n bigger than M?
00:29:43.091 --> 00:29:43.590
All right?
00:29:48.790 --> 00:29:49.420
Let's do that.
00:30:03.940 --> 00:30:04.450
OK.
00:30:04.450 --> 00:30:20.130
To see when all the jobs
are filled, all M jobs,
00:30:20.130 --> 00:30:24.876
for the n when f of n is
bigger and equal to M,
00:30:24.876 --> 00:30:28.300
when we got a Fibonacci
number that's bigger than M.
00:30:28.300 --> 00:30:31.770
And we just showed
that basically f of n,
00:30:31.770 --> 00:30:35.090
well, it equals this
where that's a tiny thing.
00:30:35.090 --> 00:30:35.590
All right?
00:30:35.590 --> 00:30:40.020
So we need to figure out when
is 1 over square root of 5 times
00:30:40.020 --> 00:30:44.080
the golden ratio to
the n-th power-- plus
00:30:44.080 --> 00:30:47.430
I have this tiny little
thing that doesn't matter--
00:30:47.430 --> 00:30:50.200
is bigger than or equal to M?
00:30:50.200 --> 00:30:54.790
So I can solve for n now by
subtracting the delta term,
00:30:54.790 --> 00:30:57.300
multiplying by square root of 5.
00:30:57.300 --> 00:31:02.260
That gives me the golden
ratio to the n-th power
00:31:02.260 --> 00:31:06.240
bigger than or equal
to square root 5 times
00:31:06.240 --> 00:31:08.050
M minus the tiny thing.
00:31:10.800 --> 00:31:14.040
Now I take logs.
00:31:14.040 --> 00:31:21.450
And I'm in trouble when n is
bigger than or equal to log
00:31:21.450 --> 00:31:30.825
of this over log of the base.
00:31:38.710 --> 00:31:41.070
In other words, this is theta.
00:31:41.070 --> 00:31:42.550
What's this theta of here?
00:31:45.830 --> 00:31:48.500
That goes away.
00:31:48.500 --> 00:31:50.434
I can skip all the
constant factors.
00:31:50.434 --> 00:31:52.225
What's this theta of
here, this expression,
00:31:52.225 --> 00:31:56.224
in terms of theta of something
to do with some function of M?
00:31:56.224 --> 00:31:57.220
AUDIENCE: Log of M?
00:31:57.220 --> 00:32:02.910
PROFESSOR: Log of M. So the jobs
get filled in log of M years.
00:32:02.910 --> 00:32:05.250
And in fact, if I
plugged in, for example,
00:32:05.250 --> 00:32:07.810
M equals 10,000 into
this expression,
00:32:07.810 --> 00:32:09.290
I would find that
all the jobs are
00:32:09.290 --> 00:32:12.540
filled in 20 years, which
is more or less what
00:32:12.540 --> 00:32:14.780
happened in computer science.
00:32:14.780 --> 00:32:18.221
Ballpark, those numbers
are roughly correct.
00:32:18.221 --> 00:32:18.720
All right?
00:32:18.720 --> 00:32:21.530
But you can solve it exactly now
by just plugging in whatever M
00:32:21.530 --> 00:32:22.490
you want.
00:32:22.490 --> 00:32:23.870
That's a fraction
less than 1/10.
00:32:23.870 --> 00:32:25.286
And you can solve
to find out when
00:32:25.286 --> 00:32:26.973
your population gets that big.
00:32:29.851 --> 00:32:30.350
OK.
00:32:30.350 --> 00:32:30.933
Any questions?
00:32:36.410 --> 00:32:36.910
OK.
00:32:36.910 --> 00:32:39.250
So now what I want
to do is show you
00:32:39.250 --> 00:32:43.495
how to use this same idea to
solve any linear recurrence,
00:32:43.495 --> 00:32:45.620
and this is the process
you'll go through to do it.
00:33:01.625 --> 00:33:02.310
All right.
00:33:02.310 --> 00:33:06.420
So we're going to solve a
general linear recurrence.
00:33:20.040 --> 00:33:27.440
So in this case, we've got
f of n is the sum from i
00:33:27.440 --> 00:33:30.590
equals 1 to d, for an
order d recurrence,
00:33:30.590 --> 00:33:34.530
a sub i f of n minus i.
00:33:34.530 --> 00:33:38.280
And we've got to have
boundary conditions.
00:33:38.280 --> 00:33:46.570
So we'll have f of 0
is b0, f of 1 is b1.
00:33:46.570 --> 00:33:48.100
And how many boundary
conditions do
00:33:48.100 --> 00:33:49.599
you think I'm going
to need to have?
00:33:49.599 --> 00:33:51.790
Any guesses?
00:33:51.790 --> 00:33:54.242
I had two for Fibonacci.
00:33:54.242 --> 00:33:56.320
In this case, I've got d terms.
00:33:56.320 --> 00:33:57.059
AUDIENCE: d.
00:33:57.059 --> 00:33:57.600
PROFESSOR: d.
00:33:57.600 --> 00:33:59.266
I'm going to need d
boundary conditions.
00:33:59.266 --> 00:34:03.650
So we'll go all the
way to f of d minus 1
00:34:03.650 --> 00:34:05.370
equal to b of d minus 1.
00:34:07.992 --> 00:34:08.780
All right?
00:34:08.780 --> 00:34:16.839
And now I'm going to try
f of n is alpha to the n.
00:34:16.839 --> 00:34:20.989
We're going to plug it
into this expression.
00:34:20.989 --> 00:34:25.090
And then when we do,
we get alpha to the n
00:34:25.090 --> 00:34:31.480
equals a1 alpha to
the n minus 1 plus
00:34:31.480 --> 00:34:37.360
a2 alpha to the n minus 2
all the way down to a sub
00:34:37.360 --> 00:34:44.310
d alpha to the n minus d.
00:34:44.310 --> 00:34:44.810
All right?
00:34:44.810 --> 00:34:47.280
Just plugging into there.
00:34:47.280 --> 00:34:50.790
I can divide everything
by alpha to the n minus d,
00:34:50.790 --> 00:34:54.290
and that gives me
alpha to the d equals
00:34:54.290 --> 00:35:04.320
a1 alpha to the d minus 1 a2
alpha to the d minus 2 ad times
00:35:04.320 --> 00:35:08.760
alpha to the 0, which is just 1.
00:35:08.760 --> 00:35:12.805
And I can rewrite this as
a polynomial equal to 0.
00:35:22.800 --> 00:35:26.255
So that means that
alpha to the d minus
00:35:26.255 --> 00:35:34.420
a1 alpha to the d minus 1
minus a2 alpha to the d minus 2
00:35:34.420 --> 00:35:38.600
minus ad is 0.
00:35:38.600 --> 00:35:41.460
This is called the
characteristic equation
00:35:41.460 --> 00:35:42.210
of the recurrence.
00:35:56.770 --> 00:35:58.490
OK?
00:35:58.490 --> 00:36:03.590
Now, what you need to do is
compute the roots of this,
00:36:03.590 --> 00:36:08.610
and we'll use the roots to get
the solution to the recurrence.
00:36:08.610 --> 00:36:10.780
Now, the simple case
is when all the roots
00:36:10.780 --> 00:36:15.120
are different-- so let's
do that first-- like there
00:36:15.120 --> 00:36:16.530
was in the Fibonacci example.
00:36:21.440 --> 00:36:30.280
All d roots are
different, and let's call
00:36:30.280 --> 00:36:33.440
them alpha 1 to alpha d.
00:36:39.610 --> 00:36:44.070
In that case, the solution
is all linear combinations
00:36:44.070 --> 00:36:49.490
of their n-th
powers, just like it
00:36:49.490 --> 00:36:56.180
was with Fibonacci without
the boundary conditions.
00:36:56.180 --> 00:37:00.040
c1 alpha 1 to the
n plus c2 alpha 2
00:37:00.040 --> 00:37:08.580
to the n plus cd
alpha d to the n.
00:37:08.580 --> 00:37:09.080
All right?
00:37:09.080 --> 00:37:11.340
Same thing happens that
happened in Fibonacci,
00:37:11.340 --> 00:37:14.780
that this becomes the
solution before the boundary
00:37:14.780 --> 00:37:16.690
conditions are applied.
00:37:16.690 --> 00:37:17.190
All right?
00:37:30.500 --> 00:37:33.730
And by the way, if your
characteristic equation has
00:37:33.730 --> 00:37:36.930
imaginary roots, that's fine.
00:37:36.930 --> 00:37:39.480
It doesn't matter
because the imaginary i
00:37:39.480 --> 00:37:41.900
term will disappear just
like the square root of 5
00:37:41.900 --> 00:37:43.350
disappeared.
00:37:43.350 --> 00:37:49.130
Has to because we know f of n,
in this case, is a real number.
00:37:49.130 --> 00:37:51.110
All right?
00:37:51.110 --> 00:37:51.610
OK.
00:37:51.610 --> 00:37:54.600
Now, to find out the values
of the coefficients, what
00:37:54.600 --> 00:37:57.710
are we going to do?
00:37:57.710 --> 00:37:58.710
What is it?
00:37:58.710 --> 00:37:59.960
AUDIENCE: Boundary conditions.
00:37:59.960 --> 00:38:01.490
PROFESSOR: Boundary
conditions, yep.
00:38:01.490 --> 00:38:13.870
So now we solve for c1, c2, cd
from the boundary conditions.
00:38:13.870 --> 00:38:20.270
That is, f of i is b
of i for i from 0 to d.
00:38:23.030 --> 00:38:28.960
So for example, we
know that f of 0
00:38:28.960 --> 00:38:35.650
is c1 times alpha 1 to the
0, which is 1, c2 alpha 2
00:38:35.650 --> 00:38:40.480
to the 0 plus cd.
00:38:40.480 --> 00:38:45.950
And that's going to be
equal to b0 and so forth.
00:38:45.950 --> 00:38:48.600
So you get a system of
equations, d equations
00:38:48.600 --> 00:38:53.820
in d variables, that you solve
to find the coefficients.
00:38:53.820 --> 00:38:57.170
And that will give the
unique and correct solution
00:38:57.170 --> 00:39:00.360
to the recurrence.
00:39:00.360 --> 00:39:00.860
All right?
00:39:00.860 --> 00:39:05.620
Now, turns out this system of
equations is never degenerate.
00:39:05.620 --> 00:39:07.550
It always has a solution.
00:39:07.550 --> 00:39:11.860
And you can prove that,
but we won't do that.
00:39:11.860 --> 00:39:17.760
Any questions about
how to do that?
00:39:17.760 --> 00:39:18.420
All right.
00:39:18.420 --> 00:39:19.209
Yeah?
00:39:19.209 --> 00:39:21.083
AUDIENCE: Sorry, I just
had a quick question.
00:39:21.083 --> 00:39:25.700
But what exactly was the
distance there between n and d?
00:39:25.700 --> 00:39:29.710
d is like the degree of--
which the terms you go back to.
00:39:29.710 --> 00:39:35.260
PROFESSOR: Yes, Yeah. d is
how far back you're going.
00:39:35.260 --> 00:39:39.339
You go as far back
as f of n minus d.
00:39:39.339 --> 00:39:39.880
AUDIENCE: OK.
00:39:39.880 --> 00:39:40.340
Cool.
00:39:40.340 --> 00:39:41.965
PROFESSOR: And that
becomes the degree,
00:39:41.965 --> 00:39:45.177
and that is a
constant-- 2, 3, 4.
00:39:45.177 --> 00:39:47.510
Well, I don't think we'll
ever ask you anything beyond 4
00:39:47.510 --> 00:39:49.660
because it gets to
be a pain to do.
00:39:49.660 --> 00:39:53.450
Typically, it's 2 or 3,
sometimes even just 1.
00:39:53.450 --> 00:39:55.450
And then that
becomes the power of
00:39:55.450 --> 00:39:58.010
your characteristic equation.
00:39:58.010 --> 00:40:01.797
It's the order of the
characteristic equation.
00:40:01.797 --> 00:40:02.630
Any other questions?
00:40:05.240 --> 00:40:05.740
All right.
00:40:05.740 --> 00:40:08.550
That was the nice case
where all the roots
00:40:08.550 --> 00:40:11.660
of your characteristic
equation were different.
00:40:11.660 --> 00:40:14.625
If they're not all different,
it's a little more complicated.
00:40:33.380 --> 00:40:42.010
So the tricky case
is repeated roots.
00:40:49.320 --> 00:40:54.550
Now, the theorem, which we won't
prove but tells you what to do,
00:40:54.550 --> 00:41:10.460
is that if alpha is a root of
the characteristic equation
00:41:10.460 --> 00:41:16.530
and it is repeated r times-- so
x minus alpha to the r-th power
00:41:16.530 --> 00:41:39.576
is a factor-- then alpha to
the n, n times alpha to the n,
00:41:39.576 --> 00:41:43.350
n squared times alpha
to the n, all the way up
00:41:43.350 --> 00:41:47.790
to n to the r minus 1
times alpha to the n
00:41:47.790 --> 00:41:49.570
are all solutions
to the recurrence.
00:42:04.460 --> 00:42:04.960
All right?
00:42:04.960 --> 00:42:07.090
And then you would
treat them just
00:42:07.090 --> 00:42:08.420
as you would the other roots.
00:42:08.420 --> 00:42:10.380
You take linear
combinations, just
00:42:10.380 --> 00:42:13.560
like you did with the other
roots to put it all together.
00:42:17.470 --> 00:42:22.020
By the way, is anybody starting
to recognize a similarity
00:42:22.020 --> 00:42:24.615
with something else that
you've studied in the past?
00:42:24.615 --> 00:42:25.990
AUDIENCE: Differential
equations.
00:42:25.990 --> 00:42:27.910
PROFESSOR:
Differential equations.
00:42:27.910 --> 00:42:32.550
This is the discrete analog
of differential equations.
00:42:32.550 --> 00:42:33.050
All right?
00:42:33.050 --> 00:42:35.390
Recurrences is the same thing.
00:42:35.390 --> 00:42:37.450
All the math we're
going to do henceforth
00:42:37.450 --> 00:42:39.840
is going to look just
like what you did
00:42:39.840 --> 00:42:42.409
with differential equations.
00:42:42.409 --> 00:42:44.950
So that's sort of good news and,
I guess, bad news, depending
00:42:44.950 --> 00:42:45.820
on whether you like that stuff.
00:42:45.820 --> 00:42:46.612
AUDIENCE: Bad news.
00:42:46.612 --> 00:42:47.445
PROFESSOR: Bad news.
00:42:47.445 --> 00:42:48.020
Yeah, OK.
00:42:51.810 --> 00:42:54.520
All right, let's do an
example that uses maybe
00:42:54.520 --> 00:42:57.480
the repeated roots case.
00:42:57.480 --> 00:43:00.140
Suppose there's a
plant out there,
00:43:00.140 --> 00:43:04.510
and this plant lives
forever but only reproduces
00:43:04.510 --> 00:43:08.070
in the first year of life
and then never again.
00:43:08.070 --> 00:43:11.000
And it reproduces one for one.
00:43:11.000 --> 00:43:11.500
All right?
00:43:11.500 --> 00:43:13.530
Let's see what
happens in that case.
00:43:19.890 --> 00:43:22.310
Actually, there's a plant
sort of like this in Hawaii.
00:43:22.310 --> 00:43:27.517
I think it's called the
century plant, and it's rare.
00:43:27.517 --> 00:43:29.225
We'll see why when we
solve this problem.
00:43:31.990 --> 00:43:46.290
So it reproduces one for one
during the first year of life,
00:43:46.290 --> 00:43:56.825
then never again, and
the plant lives forever.
00:44:05.500 --> 00:44:10.951
So our question is, how fast
does the plant population grow?
00:44:10.951 --> 00:44:11.450
All right?
00:44:11.450 --> 00:44:15.010
In year n, how many
plants there are.
00:44:15.010 --> 00:44:18.035
So to figure that out, we're
going to set up a recurrence.
00:44:21.200 --> 00:44:26.330
We're going to let f of n be
the number of plants in year n.
00:44:33.150 --> 00:44:36.610
And we're going to say that the
first plant miraculously comes
00:44:36.610 --> 00:44:39.090
into existence in year 1.
00:44:39.090 --> 00:44:43.060
So that in year 0 there's
none of them, and in year 1
00:44:43.060 --> 00:44:45.512
there's 1.
00:44:45.512 --> 00:44:47.720
And now we want to know how
many there are in year n.
00:45:05.540 --> 00:45:06.070
OK.
00:45:06.070 --> 00:45:07.361
So let's set up the recurrence.
00:45:10.190 --> 00:45:15.200
f of n equals-- well,
the previous year,
00:45:15.200 --> 00:45:20.155
how many plants were
there in terms of f?
00:45:20.155 --> 00:45:21.030
AUDIENCE: [INAUDIBLE]
00:45:21.030 --> 00:45:23.300
PROFESSOR: f of n minus 1.
00:45:23.300 --> 00:45:23.800
All right?
00:45:23.800 --> 00:45:25.341
That's how many
there were last year,
00:45:25.341 --> 00:45:27.120
and they're all
still alive, plus
00:45:27.120 --> 00:45:31.360
we've got to add the
number of new plants.
00:45:31.360 --> 00:45:34.810
Well, that would
be-- yeah, well,
00:45:34.810 --> 00:45:36.330
how many new plants are there?
00:45:36.330 --> 00:45:40.560
It's all the plants that
were one-year-old last year.
00:45:40.560 --> 00:45:44.650
So that's all the
ones that were alive
00:45:44.650 --> 00:45:47.370
last year minus the ones that
were alive the year before.
00:45:50.450 --> 00:45:52.850
That's how many new plants
there were last year,
00:45:52.850 --> 00:45:56.186
and they each produce
1 new one this year.
00:45:56.186 --> 00:45:56.915
Is that OK?
00:45:56.915 --> 00:45:57.706
Everybody buy that?
00:46:00.265 --> 00:46:00.765
OK.
00:46:03.500 --> 00:46:10.020
So that equals 2 f of n
minus 1 minus f of n minus 2.
00:46:14.840 --> 00:46:16.280
OK.
00:46:16.280 --> 00:46:19.148
What's my characteristic
equation for this recurrence?
00:46:24.140 --> 00:46:24.680
Yeah?
00:46:24.680 --> 00:46:29.440
AUDIENCE: Alpha squared
minus 2 alpha plus 1.
00:46:29.440 --> 00:46:31.344
PROFESSOR: Yes.
00:46:31.344 --> 00:46:32.180
OK?
00:46:32.180 --> 00:46:39.931
alpha squared minus
2 alpha plus 1.
00:46:39.931 --> 00:46:40.430
All right?
00:46:40.430 --> 00:46:41.730
We jumped to that answer.
00:46:41.730 --> 00:46:45.863
I could have written down alpha
to the n minus 2 times alpha
00:46:45.863 --> 00:46:49.139
to the n minus 1 plus
alpha to the n minus 2
00:46:49.139 --> 00:46:50.930
and then divided by
alpha to the n minus 2.
00:46:50.930 --> 00:46:54.570
But pretty quickly, you want
to start just reading it off.
00:46:54.570 --> 00:46:56.420
That's the
characteristic equation.
00:46:56.420 --> 00:46:58.760
I get alpha squared, and
then bringing this over,
00:46:58.760 --> 00:47:03.000
a minus 2 alpha, bring
this over, plus 1 equals 0.
00:47:05.680 --> 00:47:10.000
Any questions on that?
00:47:10.000 --> 00:47:11.790
This is the process
now you will always
00:47:11.790 --> 00:47:13.420
use that we're going through.
00:47:13.420 --> 00:47:13.920
All right.
00:47:13.920 --> 00:47:15.294
What are the roots
to this thing?
00:47:18.117 --> 00:47:20.200
What are the roots to the
characteristic equation?
00:47:20.200 --> 00:47:24.184
AUDIENCE: Alpha
minus 1 [INAUDIBLE].
00:47:24.184 --> 00:47:24.850
PROFESSOR: Yeah.
00:47:24.850 --> 00:47:26.850
Alpha minus 1
times alpha minus 1
00:47:26.850 --> 00:47:29.300
is 0, which means alpha equals?
00:47:29.300 --> 00:47:29.800
AUDIENCE: 1.
00:47:29.800 --> 00:47:30.830
PROFESSOR: 1.
00:47:30.830 --> 00:47:37.590
So the roots are alpha equals
1, and it's a double root.
00:47:37.590 --> 00:47:39.070
OK?
00:47:39.070 --> 00:47:40.040
It's a double root.
00:47:40.040 --> 00:47:48.110
It occurs twice because this
is alpha minus 1 squared.
00:47:48.110 --> 00:47:49.550
OK.
00:47:49.550 --> 00:47:54.590
So what solutions am I going
to use to my recurrence?
00:48:00.330 --> 00:48:04.350
What's f of n going
to be now before I
00:48:04.350 --> 00:48:07.466
put in the boundary conditions?
00:48:07.466 --> 00:48:13.516
Well, it's going to be
c1 times what to the n?
00:48:13.516 --> 00:48:14.448
AUDIENCE: 1.
00:48:14.448 --> 00:48:15.140
PROFESSOR: 1.
00:48:15.140 --> 00:48:16.960
That's the first root.
00:48:16.960 --> 00:48:17.600
What's here?
00:48:17.600 --> 00:48:21.780
What's the next thing
I'm going to put here?
00:48:21.780 --> 00:48:22.740
AUDIENCE: [INAUDIBLE].
00:48:22.740 --> 00:48:24.555
PROFESSOR: n times 1 to the n.
00:48:24.555 --> 00:48:27.540
All right?
00:48:27.540 --> 00:48:30.150
Because I've got a root
that's repeated twice,
00:48:30.150 --> 00:48:34.790
r equals 2, so I have alpha
to the n and n alpha to the n.
00:48:34.790 --> 00:48:37.435
Just happens alpha's 1,
which makes it really easy.
00:48:39.770 --> 00:48:40.270
All right?
00:48:40.270 --> 00:48:43.000
So this is now my solution
before the boundary conditions.
00:48:46.270 --> 00:48:48.630
In fact, that gets even simpler.
00:48:48.630 --> 00:48:49.130
That's 1.
00:48:49.130 --> 00:48:51.308
That's c1 plus c2 times n.
00:48:54.520 --> 00:48:56.025
And now all that's
left is to plug
00:48:56.025 --> 00:48:57.150
in the boundary conditions.
00:49:10.680 --> 00:49:14.140
So let's do that.
00:49:14.140 --> 00:49:17.225
Well, f of 0 equals 0.
00:49:21.330 --> 00:49:23.514
If I plug it into here,
what happens for f of 0?
00:49:23.514 --> 00:49:24.430
What does that become?
00:49:24.430 --> 00:49:25.800
AUDIENCE: [INAUDIBLE].
00:49:25.800 --> 00:49:27.430
PROFESSOR: C1.
00:49:27.430 --> 00:49:28.690
So c1 equals 0.
00:49:28.690 --> 00:49:29.990
That's good.
00:49:29.990 --> 00:49:32.990
f of 1 equals 1.
00:49:32.990 --> 00:49:37.060
And now that's going
to be c1 plus c2.
00:49:37.060 --> 00:49:40.570
c1 is 0, so it
means c2 equals 1.
00:49:43.031 --> 00:49:43.530
All right.
00:49:43.530 --> 00:49:45.390
So this is really easy.
00:49:45.390 --> 00:49:48.430
What's f of n equal?
00:49:48.430 --> 00:49:50.520
n.
00:49:50.520 --> 00:49:53.593
So we went through a lot of work
to get an answer that probably
00:49:53.593 --> 00:49:55.940
we could have guessed
pretty easily by just
00:49:55.940 --> 00:49:58.107
plugging in a few examples.
00:49:58.107 --> 00:50:00.190
But the nice thing is this
works for all the cases
00:50:00.190 --> 00:50:05.890
when it's not so easy to guess
by plugging in the examples.
00:50:05.890 --> 00:50:09.850
Yeah, now you can see why this
is a relatively rare plant.
00:50:09.850 --> 00:50:12.080
Its population is
growing very slowly.
00:50:14.990 --> 00:50:15.540
OK.
00:50:15.540 --> 00:50:17.140
Any questions about that?
00:50:17.140 --> 00:50:18.140
That had repeated roots.
00:50:21.790 --> 00:50:22.520
All right.
00:50:22.520 --> 00:50:23.020
Yeah?
00:50:23.020 --> 00:50:24.700
AUDIENCE: So we just
guessed that f of n
00:50:24.700 --> 00:50:26.890
is equal to alpha
to the n, and we
00:50:26.890 --> 00:50:29.680
don't know if that works for
like different [INAUDIBLE].
00:50:29.680 --> 00:50:32.170
But how do you know that it
works until you plug it in?
00:50:32.170 --> 00:50:35.170
If you tried it out [INAUDIBLE]?
00:50:35.170 --> 00:50:37.294
PROFESSOR: Yeah.
00:50:37.294 --> 00:50:38.710
We didn't go through
and prove it.
00:50:38.710 --> 00:50:42.750
We used some facts along the
way that we didn't prove,
00:50:42.750 --> 00:50:43.590
which you can do.
00:50:43.590 --> 00:50:47.100
Like, in particular, the fact we
didn't prove that theorem there
00:50:47.100 --> 00:50:48.800
that those will be the roots.
00:50:48.800 --> 00:50:50.940
And we didn't prove that
any linear combination
00:50:50.940 --> 00:50:52.781
would be a solution.
00:50:52.781 --> 00:50:55.280
But those are facts you could
take from-- you could actually
00:50:55.280 --> 00:50:55.779
prove them.
00:50:55.779 --> 00:50:57.490
They're not too hard to prove.
00:50:57.490 --> 00:50:59.760
But otherwise, I think we
went through every step
00:50:59.760 --> 00:51:01.031
and narrowed it in.
00:51:01.031 --> 00:51:02.530
If we wanted to be
really sure, we'd
00:51:02.530 --> 00:51:03.990
go back and prove
it by induction
00:51:03.990 --> 00:51:06.020
against the original recurrence.
00:51:06.020 --> 00:51:10.030
And we'd say this would be
the induction hypothesis.
00:51:10.030 --> 00:51:12.930
We'd cover the base
cases-- f of 0 and f of 1.
00:51:12.930 --> 00:51:16.610
And then we'd plug this into
the recurrence up there,
00:51:16.610 --> 00:51:22.050
which is, does n equal twice
n minus 1 minus n minus 2,
00:51:22.050 --> 00:51:23.100
is what we would do.
00:51:23.100 --> 00:51:24.790
And you see that it's true.
00:51:24.790 --> 00:51:29.000
So you could really
prove it by induction
00:51:29.000 --> 00:51:30.720
for any of the
solutions we ever get.
00:51:30.720 --> 00:51:33.740
And if you worked this
way to get the solution,
00:51:33.740 --> 00:51:35.390
it will always work.
00:51:35.390 --> 00:51:38.172
This method never fails,
gives you the wrong answer.
00:51:38.172 --> 00:51:39.630
In fact, that's an
important point.
00:51:39.630 --> 00:51:41.963
When we tell you to solve a
recurrence using this method
00:51:41.963 --> 00:51:45.450
on an exam or for
homework, you don't
00:51:45.450 --> 00:51:47.460
have to verify it by
induction unless we
00:51:47.460 --> 00:51:49.550
say verify by induction.
00:51:49.550 --> 00:51:51.130
Because we're
giving you a method
00:51:51.130 --> 00:51:52.540
that is guaranteed to work.
00:51:52.540 --> 00:51:55.220
And if you do the method
right, you're fine.
00:51:55.220 --> 00:51:57.960
There's no guessing here so far.
00:51:57.960 --> 00:52:00.440
In a minute, we're going
to do a little guessing,
00:52:00.440 --> 00:52:03.573
but not so far.
00:52:03.573 --> 00:52:04.406
Any other questions?
00:52:07.670 --> 00:52:10.100
OK.
00:52:10.100 --> 00:52:17.301
This works for all homogeneous
linear recurrences.
00:52:17.301 --> 00:52:17.800
All right?
00:52:17.800 --> 00:52:19.615
Remember homogeneous
and inhomogeneous
00:52:19.615 --> 00:52:22.450
from differential equations?
00:52:22.450 --> 00:52:23.940
It's the same
thing happens here.
00:52:31.600 --> 00:52:34.037
And now we're going to talk
about the inhomogeneous case.
00:52:41.950 --> 00:52:42.450
All right.
00:52:42.450 --> 00:52:48.100
So we've been looking at
linear recurrences, which
00:52:48.100 --> 00:52:54.450
means you have something like
f of n minus a1 f of n minus 1
00:52:54.450 --> 00:53:01.892
minus ad f of n
minus d equals 0,
00:53:01.892 --> 00:53:03.225
and that means it's homogeneous.
00:53:09.170 --> 00:53:11.930
Now, instead of 0, I might
have had something else
00:53:11.930 --> 00:53:14.930
here, might have
been equal to 1,
00:53:14.930 --> 00:53:21.040
maybe n squared, or some
general function g of n.
00:53:21.040 --> 00:53:22.953
These cases are
all inhomogeneous.
00:53:30.430 --> 00:53:31.800
OK?
00:53:31.800 --> 00:53:35.570
Now, solving inhomogeneous
linear equations
00:53:35.570 --> 00:53:38.250
is just one step harder
than homogeneous.
00:53:38.250 --> 00:53:38.750
Yeah?
00:53:38.750 --> 00:53:39.583
AUDIENCE: All right.
00:53:39.583 --> 00:53:41.577
Could you define homogeneous
and inhomogeneous
00:53:41.577 --> 00:53:43.660
for people who didn't take
differential equations?
00:53:43.660 --> 00:53:44.326
PROFESSOR: Yeah.
00:53:44.326 --> 00:53:49.170
Homogeneous means
you have the 0 here.
00:53:49.170 --> 00:53:52.720
You got all these f
terms here, right,
00:53:52.720 --> 00:53:54.380
and there's nothing else.
00:53:54.380 --> 00:53:57.940
f of n minus a1 f n
minus 1 dot dot dot
00:53:57.940 --> 00:54:01.590
minus ad f n minus d equals 0.
00:54:01.590 --> 00:54:05.610
Like with Fibonacci
numbers-- f of n minus f n
00:54:05.610 --> 00:54:09.640
minus 1 minus f n minus 2 is 0.
00:54:09.640 --> 00:54:11.250
OK?
00:54:11.250 --> 00:54:14.710
I could consider
other recurrences
00:54:14.710 --> 00:54:17.770
where there's something else
out here that it equals.
00:54:17.770 --> 00:54:19.550
Like I could have a
Fibonacci recurrence
00:54:19.550 --> 00:54:23.300
where I have f(n) equals f of
n minus 1 plus f(n) minus 2
00:54:23.300 --> 00:54:26.780
plus g of n, like n cubed.
00:54:26.780 --> 00:54:29.820
That would give me a
Fibonacci-like recurrence.
00:54:29.820 --> 00:54:32.680
And as soon as you put
a non-zero out here,
00:54:32.680 --> 00:54:34.775
then it's inhomogeneous.
00:54:34.775 --> 00:54:36.150
And now I'm going
to tell you how
00:54:36.150 --> 00:54:37.960
to solve that kind
of recurrence,
00:54:37.960 --> 00:54:41.460
which is more general.
00:54:41.460 --> 00:54:41.960
OK?
00:54:44.642 --> 00:54:45.142
OK.
00:54:48.905 --> 00:54:51.363
So let me outline the method,
and then we'll do an example.
00:55:02.220 --> 00:55:02.840
All right.
00:55:02.840 --> 00:55:23.330
So the general inhomogeneous
recurrence is exactly this.
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
00:55:32.280 --> 00:55:38.270
minus d equals g of n, where
that's some fixed function
00:55:38.270 --> 00:55:39.770
of n, nothing to do with f.
00:55:42.550 --> 00:55:46.240
And we solve it according to
the following three-step method.
00:55:49.200 --> 00:55:59.280
In step 1, we
replace g of n by 0,
00:55:59.280 --> 00:56:03.464
thereby creating the situation
we already know how to solve.
00:56:06.330 --> 00:56:11.450
And we solve the
homogeneous recurrence--
00:56:11.450 --> 00:56:25.220
because you got a 0 there now--
but we don't go all the way.
00:56:25.220 --> 00:56:27.720
We ignore the boundary
conditions for now.
00:56:35.321 --> 00:56:37.320
So you don't get all the
way to the final answer
00:56:37.320 --> 00:56:39.420
where you plugged in
the boundary conditions
00:56:39.420 --> 00:56:41.510
to get the constant
coefficients.
00:56:41.510 --> 00:56:45.510
Leave the constant
coefficients undecided.
00:56:45.510 --> 00:56:55.420
Then in step 2, we
put back in g of n,
00:56:55.420 --> 00:57:05.880
and we find any what's called
particular solution, again
00:57:05.880 --> 00:57:08.126
ignoring boundary conditions.
00:57:08.126 --> 00:57:10.392
So you'll have the
constant factors there too.
00:57:20.141 --> 00:57:20.640
All right?
00:57:20.640 --> 00:57:24.990
And then step 3 is going to be
to put the whole thing together
00:57:24.990 --> 00:57:27.371
and plug in the boundary
conditions and solve it.
00:57:35.330 --> 00:57:41.675
So we add the homogeneous
and particular--
00:57:41.675 --> 00:57:54.420
and I'll show you how to
do step 2 in a minute--
00:57:54.420 --> 00:58:05.930
so we add the homogeneous and
particular solutions together
00:58:05.930 --> 00:58:08.570
and then use the boundary
conditions to get the answer.
00:58:30.560 --> 00:58:31.060
OK.
00:58:31.060 --> 00:58:32.110
So let's do an example.
00:58:35.750 --> 00:58:38.370
Let's go down here and do an
example of the three steps.
00:58:57.480 --> 00:59:00.780
So let's say that
our recurrence is
00:59:00.780 --> 00:59:09.190
this nasty-looking thing-- f
of n equals 4 f of n minus 1
00:59:09.190 --> 00:59:12.850
plus 3 to the n.
00:59:12.850 --> 00:59:19.240
And the boundary condition
is that f of 1 is 1.
00:59:19.240 --> 00:59:24.800
So step 1 says, ignore
this 3 to the n thing
00:59:24.800 --> 00:59:28.130
and get back to just the
homogeneous form, which
00:59:28.130 --> 00:59:32.490
is f of n minus 4 f
of n minus 1 is 0.
00:59:32.490 --> 00:59:33.720
So let's solve that.
00:59:33.720 --> 00:59:36.720
What's the
characteristic equation
00:59:36.720 --> 00:59:41.062
for the homogeneous part?
00:59:41.062 --> 00:59:42.520
What's the
characteristic equation?
00:59:45.789 --> 00:59:46.723
What is it?
00:59:46.723 --> 00:59:49.012
AUDIENCE: Alpha [INAUDIBLE].
00:59:49.012 --> 00:59:49.720
PROFESSOR: Close.
00:59:49.720 --> 00:59:52.873
It's-- you could either say
alpha to the n minus 4 alpha
00:59:52.873 --> 00:59:54.780
to the n minus 1.
00:59:54.780 --> 00:59:59.080
But better to simplify it
into an order 1 polynomial.
00:59:59.080 --> 01:00:04.470
So it would be alpha minus 4,
really simple in this case.
01:00:04.470 --> 01:00:06.950
So the characteristic
equation is alpha minus 4,
01:00:06.950 --> 01:00:12.850
alpha minus 4, all
right, equals 0.
01:00:12.850 --> 01:00:16.600
And it's really easy to
find the root of this thing.
01:00:16.600 --> 01:00:20.840
It's just alpha equals
4 is your only root.
01:00:20.840 --> 01:00:27.040
And that means the
homogeneous solution
01:00:27.040 --> 01:00:32.134
is f of n equals a
constant times 4 to the n.
01:00:34.761 --> 01:00:35.260
All right?
01:00:35.260 --> 01:00:36.150
So that's step 1.
01:00:43.670 --> 01:00:44.360
OK.
01:00:44.360 --> 01:00:48.155
Let's do step 2, which
we've not tried before.
01:00:51.910 --> 01:00:56.830
We need to find a
particular solution,
01:00:56.830 --> 01:01:04.520
and this just means
any old solution
01:01:04.520 --> 01:01:13.590
to f of n minus 4 f of n
minus 1 equals 3 to the n,
01:01:13.590 --> 01:01:15.970
without worrying about
boundary conditions.
01:01:15.970 --> 01:01:21.395
Now, there's basic rules
to use to figure out
01:01:21.395 --> 01:01:23.690
what to guess here.
01:01:23.690 --> 01:01:30.210
And basically, the idea is that
you guess something for f of n
01:01:30.210 --> 01:01:34.800
that looks a whole lot
like this g term out here.
01:01:34.800 --> 01:01:38.070
And in particular, if
this g term is 3 to the n,
01:01:38.070 --> 01:01:41.270
you guess a constant
times 3 to the n.
01:01:41.270 --> 01:01:44.680
If it's 5 to the n, you guess
a constant times 5 to the n.
01:01:44.680 --> 01:01:49.420
If it's n squared, you guess a
polynomial that's of degree 2
01:01:49.420 --> 01:01:51.590
and so forth.
01:01:51.590 --> 01:01:52.090
OK?
01:01:52.090 --> 01:01:58.920
So let's guess a
constant times 3 to the n
01:01:58.920 --> 01:02:01.560
and see if we can
make it work, not
01:02:01.560 --> 01:02:03.452
worrying about the
boundary conditions.
01:02:13.890 --> 01:02:16.346
All right.
01:02:16.346 --> 01:02:20.220
And this is just like
differential equations, right?
01:02:20.220 --> 01:02:22.400
Same guessing
strategy exactly you
01:02:22.400 --> 01:02:26.250
use in differential equations,
those of you who've had that.
01:02:26.250 --> 01:02:31.840
So we guess f of n equals a
constant times 3 to the n,
01:02:31.840 --> 01:02:34.320
and let's plug it in.
01:02:34.320 --> 01:02:37.640
So we plug that in up there.
01:02:37.640 --> 01:02:44.300
We get c3 to the n minus
c3 to the n minus 1
01:02:44.300 --> 01:02:47.601
equals 3 to the n.
01:02:47.601 --> 01:02:48.100
All right?
01:02:48.100 --> 01:02:50.240
So let's divide by
3 to the n here.
01:02:50.240 --> 01:02:56.710
We get 3c minus c equals 3.
01:02:56.710 --> 01:02:58.570
Did I do that right?
01:02:58.570 --> 01:03:01.815
No, I left off my 4 here,
right, left off that.
01:03:01.815 --> 01:03:02.830
So there's a 4 here.
01:03:06.150 --> 01:03:10.900
And that means
that c is minus 3.
01:03:10.900 --> 01:03:11.400
OK?
01:03:11.400 --> 01:03:15.600
So I got minus c equals
3, so c is minus 3.
01:03:15.600 --> 01:03:16.100
All right.
01:03:16.100 --> 01:03:27.860
That means that the particular
solution is just f of n
01:03:27.860 --> 01:03:36.060
equals-- c is minus 3--
minus 3 to the n plus 1.
01:03:36.060 --> 01:03:36.560
All right?
01:03:36.560 --> 01:03:41.370
So now I found a solution where
there's no constants involved.
01:03:41.370 --> 01:03:43.780
This time, the
constant went away just
01:03:43.780 --> 01:03:46.830
plugging into the
recurrence formula.
01:03:46.830 --> 01:03:49.130
I didn't use base cases yet.
01:03:49.130 --> 01:03:51.050
I just found a
particular case that
01:03:51.050 --> 01:03:56.980
works for the recurrence--
minus 3 to the n plus 1.
01:03:56.980 --> 01:03:59.492
OK?
01:03:59.492 --> 01:04:01.430
All right.
01:04:01.430 --> 01:04:02.546
Now we go to step 3.
01:04:19.300 --> 01:04:19.800
All right.
01:04:19.800 --> 01:04:30.670
Step 3, we find the
general solution
01:04:30.670 --> 01:04:33.520
by adding the homogeneous
and the particular solution.
01:04:37.850 --> 01:04:43.810
So we take f of
n equals c1 times
01:04:43.810 --> 01:04:50.790
4 to the n plus negative
3 to the n plus 1.
01:04:55.350 --> 01:04:58.660
And all I've got to
do is determine c1,
01:04:58.660 --> 01:05:01.894
and I do that from the
boundary conditions.
01:05:01.894 --> 01:05:02.560
Yeah, let's see.
01:05:02.560 --> 01:05:05.800
Where was my boundary
condition here?
01:05:05.800 --> 01:05:09.580
Ah, up there-- f of 1 is 1.
01:05:09.580 --> 01:05:12.690
So f of 1 equals 1.
01:05:12.690 --> 01:05:15.760
Plugging in 1 here,
I get c1 times 4
01:05:15.760 --> 01:05:21.430
to the 1 minus 3 squared.
01:05:21.430 --> 01:05:21.930
All right?
01:05:21.930 --> 01:05:25.120
So I have 4c1 minus 9.
01:05:25.120 --> 01:05:30.100
Put the 9 over here,
I get 10 equals 4c1.
01:05:30.100 --> 01:05:32.905
And that means that c1 is 5/2.
01:05:37.570 --> 01:05:39.870
And now I know the
final solution for f(n).
01:05:44.170 --> 01:05:49.845
It's 5/2 4 to the n
minus 3 to the n plus 1.
01:05:56.650 --> 01:05:58.244
Now, when you're
all done with this,
01:05:58.244 --> 01:05:59.660
you don't have--
we won't make you
01:05:59.660 --> 01:06:03.579
do an inductive proof, which you
could do to verify it's right.
01:06:03.579 --> 01:06:05.370
If you wanted to be
really, really careful,
01:06:05.370 --> 01:06:06.950
you should do that.
01:06:06.950 --> 01:06:10.952
But it is a good idea just
to check a couple values of n
01:06:10.952 --> 01:06:13.535
to make sure you didn't make a
mistake because you might have.
01:06:13.535 --> 01:06:16.440
With all these calculations,
you might have made a mistake.
01:06:16.440 --> 01:06:20.200
So let's check, for
example, f of 2.
01:06:23.000 --> 01:06:30.300
So by the recurrence,
f of 2 is 4 times
01:06:30.300 --> 01:06:39.960
f of 1-- it's 4 times 1-- plus
3 squared, which is 9, is 13.
01:06:39.960 --> 01:06:43.790
And let's just check
when we plug in 2 here.
01:06:43.790 --> 01:06:52.590
f of 2 is 5/2 times 16 minus 27.
01:06:52.590 --> 01:06:57.210
5 times 8 is 40, minus 27 is 13.
01:06:57.210 --> 01:06:58.920
Just as a sanity check.
01:06:58.920 --> 01:07:01.170
Because there's a decent
chance if you made a mistake,
01:07:01.170 --> 01:07:04.240
it'll catch it pretty
quick with n equals 2 or 3.
01:07:04.240 --> 01:07:04.740
All right?
01:07:04.740 --> 01:07:07.880
Just to make sure
you got it right.
01:07:07.880 --> 01:07:14.280
Any questions about that?
01:07:14.280 --> 01:07:16.630
So the tricky part
here is guessing
01:07:16.630 --> 01:07:18.730
the particular solution.
01:07:18.730 --> 01:07:24.250
So let me give you the rules
for that, just write those down,
01:07:24.250 --> 01:07:26.100
and maybe I'll do
one last example.
01:07:40.320 --> 01:07:40.820
All right.
01:07:40.820 --> 01:07:43.950
So we're guessing a
particular solution.
01:07:56.740 --> 01:08:03.570
So if g-- that's saying
the non-homogeneous part--
01:08:03.570 --> 01:08:14.660
is exponential, you should
try guessing an exponential
01:08:14.660 --> 01:08:15.880
of the same type.
01:08:20.740 --> 01:08:31.050
So for example, say that g is
2 to the n plus 3 to the n.
01:08:31.050 --> 01:08:37.050
What you should do is guess
some constant a times 2 to the n
01:08:37.050 --> 01:08:40.279
plus some constant
b times 3 to the n.
01:08:40.279 --> 01:08:43.340
Plug it in-- not to the
boundary conditions.
01:08:43.340 --> 01:08:47.520
Plug it into the recurrence
equation and solve for a and b.
01:08:47.520 --> 01:08:50.939
And it generally will work.
01:08:50.939 --> 01:09:00.450
If g is polynomial, you
should guess a polynomial
01:09:00.450 --> 01:09:01.420
of the same degree.
01:09:07.840 --> 01:09:21.109
So for example, say g of
n is n squared minus 1.
01:09:21.109 --> 01:09:33.050
You should guess-- let's
see-- guess an squared
01:09:33.050 --> 01:09:36.229
plus bn plus c.
01:09:36.229 --> 01:09:38.951
Plug that in for f of n.
01:09:38.951 --> 01:09:39.450
All right?
01:09:39.450 --> 01:09:44.186
So when we're doing these
guesses, we're guessing f of n.
01:09:44.186 --> 01:09:45.668
Same thing up here.
01:10:07.930 --> 01:10:10.800
Now, say you mixed two together.
01:10:10.800 --> 01:10:15.130
Suppose you have an
example where g of n
01:10:15.130 --> 01:10:18.710
equals 2 to the n plus n.
01:10:18.710 --> 01:10:22.359
What do you suppose
you do in that case?
01:10:22.359 --> 01:10:24.190
AUDIENCE: [INAUDIBLE]
to guess [INAUDIBLE].
01:10:24.190 --> 01:10:27.660
PROFESSOR: Yeah, guess each one
separately, add them together.
01:10:27.660 --> 01:10:33.550
So you're going to guess
f of n equals a times 2
01:10:33.550 --> 01:10:37.530
to the n plus bn plus c.
01:10:37.530 --> 01:10:38.110
All right?
01:10:38.110 --> 01:10:40.610
Because you take the guess for
that plus the guess for that.
01:10:44.050 --> 01:10:44.560
All right.
01:10:44.560 --> 01:10:48.540
Now, there's one last thing
that can go wrong here.
01:10:48.540 --> 01:10:53.841
And that is you can try your
guess, and it doesn't work.
01:10:53.841 --> 01:10:54.340
All right?
01:10:54.340 --> 01:10:55.940
So there's rules for that too.
01:10:58.460 --> 01:11:06.140
For example, if, say,
g(n) is 2 to the n
01:11:06.140 --> 01:11:13.440
and your guess of a times 2 to
the n, where a is a constant,
01:11:13.440 --> 01:11:14.575
fails.
01:11:14.575 --> 01:11:17.800
And we'll do an example in
a minute where it fails.
01:11:17.800 --> 01:11:22.900
What you do then is you guess
a polynomial times 2 to the n.
01:11:22.900 --> 01:11:28.630
So you'd guess an plus
b times 2 to the n.
01:11:28.630 --> 01:11:32.370
And if that fails,
your next guess
01:11:32.370 --> 01:11:39.130
would be an squared plus
bn plus c times 2 to the n.
01:11:39.130 --> 01:11:41.670
And it won't happen,
but if that failed,
01:11:41.670 --> 01:11:43.820
you'd guess a cubic
times 2 to the n.
01:11:43.820 --> 01:11:47.480
You keep pounding it with
another factor of n in front
01:11:47.480 --> 01:11:50.030
if the guess fails.
01:11:50.030 --> 01:11:52.260
And that's true
for anything at all
01:11:52.260 --> 01:11:55.167
you would be doing like
this, and that'll work.
01:11:55.167 --> 01:11:57.500
And I don't think I've ever
encountered an example where
01:11:57.500 --> 01:12:00.760
you have to go very
far to make that fly.
01:12:04.180 --> 01:12:06.260
Same thing we had
for repeated roots
01:12:06.260 --> 01:12:09.310
in the characteristic equation.
01:12:09.310 --> 01:12:11.610
Multiply those factors
of n in front of it
01:12:11.610 --> 01:12:13.811
to get to the answer.
01:12:13.811 --> 01:12:14.310
All right.
01:12:14.310 --> 01:12:17.210
Let's do one more
example where it fails,
01:12:17.210 --> 01:12:18.832
so we get to see what happens.
01:12:39.970 --> 01:12:48.470
Let's try this recurrence--
f of n is 2 f of n minus 1
01:12:48.470 --> 01:12:51.400
plus 2 to the n.
01:12:51.400 --> 01:12:56.870
And the boundary
condition is f of 0 is 1.
01:12:56.870 --> 01:13:02.090
What's the first
thing I do for this?
01:13:02.090 --> 01:13:04.450
AUDIENCE: Set it equal to 0.
01:13:04.450 --> 01:13:06.515
PROFESSOR: Set it equal
to 0 and solve it.
01:13:06.515 --> 01:13:07.962
Get the homogeneous solution.
01:13:13.240 --> 01:13:13.820
OK.
01:13:13.820 --> 01:13:16.740
So what's the
characteristic polynomial?
01:13:20.290 --> 01:13:24.520
Alpha minus 2 is 0.
01:13:24.520 --> 01:13:26.541
What's my root?
01:13:26.541 --> 01:13:27.040
2.
01:13:29.790 --> 01:13:33.550
And therefore, my
homogeneous solution
01:13:33.550 --> 01:13:36.460
is c1 times 2 to the n.
01:13:36.460 --> 01:13:38.900
Well, that's pretty simple.
01:13:38.900 --> 01:13:39.892
What's the next step?
01:13:43.860 --> 01:13:45.983
What do I have to find next?
01:13:45.983 --> 01:13:46.858
AUDIENCE: Particular.
01:13:46.858 --> 01:13:48.334
PROFESSOR: Particular solution.
01:13:52.762 --> 01:13:53.270
All right.
01:13:53.270 --> 01:13:55.282
So what am I going to guess?
01:14:00.210 --> 01:14:01.690
a times 2 to the n.
01:14:04.260 --> 01:14:05.340
All right?
01:14:05.340 --> 01:14:08.110
So let's plug that in,
a times 2 to the n.
01:14:08.110 --> 01:14:10.720
I'm going to plug it in to here.
01:14:10.720 --> 01:14:18.100
So I get a 2 to the n
equals 2 times a times 2
01:14:18.100 --> 01:14:23.200
to the n minus 1
plus 2 to the n.
01:14:23.200 --> 01:14:24.760
Did I do that right?
01:14:24.760 --> 01:14:27.190
Think so.
01:14:27.190 --> 01:14:29.962
So I get 2 to the n, 2
to the n, 2 to the n.
01:14:29.962 --> 01:14:36.040
I get a equals a plus 1.
01:14:36.040 --> 01:14:38.510
Not so good.
01:14:38.510 --> 01:14:39.650
All right?
01:14:39.650 --> 01:14:42.586
There's no solution for a.
01:14:42.586 --> 01:14:44.181
Well, that's bad.
01:14:44.181 --> 01:14:44.680
All right.
01:14:44.680 --> 01:14:45.960
So what do I do?
01:14:52.701 --> 01:14:54.576
Any thoughts about what
I'm going to do next?
01:14:57.414 --> 01:14:58.360
AUDIENCE: [INAUDIBLE].
01:14:58.360 --> 01:14:58.940
PROFESSOR: What is it?
01:14:58.940 --> 01:15:00.240
AUDIENCE: Change your guess.
01:15:00.240 --> 01:15:01.200
PROFESSOR: Change the guess.
01:15:01.200 --> 01:15:02.616
What's the next
guess going to be?
01:15:06.780 --> 01:15:07.580
Yeah, all right.
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.
01:15:18.630 --> 01:15:19.840
We'll hope for better luck.
01:15:19.840 --> 01:15:23.020
So let's plug that in.
01:15:23.020 --> 01:15:32.100
an plus b 2 to the n into--
where am I, up there--
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
01:15:42.013 --> 01:15:44.435
to the n.
01:15:44.435 --> 01:15:45.130
All right.
01:15:45.130 --> 01:15:48.325
Now, I can divide out the 2 to
the n's here like I did before.
01:15:51.000 --> 01:16:04.510
And I get an plus b equals
an minus a plus b plus 1.
01:16:04.510 --> 01:16:09.240
That cancels here, b cancels.
01:16:09.240 --> 01:16:13.511
So I got a solution--
a equals 1.
01:16:13.511 --> 01:16:15.500
And I don't care what b is.
01:16:15.500 --> 01:16:17.910
I didn't need to
set it to anything.
01:16:17.910 --> 01:16:20.880
So I'll make it 0 just
to get it out of the way
01:16:20.880 --> 01:16:22.960
because it didn't matter.
01:16:22.960 --> 01:16:31.375
So my particular solution
then is f of n-- a is 1.
01:16:31.375 --> 01:16:34.370
b I can just make 0 because
it didn't matter what I used,
01:16:34.370 --> 01:16:35.790
so I'll make it simpler.
01:16:35.790 --> 01:16:38.634
So I get n 2 to the n.
01:16:38.634 --> 01:16:39.884
That's my particular solution.
01:16:42.810 --> 01:16:46.190
And I've got my general
solution up there as c1 times 2
01:16:46.190 --> 01:16:48.830
to the n-- sorry, the
homogeneous solution.
01:16:51.530 --> 01:16:53.339
What's the next step?
01:16:59.207 --> 01:17:00.300
What's step 3?
01:17:04.570 --> 01:17:07.955
What do I do with these
guys, this solution
01:17:07.955 --> 01:17:09.387
and that solution?
01:17:09.387 --> 01:17:10.532
[? AUDIENCE: Add them. ?]
01:17:10.532 --> 01:17:11.740
PROFESSOR: Add them together.
01:17:11.740 --> 01:17:12.240
Good.
01:17:12.240 --> 01:17:23.380
So the general solution is I
have f of n is the sum of c1 2
01:17:23.380 --> 01:17:27.700
to the n plus the particular
solutions n 2 to the n.
01:17:27.700 --> 01:17:31.189
How do I figure out what c1 is?
01:17:31.189 --> 01:17:32.730
AUDIENCE: Plugging
in to [INAUDIBLE].
01:17:32.730 --> 01:17:37.050
PROFESSOR: Plugging in the
boundary condition-- f(0)
01:17:37.050 --> 01:17:38.275
equals 1.
01:17:38.275 --> 01:17:40.400
f(0) equals 1.
01:17:40.400 --> 01:17:47.240
Plug in 0, I get c1
2 to the 0 plus 0.
01:17:47.240 --> 01:17:51.390
Well, that's pretty
easy. c1 equals 1.
01:17:51.390 --> 01:17:54.230
So I now have the final answer.
01:17:54.230 --> 01:17:59.940
f of n equals 2 to the
n plus n 2 to the n.
01:17:59.940 --> 01:18:00.777
All right?
01:18:00.777 --> 01:18:01.360
Any questions?
01:18:05.730 --> 01:18:06.230
OK.
01:18:06.230 --> 01:18:09.740
So it's a little
tedious to do this.
01:18:09.740 --> 01:18:12.560
But the really nice thing
is any linear recurrence
01:18:12.560 --> 01:18:17.390
you ever see, this method
always works, which is handy.
01:18:17.390 --> 01:18:17.890
OK.
01:18:17.890 --> 01:18:20.040
That's it for today.