Numerical Diff of Continuous Functions - First Derivative: Backward Divided Diff
|
In this segment we'll talk about
how to find the first derivative of a function by using Backward Divided
Difference method. We will also take an example to see how to do that. Let's
go and see how the Backward Divided Difference method works for the first
derivative of the function. So, let's suppose somebody gives
you a function, and says that hey I want to find the value of the derivative
of the function at this particular point. And the Backward
Divided Difference method means that you're going backwards so you're going
to take a step here let's suppose you want to say i'm
going to take a step which is h behind x, so this point here will be x minus
h hence. So, we're going to look at this particular
coordinate which will be the x value will be x minus h, the y value be
the value of the function at that particular point, this coordinate here will
be x comma f of x. What you're going to do is you're going to draw a secant
line now from this point here to this point here and you're going to find the
slope of that secant line, and which will approximate the derivative of the
function, first derivative of the function at the value of x. So, we've got
to basically look at rise over run. So, if you look at this rise here it is
nothing but the value of the function at x, minus the value of the function
at x minus h. And if you look at the run, the run is just h as we've already
found out. And so, if I want to look at the approximation of the first
derivative of the function f prime of x will be
approximately equal to the rise which is this quantity right here, over run
which is this. Let's go and see how we can use this in example. So, let's
look at the example which we're asked to solve by the Backward Divided
Difference method to find the first derivative of the function. So, we are given the function is
7 x to the power 4, a step size of 0.16. We're asked to use the backward
divided difference formula to calculate the derivative of the function at 3
the true value at that particular at that particular point.
And the reason why we're asking for the true value so that you can appreciate
hey what it means that how much true error we are getting we are also asked
to see how the true error changes as we change the step size. And since we
won't be privy to the true value when we are using numerical methods to
calculate our derivatives of the functions, we're also asked to see that hey,
can we make some sense of the absolute relative approximate error when we try
to relate to the number of significant digits which are at least correct as
our step size is decreased. So, let's go and take each of these one at a time
and we'll be able to go through this exercise here. So, let's go and do part
a where we're asked to calculate the value of the derivative of the function
by using the backward divided difference formula, which is given as follows.
The derivative has to be found at x equal to 3 with
a step size of 0.16. So, what does f prime of 3 turn out to be? Then it will
be approximately the value of the function of 3, minus the value of the
function at 3 minus 0.16, divided by 0.16. That turns out to be equal to the
value of the function at 3, minus the value of the function at 2.84. So, all
we have to do now is since our function is given as
7x to the power 4, let's go and see that what we get from there. So, it'll be
7, 3 to the power 4 minus 7, 2.84 raised to the power 4, raised to the power
4, divided by 0.16. And this number here when you calculate it turns out to
be 697.6417. So that's part a. Let's go and see what we do for part b. So, in part b we are asked to
calculate the exact value of the derivative so this is the function f prime of x would be 7 times 4 x cubed and that's 28 x cubed. But we are interested in finding the exact
value of the derivative of the function at 3, so it's 28 times 3 cubed. And
that number turns out to be 756. So, we can now, in part c, calculate what
the true error is the true error is what it is the true value and also sometimes called the exact value, minus the
approximate value. The true value which you just calculated which we just
calculated was 756. What was the approximate value which we just calculated
in part a was as follows? And we subtract the two quantities, we get 58.3583.
So here we are asked to calculate what the to show what the effect of the
true error is or what the effect of the step size is on the true error. So,
let's go and tabulate these numbers here for the true error. Our exact value of course by
calculating the differential calculus from the differential calculus class
turns out to be 756 for f prime of three. So when I had a step size of 0.16
which we just did the problem, we got this as our value, and the true error
also we calculated, and now what we do is let's suppose if we halve the step
size, halve the step size, then in that case what we get by following the
same calculations as we had previously, we get this as the approximate value,
and the true error corresponding to this turns out to be this quantity here. And
same thing let's suppose we halve the step size again to 0.04, let’s suppose,
we get this as our value of the derivative of the function at 3. And the true
error here in this case turns out to be as follows. So, one of the things
which you got to see is that as we are decreasing our step size, what is
happening is the approximate value is getting closer and closer to the exact
value here, you're also finding out that the true error is decreasing, of
course, but also what you got to think about is that see how the true error
is decreasing. As you are having the step sizes size what is happening is
that the true error is also getting approximately quartered guys it's getting
approximately quartered[JP1] . 58 half is about 29, 29 half
is about 14.5. So, you’re getting here that's getting approximately half. And
this has to be noted down because as we do in the future lessons
we will talk about the order of accuracy of each of these methods or we'll
talk about why do we get such order of accuracy. So, for example in this case we
are finding just from this experimental data, or not experimental data but
numerical data, that as we are having the step size that the true error is
getting approximately halved. Is there some reason to it can we show that
that is really the case? In the last part we are asked to find out hey, can
we talk about the absolute relative approximate error as we keep on changing
decreasing our step size, and is there any relationship to the absolute
relative approximate error? So, let's go and put h here, we'll put f prime of
3 here, we're going to show hey what is the approximate error and what is the
relative absolute relative approximate error let's put it that way. So, we
just calculated what the value of 0.16 f prime of 3 is, which was 697.6417. We
cannot calculate the approximate error or the relative approximate because
that's the step size we started with, but let's suppose if I go ahead and
have the step size, I will get these as my values, and the approximate error
will be 14 point sorry the approximate error in this case will be this much. This
approximate error is simply calculated from the current approximation, minus
the previous approximation. This is the current approximation and that's the
previous approximation. And that's what we get as the approximate error. The
relative approximation will turn out to be equal to absolute value will be 3.9450%.
Which is simply calculated from the approximate error divided by the current
approximation, absolute value multiplied by 100. So, if I further go ahead
and decrease the step size of 0.04, the approximate value turns out to be as
follows: approximate error turns out to be this one, so that's simply the
current approximation minus previous approximation, and the relative
approximation in this case turns out to be as follows. So, the reason why we talk about
this approximate error business is because we won't be privy to the exact value
because the reason why we're using numerical method would be because hey we
don't know the exact value. So how do we account for that how good our
solution is, is based on simply calculating the value of the derivative of
the function in this case with different step sizes and seeing what effect it
has on the absolute relative approximate error. So, if we take this number
right here it is less than 5%, but not less than or equal to 0.5%, which
leads us to believe that we can only trust one significant digit uh in this
number right here. So, we have f prime of 3 approximately equal to 741.0140, and
since our absolute relative approximate is only less than 5% but not 0.5%, we
can only trust the first significant digit which is 7 in this case. If you
continue to decrease the step size further in this case what you're going to
find out is that you'll start getting absolute relative approximate errors
which are much smaller, and hence give you the number that hey you are going
to get less significant digits you're going to get more significant digits
correct in your answer. And that's the end of this segment. |
[JP1]I
believe Dr. Kaw misspoke here, this should be halved no?