Current time:0:00Total duration:7:27

# Taylor & Maclaurin polynomials intro (part 2)

## Video transcript

In the last several
videos, we learned how we can approximate
an arbitrary function, but a function that is
differentiable and twice and thrice differentiable
and all of the rest. How we can approximate a
function around x is equal to 0 using a polynomial. If we just have a
zero-degree polynomial, which is just a constant,
you can approximate it with a horizontal line that
just goes through that point. Not a great approximation. If you have a
first-degree polynomial, you can at least get the
slope right at that point. If you get to a
second-degree polynomial, you can get something that
hugs the function a little bit longer. If you go to a
third-degree polynomial, maybe something that hugs
the function even a little bit longer than that. But all of that was
focused on approximating the function around
x is equal to 0. And that's why we call it the
Maclaurin series or the Taylor series at x is equal to 0. What I want to do now is
expand it a little bit, generalize it a little bit, and
focus on the Taylor expansion at x equals anything. So let's say we
want to approximate this function when x--
so this is our x-axis-- when x is equal to c. So we can do the
exact same thing. We could say, look,
our first approximation is that our polynomial
at c should be equal to-- or actually, even let me better
it-- our polynomial could just be-- if it's just
going to be a constant, it should at least
equal to function whatever the
function equals at c. So it should just equal f
of c. f of c is a constant. It's that value
right over there. We're assuming that c is given. And then you would
have-- this would just be a horizontal line
that goes through f of c. That's p of x is
equal to f of c. Not a great
approximation, but then we could try to go for having
this constraint matched, plus having the
derivative matched. So what this constraint
gave us-- just as a reminder-- this gave
us the fact that at least p of c, the approximation at c,
our polynomial at c, at least is going to be equal
to f of c, right? If you put c over
here, it doesn't change what's on
the right-hand side, because this is just
going to be a constant. Now, let's get the
constraint one more step. What if we want a situation
where this is true, and we want the derivative
of our polynomial to be the same thing as the
derivative of our function when either of them are at c. So for this situation, what
if we set up our polynomial-- and you'll see a
complete parallel to what we did in earlier videos. We're just going to shift
it a little bit for the fact that we're not at 0. So now, let's define p of x
to be equal to f of c plus f prime of c. So whatever the slope is at this
point of the function, whatever the function slope
is, times-- and you're going to see something
slightly different over here-- x minus c. Now, let's think about
what this minus c is doing. So let's test, first of
all, that we didn't mess up our previous constraint. So let's evaluate this at c. So now, we know that
p of c-- and I'm using this exact
example-- so p of c-- let me do this in a new color. Let me try it out. So p-- that's not a new color. p of c is going to be equal
to f of c plus f prime of c times c minus c. Wherever you see an x, you
put a c in there. c minus c. Well, this term right over
here is going to be 0. And so this whole term right
over here is going to be 0. And so you're just left with
p of c is equal to f of c. You're just left with that
constraint right over there. And the only reason why
we were able to blank out this second term right over here
is because we had f prime of c times x minus c. The x minus c makes all of the
terms after this irrelevant. We can go now verify
that this is now true. So let's try-- p
prime of x is going to be the derivative of this,
which is just 0, because this is going to be a constant,
plus the derivative of this right over here. And what's that going to be? Well, that's going to be--
you can expand this out to be f prime of c
times x minus f prime of c times c, which
would just be constant. So if you take the derivative
of this thing right here, you're just going to be
left with an f prime of c. So the derivative of our
polynomial is now constant. So obviously, if you
were to evaluate this at c, p prime at c, you're
going to get f prime of c. So once again, it meets
the second constraint. And now when you have
both of these terms, maybe our approximation will
look something like this. It will at least have the
right slope as f of x. Our approximation is
getting a little bit better. And if we keep doing
this-- and we're using the exact same logic
that we used when we did it around 0, when we did
the Maclaurin expansion-- you get the general Taylor
expansion for the approximation of f of x around c
to be the polynomial. So the polynomial p of x
is going to be equal to-- and I'll just expand it out. And this is very similar
to what we saw before. f of c plus f prime
of c times x minus c. You might even guess what the
next few terms are going to be. It's the exact same logic. Watch the videos
on Maclaurin series where I go for a few
more terms into it. It becomes a little
bit more complicated taking the second and
third derivatives, and all of the rest
just because you have to expand out
these binomials, but it's the exact same logic. So then you have plus
your second-degree term, f prime prime of c,
divided by 2 factorial. And this is just like what we
saw in the Maclaurin expansion. And just to be
clear, you could say that there's a 1
factorial down here. I didn't take the
trouble to write it because it doesn't
change the value. And then that times
x minus c squared plus the third derivative
of the function evaluated at c over
3 factorial times x minus c to the third power. And I think you get
the general idea. You can keep adding more and
more and more terms like this. Unfortunately, it makes
it a little bit harder, especially if you're
willing to do the work. It's not so bad, but instead of
having just x here and instead of just having an
x squared here, and having an (x-c) squared having an (x-c) to the third,
this makes the analytical math a little bit hairier, a
little bit more difficult. But this will
approximate your function better as you add
more and more terms or on an arbitrary value
as opposed to just around x is equal to 0. And I'll show you that using
WolframAlpha in the next video.