1
00:00:00,060 --> 00:00:07,560
So we have seen that it's pretty easy to use the command solve underscore IVP to solve differential

2
00:00:07,560 --> 00:00:08,250
equations.

3
00:00:08,880 --> 00:00:12,270
So in this case, we didn't have to define any function ourself.

4
00:00:12,270 --> 00:00:14,250
We did not have to define the Arla function.

5
00:00:14,670 --> 00:00:20,790
And we could even choose a method AKI 45, which seems to be superior compared to the Euler methods.

6
00:00:21,240 --> 00:00:25,110
And in fact, it really is much better because you need fewer points.

7
00:00:25,530 --> 00:00:33,720
The point size will rtd you judge to step with step size will be chosen accordingly, and it adapts

8
00:00:33,720 --> 00:00:40,140
to the change of the function to get you always the good result, with only a few points for the calculation.

9
00:00:40,140 --> 00:00:42,660
So it's really the best of both worlds.

10
00:00:43,620 --> 00:00:49,600
And what we haven't done yet is looking at higher order differential equations.

11
00:00:49,620 --> 00:00:55,290
So I want to show you here we can also solve second order differential equations like the free fold.

12
00:00:56,370 --> 00:01:00,090
So I copy this and let's change it to our needs.

13
00:01:01,050 --> 00:01:08,430
So what we need is we need to go to zero from zero to 10, and we need to provide the starting values

14
00:01:08,430 --> 00:01:11,810
for why zero and zero.

15
00:01:13,290 --> 00:01:18,710
So all rides, why zero is 10.

16
00:01:18,720 --> 00:01:29,100
I think this is what we chose previously and V0 is 50 and now we only need to provide the function.

17
00:01:30,510 --> 00:01:36,060
And for this, I will scroll up to our example where we have considered the free fall because I want

18
00:01:36,060 --> 00:01:38,220
to show you the very important difference.

19
00:01:38,940 --> 00:01:44,400
So of course, I could have just written the function myself, but I want to show you really what's

20
00:01:44,400 --> 00:01:48,540
important to make sure that you changed this.

21
00:01:49,050 --> 00:01:55,440
So I copy this from our previous example and go back down to our where we just left.

22
00:01:56,700 --> 00:01:58,500
Um, so let me paste it here.

23
00:02:00,300 --> 00:02:05,400
So the thing is, our function can be called f only e.

24
00:02:05,400 --> 00:02:06,120
This is good.

25
00:02:06,720 --> 00:02:12,630
And previously we had provided two arguments why zero and why?

26
00:02:12,630 --> 00:02:12,930
One?

27
00:02:12,930 --> 00:02:17,640
Because this is how we have programmed our Euler methods.

28
00:02:17,910 --> 00:02:21,210
We had two separate variables y zero and y one.

29
00:02:22,080 --> 00:02:25,170
And our output was only the value of the function.

30
00:02:26,190 --> 00:02:34,830
However, in order to fulfill the syntax of solve IVP, we must provide the arguments in a different

31
00:02:34,830 --> 00:02:43,110
way and we must provide the output in a different way because here y is a list like two starting values.

32
00:02:43,530 --> 00:02:45,030
So this was the starting value.

33
00:02:45,330 --> 00:02:49,920
So like the starting values, also, the arguments themselves are lists.

34
00:02:50,610 --> 00:02:56,820
So it's just a single is called Y, and it will have two elements in this case.

35
00:02:57,180 --> 00:03:01,140
And this we have to make sure that we respect here for the return function.

36
00:03:01,380 --> 00:03:03,010
So we have to write the minus g.

37
00:03:03,030 --> 00:03:03,690
This is good.

38
00:03:04,260 --> 00:03:10,140
But then we have to also provide the other variable and this will just be the velocity.

39
00:03:10,830 --> 00:03:15,930
And this is actually pretty similar to our trick that we have used before.

40
00:03:15,960 --> 00:03:18,750
Let me briefly scroll up to the theory part.

41
00:03:18,900 --> 00:03:20,910
So in your notebook, you can stay where you are.

