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

0 energy points

Ready to check your understanding?Practice this concept

# Generalized Taylor series approximation

Approximating a function around a non-zero x value. Created by Sal Khan.

Video transcript

In the last several videos, we learned how
we can approximate and arbitrary function, but a function that is differentiable and twice and thrice differentiable and all
the rest. How we can approximate a function around x
is equal to 0. Using a polynomial, if we, if we just have
a first degree poly, or I should say a
zero-th 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, 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 around, was focused on approximating the function around x is
equal to zero. And that's why we called it Maclaurin
series or the Taylor series at x is equal to zero. 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 f of, is that our polynomial, our polynomial at c should be equal to, or actually even let me better, our
polynomial could just be at least, if it's just going
to be a constant, if it's gonna be constant, it should at least equal to a 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 can try to go for this, having this constraint
mashed. Plus having the derivative mashed. 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 her it doesn't change
what's on the right hand side because this is just
going to be constant. Now let's get the constraint one more
step. What if we want a situation where, 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 why don't we set up
our polynomial and you'll see a complete parallel to what we
did in earlier videos. We are just gonna shift it a little bit
for the fact we're not at 0, so now is to find P of X to be equal to F of C, F of C plus F prime of C, plus F prime of C. So what ever the sloop is at this point of the function, what ever the function
sloop is. Times and you're gonna see something
slightly different over here. X minus c, and let's think about why we
put this, what this minus c is doing, what this
minus c is doing. So let's test first off all that we didn't
mess up. Our previous constraint. So, let's evaluate this at c, so now we
know that p is c and I'm using this exact
example. So p is c, I'm just a new color and we try
it out. So p, that's not a new color, p of c, 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 gonna be
0. And so this whole term right over here is
going to be 0. And so you're just left with, 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 last, this second term right over here is because it, we had f
prime of z, 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, so p prime of c. P or I should say p prime of x. P prime of x is going to be the derivative
of this, which is just zero 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 could 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, f
prime of c. So the derivative of our polynomial is now constant so obviously, 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, it meets the
second constraint. And now, when you have both of these terms, maybe our approximation will look
something like this. It'll at least have the right slope. It'll 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, the Taylor expansion, 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, and I'll just expand it
out. And this is very similar to what we saw
before. F(c) + f'(c) (x-c) you might even guess
what the next few terms are going to be. It's the exact same logic. Watch the videos of mclorance here as a go
few more terms into it. It gets a little more complicated taking the second and third derivatives and all
of the rest just because you have, you have
to kind of expand out theses binomials. But it's the exact same logic. So then you have plus your second degree
term. Your second degree. 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, there's, you could
say that there's a 1 factorial down here. I didn't take the trouble to write it,
'cuz it doesn't change the value. And that then times x minus c squared plus
the 3rd 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
have, you know, if you're willing to do the
work. It's not so bad, but this, adding this x,
instead of having just x here and instead of just having an x
squared here, having an x minus c squared and having an x minus c
to the 3rd, 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. Around an arbitrary value as opposed to
just around x is equal to zero and I'll show you that using
WolframAlpha in the next video.