1
00:00:00,360 --> 00:00:06,240
So in the previous lecture, we have found out that the central differences method is much better than

2
00:00:06,240 --> 00:00:08,640
the forward and to back what differences methods.

3
00:00:09,780 --> 00:00:15,570
So this is maybe a bit surprising because when we scroll up our notebook and go back to the very beginning,

4
00:00:16,050 --> 00:00:21,300
we found that mathematically speaking, the three methods are exactly the same.

5
00:00:22,050 --> 00:00:29,610
But this is only true if we take the limit of age to zero, which is something that we cannot precisely

6
00:00:29,610 --> 00:00:30,630
do in the Marek's.

7
00:00:31,710 --> 00:00:38,280
So in the metrics, we always have this approximation and the derivative is never really perfect.

8
00:00:38,700 --> 00:00:39,930
So of course it can happen.

9
00:00:39,930 --> 00:00:43,830
Then one of the methods works better than than one of the other methods.

10
00:00:44,880 --> 00:00:53,190
And in this lecture, I want to show you mathematically why this is the case and to figure this out,

11
00:00:53,190 --> 00:01:01,860
we used to so-called big own notation, and the big o notation tells us which order are the following

12
00:01:01,890 --> 00:01:03,660
terms that we are leaving out here.

13
00:01:04,410 --> 00:01:12,090
So previously, our roads that this derivative here is only approximately the same as this term, and

14
00:01:12,600 --> 00:01:20,430
the error that leads to the approximate instead of the equals sign is given by this big arrow here.

15
00:01:21,090 --> 00:01:28,680
And it turns out that the forward and backward differences is has an error of order h and the central

16
00:01:28,680 --> 00:01:29,070
difference.

17
00:01:29,070 --> 00:01:32,070
This method has an error of the Order H Square.

18
00:01:32,730 --> 00:01:39,780
So this means the remaining terms here that are missing due to for for these terms to be equal, the

19
00:01:39,780 --> 00:01:42,990
missing terms of order a square and higher.

20
00:01:43,350 --> 00:01:45,750
So there is no term of order H.

21
00:01:46,680 --> 00:01:54,630
And when H is a very small number like zero point zero one or in our case, also 0.1 and we squared

22
00:01:54,630 --> 00:01:56,430
this number, then it becomes even smaller.

23
00:01:57,210 --> 00:02:00,540
So a zero point one square is zero point zero one.

24
00:02:01,290 --> 00:02:07,290
So here the error is some constant times zero point zero one.

25
00:02:07,290 --> 00:02:11,270
And here the error is some constant times zero point one.

26
00:02:11,760 --> 00:02:15,750
So, of course, the error is much smaller for the central differences method.

27
00:02:17,430 --> 00:02:22,320
So why is the error of Order H Square?

28
00:02:22,410 --> 00:02:26,040
This is something that we can really show analytically.

29
00:02:26,760 --> 00:02:33,600
And for this, we need to rely on our Taylor expansion methods, and we need to assume that we can Taylor

30
00:02:33,600 --> 00:02:38,880
expand our function f at some point, which is, of course, true if it's a continuous function.

31
00:02:40,080 --> 00:02:47,370
So we can say we start from our Point X. So we want to expand the function if we want to know the value

32
00:02:47,370 --> 00:02:51,090
of the function at the point X plus h instead.

33
00:02:51,930 --> 00:02:56,940
And if we expand our function around the Point X, this works as follows.

34
00:02:56,940 --> 00:03:05,850
We write F of x plus first derivative of X Times H plus one of a two second derivative of X times a

35
00:03:05,850 --> 00:03:12,990
square, then one of two times three times three derivative of F times H two.

36
00:03:12,990 --> 00:03:13,740
The power of three.

37
00:03:14,070 --> 00:03:15,620
And then so on and so on.

38
00:03:15,630 --> 00:03:20,040
So here then there come the fourth or the terms five fifth, all the terms and so on.

39
00:03:20,790 --> 00:03:23,610
But we only need these terms for the derivation.

40
00:03:24,030 --> 00:03:30,150
But of course, we can also do the same thing for finding the the value of the function at the point

41
00:03:30,150 --> 00:03:31,360
X minus h.

42
00:03:31,380 --> 00:03:39,690
And again, we expend around to point X. And this time we get the result, which is pretty similar.

43
00:03:40,110 --> 00:03:44,130
But instead of having H and this function, we have minus h.

44
00:03:44,790 --> 00:03:50,430
So this will mean this term, if you will change the sign, this one will stay because it's H Square

45
00:03:50,820 --> 00:03:52,890
and this one will also change the sign.

46
00:03:53,160 --> 00:03:56,010
And so every second term will have a different sign.

47
00:03:56,490 --> 00:04:00,270
But besides that, these two functions are the same.

48
00:04:01,620 --> 00:04:08,610
Now, from the first line, individually, we can immediately see that the four what difference this

49
00:04:08,610 --> 00:04:10,950
method is of order H.

50
00:04:11,610 --> 00:04:16,230
And from the second line, we can see that the backwards differences method is of Order H.

51
00:04:16,920 --> 00:04:18,690
Let me show you how this works.

52
00:04:19,290 --> 00:04:21,790
We basically solve this equation.

53
00:04:21,870 --> 00:04:29,370
And also this this equation for the first derivative of F at the Position X, because this is what we

54
00:04:29,370 --> 00:04:30,540
want, after all.

55
00:04:31,560 --> 00:04:34,740
So what we do is we bring this to the other side.

56
00:04:34,950 --> 00:04:40,380
Then we bring this to the other side and then we account for the negative sign here.

57
00:04:41,070 --> 00:04:53,880
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

