1
00:00:00,120 --> 00:00:05,850
So now we want to compare our three methods Euler, R.K., four and R.K. four or five.

2
00:00:06,780 --> 00:00:11,640
And since so far, we have only implemented this for solving first or the differential equations.

3
00:00:11,970 --> 00:00:17,220
We have to, of course, search for an example of where the differential equation was of First Order

4
00:00:17,820 --> 00:00:19,900
and some of the most difficult one that we have considered.

5
00:00:19,930 --> 00:00:23,460
So, for example, number two, two time amplified decay.

6
00:00:24,360 --> 00:00:32,340
And so I will copy these to cells here and let me make a new one and copy this.

7
00:00:32,400 --> 00:00:33,780
So here.

8
00:00:35,010 --> 00:00:36,420
And also this cell here.

9
00:00:39,620 --> 00:00:45,770
And then copy the whole thing and go to the bottom of the notebook.

10
00:00:47,570 --> 00:00:48,980
So here we have it.

11
00:00:49,940 --> 00:00:54,140
So when I run this, it gives me the solution for our oily methods.

12
00:00:55,850 --> 00:01:01,130
So what we will add next is, of course, we will add new solutions.

13
00:01:01,700 --> 00:01:05,900
And therefore, I would call this solution with the old methods solution.

14
00:01:07,850 --> 00:01:13,130
Then I have to, of course, also update this one here and here.

15
00:01:16,610 --> 00:01:20,800
And now I will calculate all sort of solutions with our other two solvers.

16
00:01:20,870 --> 00:01:26,960
And we have only we modified the general syntax of the Euler function.

17
00:01:26,960 --> 00:01:31,130
So the syntax here is really the same for the OK four in the arc, four or five.

18
00:01:31,610 --> 00:01:35,270
So we can just change the name here, and it should work.

19
00:01:35,840 --> 00:01:40,610
So this one will be our K four solution r k four.

20
00:01:41,870 --> 00:01:43,580
Then we have our K four five.

21
00:01:47,840 --> 00:01:56,870
And like this, and now we can just go ahead, copy this line of code and updates here, the R.K. four

22
00:01:58,190 --> 00:02:00,830
and R.K. four or five.

23
00:02:01,460 --> 00:02:03,680
And of course, also here for the Y component.

24
00:02:08,470 --> 00:02:17,590
And when I run this, we do not see anything really, so it seems as if all three solutions are pretty

25
00:02:17,590 --> 00:02:19,900
much the same and they are on top of each other.

26
00:02:20,290 --> 00:02:26,290
So this is already a good sign because there is no large deviation comparing the three methods.

27
00:02:27,310 --> 00:02:31,750
So now we go ahead and do something that we also did previously.

28
00:02:31,750 --> 00:02:38,890
When we compare the methods that were implemented in the solve, underscore IVP solver of the integrate

29
00:02:38,890 --> 00:02:39,280
module.

30
00:02:39,820 --> 00:02:42,790
We will compare these differences here in the way value.

31
00:02:44,620 --> 00:02:47,980
And so I will go ahead and copy this code here

32
00:02:50,980 --> 00:03:00,460
and I will write T and paragraph off Y and then here I will just subtract the test value, basically.

33
00:03:01,090 --> 00:03:08,140
So what we did previously is we find already here a test value test T and then test Y.

34
00:03:08,710 --> 00:03:13,810
And the only thing that we have to make sure I think this one is not correct because here we are missing

35
00:03:13,810 --> 00:03:19,620
a one because we only always start at two zero and then we go and next steps to h.

36
00:03:19,630 --> 00:03:22,000
So we have in total and mixed +1 values.

37
00:03:22,450 --> 00:03:25,300
And so now we also have here and makes +1 values.

38
00:03:26,080 --> 00:03:31,540
Since I updated this, I have to rerun the South and now I can just write here

39
00:03:34,150 --> 00:03:37,960
basically minus test y.

40
00:03:40,210 --> 00:03:42,430
And then we do this for all three lines.

41
00:03:43,360 --> 00:03:46,270
And now just to compare them, I will add colors.

42
00:03:47,170 --> 00:03:48,610
So you know, they right blue.

43
00:03:49,960 --> 00:03:53,200
Here I write red and green.

44
00:03:56,480 --> 00:04:03,350
And then since you see this line here so thick, I will also change the catapult to just a regular plot

45
00:04:03,350 --> 00:04:06,050
so that the points are connected by lines.

46
00:04:07,640 --> 00:04:16,250
And if you won this, then we see we have a blue line here, which so let me just tell you again what

47
00:04:16,250 --> 00:04:16,910
this shows here.

48
00:04:17,149 --> 00:04:21,740
So this is basically the error of our method compared to the analytical solution.

