So in the previous lecture, we have found out that the central differences method is much better than
the forward and to back what differences methods.
So this is maybe a bit surprising because when we scroll up our notebook and go back to the very beginning,
we found that mathematically speaking, the three methods are exactly the same.
But this is only true if we take the limit of age to zero, which is something that we cannot precisely
do in the Marek's.
So in the metrics, we always have this approximation and the derivative is never really perfect.
So of course it can happen.
Then one of the methods works better than than one of the other methods.
And in this lecture, I want to show you mathematically why this is the case and to figure this out,
we used to so-called big own notation, and the big o notation tells us which order are the following
terms that we are leaving out here.
So previously, our roads that this derivative here is only approximately the same as this term, and
the error that leads to the approximate instead of the equals sign is given by this big arrow here.
And it turns out that the forward and backward differences is has an error of order h and the central
difference.
This method has an error of the Order H Square.
So this means the remaining terms here that are missing due to for for these terms to be equal, the
missing terms of order a square and higher.
So there is no term of order H.
And when H is a very small number like zero point zero one or in our case, also 0.1 and we squared
this number, then it becomes even smaller.
So a zero point one square is zero point zero one.
So here the error is some constant times zero point zero one.
And here the error is some constant times zero point one.
So, of course, the error is much smaller for the central differences method.
So why is the error of Order H Square?
This is something that we can really show analytically.
And for this, we need to rely on our Taylor expansion methods, and we need to assume that we can Taylor
expand our function f at some point, which is, of course, true if it's a continuous function.
So we can say we start from our Point X. So we want to expand the function if we want to know the value
of the function at the point X plus h instead.
And if we expand our function around the Point X, this works as follows.
We write F of x plus first derivative of X Times H plus one of a two second derivative of X times a
square, then one of two times three times three derivative of F times H two.
The power of three.
And then so on and so on.
So here then there come the fourth or the terms five fifth, all the terms and so on.
But we only need these terms for the derivation.
But of course, we can also do the same thing for finding the the value of the function at the point
X minus h.
And again, we expend around to point X. And this time we get the result, which is pretty similar.
But instead of having H and this function, we have minus h.
So this will mean this term, if you will change the sign, this one will stay because it's H Square
and this one will also change the sign.
And so every second term will have a different sign.
But besides that, these two functions are the same.
Now, from the first line, individually, we can immediately see that the four what difference this
method is of order H.
And from the second line, we can see that the backwards differences method is of Order H.
Let me show you how this works.
We basically solve this equation.
And also this this equation for the first derivative of F at the Position X, because this is what we
want, after all.
So what we do is we bring this to the other side.
Then we bring this to the other side and then we account for the negative sign here.
And so what we get is then f derivative of x times h is equal to minus f of x plus f of x plus h minus
one half this term, minus one of a sixth this term and so on and so on.
And then we have here also the factor h and we divide by age, and this gives us what is written down
here.
We have the first derivative of F at the position X is equal to one over H and then all of these terms
that I have just mentioned.
So this will be this term than negative this term, negative this term, negative this term.
And when you look at these two terms and divide by age, this is exactly what we have here for the forward's
differences.
So we have here our forward differences solution and then we have additional terms.
And the first term will be minus one over two times second derivative Times Square.
But we divide by age, so it's only an age here.
And then the other terms are of higher order.
We have to each square a short par three and so on and so on.
So we can summarize and say that all of these terms here are the error of our forwards differences methods.
And they are of older age and higher.
So this is why, right?
Order of age.
And this will be the main term that determines the error.
And these will, of course, also determine the arrow.
But they will be much smaller.
And for the backwards differences methods, we take the second equation.
And of course, we do the same thing.
We bring this one to the left side.
This one to the right side.
And we divide by age.
And so this time we have here different signs or most of these terms will change their sign.
So we have such an expression here.
And so this will here be a lot back.
What's difference this term?
And this one divided by age will be our arrow.
So once again, it's of older age to the power of one, and then we have also higher terms.
However, here I wrote down that the central differences term has an arrow of older age square.
So there is no term proportional to age.
And here is why this is the case.
So I wrote down to find this older H2 dependence.
We have to subtract the two terms, so we have to subtract these two equations from each other.
So the left side will become f of x plus h minus f of x minus h is equal to these two terms will cancel.
These two terms will then add up because we have this term minus minus this term.
So we have two times first derivative of F times h and then these two terms will cancel again and these
two terms will add up again.
So here we have one of the three third derivative and then h to the power three.
And now you see, this is here the denominator of this function here of the central difference, this
method.
So we divide by two h and then we have this term.
So we have one over two h times.
This one is equal to the first derivative of F at the position X and then the next term will be this
term third derivative and h two the power of two.
So this means when we solve for this one, that this is equal to the expression that we had above this
was the central differences method.
And then the first term that appears will be one of a six third derivative of F and an H to the power
of two.
And so this is an arrow of the order h square.
And the very reason for this not to be power one is that these two terms cancel out when we subtract
these two terms.
And this is the whole trick for finding new methods to calculate derivatives with a lot.
With a smaller arrow, we have to combine several different terms so that our rules of Law Order will
cancel out.
And this is really a trick that is used very often, and we will explore this also in the next lecture
that we will use a function or methods that allows us to calculate the derivative of a function with
a much higher accuracy.