58
00:04:53,880 --> 00:04:58,620
one half this term, minus one of a sixth this term and so on and so on.

59
00:05:00,000 --> 00:05:06,300
And then we have here also the factor h and we divide by age, and this gives us what is written down

60
00:05:06,300 --> 00:05:06,630
here.

61
00:05:07,110 --> 00:05:14,070
We have the first derivative of F at the position X is equal to one over H and then all of these terms

62
00:05:14,070 --> 00:05:15,210
that I have just mentioned.

63
00:05:15,510 --> 00:05:21,270
So this will be this term than negative this term, negative this term, negative this term.

64
00:05:23,350 --> 00:05:29,440
And when you look at these two terms and divide by age, this is exactly what we have here for the forward's

65
00:05:29,440 --> 00:05:30,070
differences.

66
00:05:30,880 --> 00:05:35,710
So we have here our forward differences solution and then we have additional terms.

67
00:05:36,070 --> 00:05:41,590
And the first term will be minus one over two times second derivative Times Square.

68
00:05:41,860 --> 00:05:45,040
But we divide by age, so it's only an age here.

69
00:05:45,940 --> 00:05:48,570
And then the other terms are of higher order.

70
00:05:48,580 --> 00:05:52,120
We have to each square a short par three and so on and so on.

71
00:05:53,170 --> 00:05:59,710
So we can summarize and say that all of these terms here are the error of our forwards differences methods.

72
00:06:00,100 --> 00:06:03,430
And they are of older age and higher.

73
00:06:04,090 --> 00:06:05,320
So this is why, right?

74
00:06:05,710 --> 00:06:06,580
Order of age.

75
00:06:06,880 --> 00:06:09,640
And this will be the main term that determines the error.

76
00:06:09,650 --> 00:06:12,160
And these will, of course, also determine the arrow.

77
00:06:12,160 --> 00:06:13,450
But they will be much smaller.

78
00:06:14,830 --> 00:06:19,090
And for the backwards differences methods, we take the second equation.

79
00:06:19,540 --> 00:06:21,140
And of course, we do the same thing.

80
00:06:21,160 --> 00:06:22,960
We bring this one to the left side.

81
00:06:23,200 --> 00:06:24,460
This one to the right side.

82
00:06:24,460 --> 00:06:25,720
And we divide by age.

83
00:06:26,020 --> 00:06:31,400
And so this time we have here different signs or most of these terms will change their sign.

84
00:06:31,420 --> 00:06:33,760
So we have such an expression here.

85
00:06:35,020 --> 00:06:37,780
And so this will here be a lot back.

86
00:06:37,870 --> 00:06:39,070
What's difference this term?

87
00:06:39,460 --> 00:06:43,120
And this one divided by age will be our arrow.

88
00:06:43,420 --> 00:06:49,390
So once again, it's of older age to the power of one, and then we have also higher terms.

89
00:06:50,920 --> 00:06:58,090
However, here I wrote down that the central differences term has an arrow of older age square.

90
00:06:58,600 --> 00:07:01,660
So there is no term proportional to age.

91
00:07:02,380 --> 00:07:04,300
And here is why this is the case.

92
00:07:06,230 --> 00:07:10,400
So I wrote down to find this older H2 dependence.

93
00:07:10,880 --> 00:07:16,040
We have to subtract the two terms, so we have to subtract these two equations from each other.

94
00:07:16,940 --> 00:07:25,910
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.

95
00:07:26,780 --> 00:07:31,850
These two terms will then add up because we have this term minus minus this term.

96
00:07:31,880 --> 00:07:39,470
So we have two times first derivative of F times h and then these two terms will cancel again and these

97
00:07:39,470 --> 00:07:40,970
two terms will add up again.

98
00:07:41,630 --> 00:07:47,390
So here we have one of the three third derivative and then h to the power three.

99
00:07:48,890 --> 00:07:55,460
And now you see, this is here the denominator of this function here of the central difference, this

100
00:07:55,460 --> 00:07:55,880
method.

101
00:07:56,780 --> 00:07:59,900
So we divide by two h and then we have this term.

102
00:08:00,350 --> 00:08:04,820
So we have one over two h times.

103
00:08:04,820 --> 00:08:12,980
This one is equal to the first derivative of F at the position X and then the next term will be this

104
00:08:12,980 --> 00:08:16,250
term third derivative and h two the power of two.

105
00:08:17,330 --> 00:08:23,870
So this means when we solve for this one, that this is equal to the expression that we had above this

106
00:08:23,870 --> 00:08:25,940
was the central differences method.

107
00:08:26,540 --> 00:08:34,610
And then the first term that appears will be one of a six third derivative of F and an H to the power

108
00:08:34,640 --> 00:08:35,240
of two.

109
00:08:36,380 --> 00:08:40,190
And so this is an arrow of the order h square.

110
00:08:41,270 --> 00:08:48,890
And the very reason for this not to be power one is that these two terms cancel out when we subtract

111
00:08:48,890 --> 00:08:49,760
these two terms.

112
00:08:50,870 --> 00:08:58,140
And this is the whole trick for finding new methods to calculate derivatives with a lot.

113
00:08:58,160 --> 00:09:06,740
With a smaller arrow, we have to combine several different terms so that our rules of Law Order will

114
00:09:06,740 --> 00:09:07,550
cancel out.

115
00:09:08,510 --> 00:09:13,340
And this is really a trick that is used very often, and we will explore this also in the next lecture

116
00:09:13,790 --> 00:09:20,840
that we will use a function or methods that allows us to calculate the derivative of a function with

117
00:09:20,840 --> 00:09:22,610
a much higher accuracy.