49
00:04:22,220 --> 00:04:27,320
And you see the blue curve, which is the only method has a very large error compared to the other two

50
00:04:27,320 --> 00:04:27,770
methods.

51
00:04:28,430 --> 00:04:33,230
So in fact, the green and the red one, you cannot even see anything different from zero here.

52
00:04:34,340 --> 00:04:43,310
So what I will do next is I will copy this paste and just comment or delete this line of code so that

53
00:04:43,310 --> 00:04:47,150
we do not show the blue one anymore and just concentrate on red and green.

54
00:04:48,080 --> 00:04:49,580
And you see this one.

55
00:04:50,120 --> 00:04:55,790
Or this time we have a 10 to the power of minus 10 arrows.

56
00:04:55,790 --> 00:04:59,240
So these values have to be multiplied with 10 to the power of minus 10.

57
00:04:59,250 --> 00:05:04,820
So this will be a very, very small value compared to this one, which is just 10 to the power of minus

58
00:05:04,820 --> 00:05:05,240
three.

59
00:05:06,620 --> 00:05:14,420
And you see, the red one has then an arrow, which is the Arc four method and the arc for five is an

60
00:05:14,750 --> 00:05:16,160
even more accurate.

61
00:05:17,120 --> 00:05:22,910
So we have really, really good solutions here and a very high accuracy.

62
00:05:23,990 --> 00:05:32,000
And this is really the take home message of the section we can, of course, implement just are straightforward,

63
00:05:32,000 --> 00:05:33,920
simple solutions like the older methods.

64
00:05:34,340 --> 00:05:39,980
But we always have to keep in mind that this brings about some error and that there are other methods

65
00:05:39,980 --> 00:05:41,240
that are much more accurate.

66
00:05:41,700 --> 00:05:45,130
We have seen that deriving these problem.

67
00:05:45,130 --> 00:05:47,340
The methods is, of course, very difficult.

68
00:05:47,420 --> 00:05:51,500
In fact, we didn't do it because it was too difficult here to time consuming.

69
00:05:51,980 --> 00:05:58,910
But if we just look at Wikipedia or other websites or books, you can find these tables here.

70
00:05:58,910 --> 00:06:03,120
And it didn't take us more than five minutes to implement these tables here.

71
00:06:03,140 --> 00:06:08,390
Of course, it's a bit tedious to write on all of these numbers, but you just have to do it once and

72
00:06:08,390 --> 00:06:09,500
then you have implemented.

73
00:06:09,500 --> 00:06:17,280
These are k four or five methods, and you see the error is really remarkably small.

74
00:06:17,300 --> 00:06:22,310
So here we have two times 10 to the power of minus three for the other method.

75
00:06:22,820 --> 00:06:31,190
We have 10 to the power of minus 10 for the quarter full methods and 400 cutoff for five methods.

76
00:06:31,760 --> 00:06:32,600
I don't even know.

77
00:06:32,840 --> 00:06:33,380
Let's see.

78
00:06:35,060 --> 00:06:39,410
We have, yeah, four times 10 to the power of minus 13.

79
00:06:39,740 --> 00:06:41,690
So really, really small error.

80
00:06:42,110 --> 00:06:43,700
The very high accuracy.

81
00:06:44,970 --> 00:06:50,780
I hope you see now that these methods to when we put our methods are very helpful and very useful.

82
00:06:51,170 --> 00:06:56,060
And of course, one thing that I have to mention, as well as in our following codes, we could of course,

83
00:06:56,060 --> 00:07:01,580
use this module here that we have implemented our K for five, which was a bit time consuming, but

84
00:07:02,180 --> 00:07:05,330
maybe just five to 10 minutes to write on all the coefficients.

85
00:07:05,750 --> 00:07:13,500
But of course, in the following mode we are going to use is we are going to use the solver of integrated

86
00:07:13,520 --> 00:07:18,290
solve, underscore IVP and then rewrite method, for example, R K for five.

87
00:07:18,770 --> 00:07:25,340
And then we have basically the same thing with even an adaptive step size, which is even better.

88
00:07:25,730 --> 00:07:34,460
So just let's get back to this example here, where we have really large step sides, step sizes at

89
00:07:34,460 --> 00:07:35,900
certain ranges.

90
00:07:35,900 --> 00:07:37,270
Where to code releases?

91
00:07:37,280 --> 00:07:39,680
OK, that function doesn't change that much here.

92
00:07:40,070 --> 00:07:44,540
It's OK to make a large step, and the arrow will not be too large.

93
00:07:44,540 --> 00:07:50,720
And so we can save a lot of time because here we only have to calculate a very few points compared to

94
00:07:50,720 --> 00:07:56,510
maybe 500 points if we would have chosen an equidistant list of points for this range here.

