.
.
In this segment, we're going to
find out how to do numerical differentiation for higher order derivatives.
.
.
So, for example, let's go ahead and take an example, that's how . . . what we mean by higher order derivatives is that we already 
looked at how to numerically differentiate a first . . . for the first derivative,
to find f prime of x, given the function f of x, how can you find f prime of x?|So let's suppose somebody wants you
to find out an approximation for the second derivative
of a function, how do we go about doing that?|And we're going to use Taylor series to find an approximation
for the second derivative of the function.|How can we numerically find out the second derivative of a
function?|So if we look at the Taylor series, the Taylor series says
that I can give you the value of the function at some other point if you can
give me the value of the function at x, you can give me the value of the first derivative,
you can give me the value of the second derivative,
you can give me the value of the third derivative,
you can give me the value of the
fourth derivative, let's suppose,
and so on and so forth, I can give you the value of the function at any other point.|So, if
you know the value of the function at x, you know the value of the derivative of the function at x, the second derivative of the
function at x, third derivative, fourth derivative, and all the other derivatives, because there's infinite
order of derivatives you need, then you can give me the value of the function at some point
h ahead of x.|Of course, all these derivatives need to be defined and continuous between x
and x plus h, only there it is possible.|So, we're going to
use this Taylor series expansion to be able to find out what the
numerical formula would be for finding the derivative . . . second derivative of a function,
f here.|Now, since I have this, I know that if I, instead of x . . .
instead of h, I put x minus h, I'll get this, I'll get f of x, plus
f prime of x times -h, right, then
plus f double-prime of x times -h
squared divided by 2 factorial, plus f triple-
prime of x times -h cubed
by factorial 3, plus f
fourth derivative of x times -h raised power 4 divided by
4 factorial, and so on and so forth.|So if you look at this particular formula
here, so I want you to pay close attention to this formula here, the only difference which I have done is that instead
of h, I substituted -h from this formula here.|So we had this formula written for
x plus h, now what I did was I took, instead of h, I put -h.
So what happens in this particular formula here is that you're going to just substitute for h, you're going to substitute -h,
and that's what you're going to get.|Now, what I want you to pay close attention to is that what I'm going to do is I'm going to add
these two . . . these two equations here, I'm going to add these two equations, so what's going to happen is that
this is going to be added to this, this is going to get added to this, but there are certain things which are going to
cancel, you see this is f prime of x times -h, and this is f prime of x times +h,
so when I add the two equations, this is going to cancel with this.|However, this is not
going to cancel with this, the reason why that is so is because -h squared is h squared
itself, so when I add the two, they're going to get added up.|Same this that's going to happen here is
that I have h cubed here, but I have -h cubed here, in this part of the
formula, so that's going to get . . . that's going to get added together, and it will become 0
there.|So, having said that, let's go ahead and see that what happens when I add the two
equations, so add the two equations.
This is what I get, I get f of x plus h,
plus f of x minus h is equal to 2
times f of x, and the first derivative term gets . . .
gets canceled, then I have f prime of x times
h squared, because those two terms get added, and since I have 2 factorial in the
denominator, but I'm adding it two times, so that cancels that, and then
I'm left with the plus f . . . the third
derivative terms get canceled out, so I'm left with the fourth derivative term, x divided by
4 factorial times 2 times h to the power 4,
plus so on and so forth, so that's what I'll be left with.|So I'll have
the zeroth derivative term, which is f of x, the second derivative term, and then the
fourth derivative term, and then I'll have the sixth derivative term and so on and so forth.|So you can very well
see that this is 2 times f of x plus f double-prime
of x times h squared, plus the order of the h to the power 4 terms.
So, what I am trying to basically say is that if I bundle all these terms which are left off here,
h to the power 4 term, h to the power 6 term, h to the power 8 term, if I would have taken more terms of
the Taylor series, then the order of those terms is simply
h to the power 4.|So I have 2 f of x plus f double-prime of x h squared
plus the terms which are of the order of h raised power 4.|Now I'm going to rewrite this,
so let me rewrite this on the next board here.|I'll get f of x plus h,
plus f of x minus h is equal to
2 times f of x, plus f double-prime of x times
h squared, plus the order of the h to the power 4
terms, keep in mind this is order of h to the power 4 terms.|Now,
since I wanted an expression for f double-prime of x, what I'll do is I'll get f double-prime of x
is equal to, I'm going to take this to the left-hand side, and divide . . . this also to the left-hand side,
and divide by h squared, so I'm going to get f of x plus h, which is this term
here, minus 2 times f of x term, which is right here, then
f of x minus h term here, right here, and
I'm going to divide by h squared here, because that's the h squared here,
then I'll have the plus of the order of h raised power 4 terms, it doesn't matter when you take it to the left-hand side it becomes a
negative order of h raised power 4 term, but it's still order of the h raised power 4 term, divided by
h squared.|So what I find out is that f double-prime of x
is approximately equal to f of x plus h minus 2 times
f of x, plus f of x minus h, divided by h squared.
So if I leave out the terms of these, then it is . . .
then it's just the first three terms here divided by h squared, that's the approximation for the second
derivative of the function.|Now this, here, because I'm dividing order of the
h power 4 terms by h squared terms, this becomes of the order of h squared . . .
this becomes of the order of h squared, so since this becomes the order of h squared,
what that means is that the amount . . . that accuracy of this formula which we just derived
here will be of the order of the square of the step size.|What that means is that
if I double the step size, the error is going to get quadrupled, or if I halve the step size
when I am conducting this . . . using this particular formula here for the second derivative of the
function, then it will get quartered.|So that's why I continue
to take this term of what the order of the terms which are left over are, because that gives you an
indication of the accuracy of the divided difference formula which you are calculating
for these derivatives of a function.|So that is the . . . that is
one of the approximations, one of the numerical differentiation approximations
for the second derivative of a function.|And that's the end of this segment.
.
.
.