42
00:03:21,970 --> 00:03:23,670
Um, let me just go here.

43
00:03:24,120 --> 00:03:26,100
But we have introduced a new variable.

44
00:03:26,580 --> 00:03:29,970
For example, Z one is equal to the first derivative of Y.

45
00:03:30,840 --> 00:03:33,150
And this is exactly what we are going to provide here.

46
00:03:33,570 --> 00:03:38,280
The one variable will be the first derivative of Z.

47
00:03:38,280 --> 00:03:41,220
One is equal to the function, which in our case is minus G.

48
00:03:41,850 --> 00:03:46,530
And then the other variable will just be equal for the derivative will just be equal to see one.

49
00:03:47,310 --> 00:03:56,460
This is what we right here see one or in this nomenclature that is used here, it's just y one.

50
00:03:57,630 --> 00:04:04,620
So to be honest, it's not 100 percent necessary that you understand really all the details that go

51
00:04:04,620 --> 00:04:05,040
on here.

52
00:04:05,050 --> 00:04:12,000
Just remember that when you try to use T solve IVP methods to solve a second order differential equation,

53
00:04:12,420 --> 00:04:16,260
you must provide a function that has to return arguments.

54
00:04:17,040 --> 00:04:19,560
And so this one would be the actual function.

55
00:04:19,560 --> 00:04:21,480
And then you just write y off one.

56
00:04:21,899 --> 00:04:27,030
And if it's higher order function, then you use more terms and you write before you're y to y three

57
00:04:27,030 --> 00:04:27,870
and so on and so on.

58
00:04:29,850 --> 00:04:38,220
So I think now we have a good solution here and we can now go ahead and plot this.

59
00:04:39,480 --> 00:04:45,150
So I will use the same command as before, but without an analytical solution.

60
00:04:45,150 --> 00:04:49,920
This time I will just right here y.

61
00:04:49,920 --> 00:04:54,030
And now, of course, I have to provide which of the two ys, I want to have zero or one.

62
00:04:54,570 --> 00:04:57,120
And I want to have to coordinate, so I want to have zero.

63
00:04:58,620 --> 00:04:59,910
So this is this.

64
00:05:00,010 --> 00:05:08,650
Solution, and to be honest, it looks pretty confusing, so let's check if it is OK and we will do

65
00:05:08,650 --> 00:05:13,480
this by copying the analytical solution from before, so I would just go up here.

66
00:05:13,960 --> 00:05:14,560
Here it is.

67
00:05:15,430 --> 00:05:16,180
Copy this.

68
00:05:16,780 --> 00:05:20,560
Go back down and copy it here.

69
00:05:20,560 --> 00:05:21,940
And let's see if it's correct.

70
00:05:24,920 --> 00:05:25,490
Yes.

71
00:05:25,560 --> 00:05:35,180
It seems to be correct, but for some reason we went way out of range here, so let's just go to 10

72
00:05:35,630 --> 00:05:38,560
and then in steps of zero point one.

73
00:05:39,170 --> 00:05:40,460
Yeah, exactly like this.

74
00:05:41,270 --> 00:05:46,460
So you see, in fact, the solution from during a quota once again got it correct.

75
00:05:47,030 --> 00:05:52,080
But a lot of points are missing here, which is not not not a problem at all.

76
00:05:52,100 --> 00:05:56,300
If you just want to have the ending value here, but if you want to have to hold your victory, then

77
00:05:56,300 --> 00:05:59,750
of course, it's pretty bad that there are no points here.

78
00:06:00,500 --> 00:06:06,980
But still, overall pretty remarkable that this method is able to solve this problem by only using five

79
00:06:06,980 --> 00:06:08,780
points for the propagation.

80
00:06:10,220 --> 00:06:20,390
So what you can do to at this point is just to right, as we did before this one here to evaluate.

81
00:06:23,830 --> 00:06:26,920
And then just make sure to get here to correct ranges.

82
00:06:27,490 --> 00:06:33,970
So we want to go to 10 and and Max was one on one.

83
00:06:35,470 --> 00:06:40,510
So you see, now we have a smooth curve and we have all the points that we wanted to have.

