1
00:00:00,060 --> 00:00:05,280
So at the end of the previous lecture, I told you that we are now able to solve basically every first

2
00:00:05,280 --> 00:00:07,440
order ordinary differential equation.

3
00:00:08,400 --> 00:00:13,480
However, physical systems are not only described by a first order differential equations.

4
00:00:13,500 --> 00:00:19,170
There are also higher order equations and especially second order differential equations play an important

5
00:00:19,170 --> 00:00:19,500
role.

6
00:00:20,670 --> 00:00:27,450
So here we have a second order derivative of why, with respect to T is given by some function that

7
00:00:27,450 --> 00:00:31,020
depends on T y and the First Order derivative.

8
00:00:31,860 --> 00:00:38,760
So this means overall we have t y first derivative and the second derivative of Y was respect to T.

9
00:00:40,350 --> 00:00:45,480
So a very simple example for such a differential equation where we have a second order derivative.

10
00:00:45,960 --> 00:00:52,530
And here we have none of these dependencies, but only a constant is actually the free form that we

11
00:00:52,530 --> 00:00:57,120
are going to solve in the next lecture because there we will just have that.

12
00:00:57,120 --> 00:01:04,500
The force is basically given by the acceleration and the mass.

13
00:01:05,040 --> 00:01:09,420
And when we leave out the mass of, say, the mass is equal to one, then we have this differential

14
00:01:09,420 --> 00:01:16,200
equation and the force becomes then or the acceleration then becomes the second order derivative of

15
00:01:16,200 --> 00:01:17,910
the position with respect to time.

16
00:01:19,200 --> 00:01:25,200
So the problem is that we cannot solve this equation with our Euler method because it's second order

17
00:01:25,200 --> 00:01:25,830
equation.

18
00:01:26,820 --> 00:01:29,250
However, there is a nice trick that we can use.

19
00:01:29,940 --> 00:01:36,450
We can basically produce the order of the differential equation by setting up such a system of equations.

20
00:01:37,320 --> 00:01:43,170
So we will transform a second order differential equation into two first order different differential

21
00:01:43,170 --> 00:01:43,770
equations.

22
00:01:44,490 --> 00:01:47,100
And this idea holds also in general.

23
00:01:47,430 --> 00:01:53,310
For example, if we have a fourth order differential equation, then we can use a system of four different

24
00:01:53,400 --> 00:01:58,500
equations, which are all a first order and which can all be solved with our Euler methods.

25
00:02:00,030 --> 00:02:07,960
So the idea is as follows for the derivation and in an intermediate process, we will define new functions

26
00:02:07,980 --> 00:02:14,430
the Z1 Z zero and then if we have higher order equations, then we would also have C two or three and

27
00:02:14,430 --> 00:02:14,820
so on.

28
00:02:15,510 --> 00:02:20,970
And they are just given by the function and by the first derivative, by the second, third, fourth

29
00:02:20,970 --> 00:02:21,600
and so on.

30
00:02:22,710 --> 00:02:29,070
And for the time being, we will consider these functions to be independent of each other, which they

31
00:02:29,100 --> 00:02:29,280
are.

32
00:02:29,280 --> 00:02:34,800
Of course not, because if you know the first derivative, then you can easily calculate the second

33
00:02:34,800 --> 00:02:35,430
derivative.

34
00:02:36,600 --> 00:02:43,290
But this is here the trick how we can change the order of differential equations because now we can

35
00:02:43,680 --> 00:02:47,640
ask ourselves, OK, we know what z zero is, we know what Z one is.

36
00:02:48,180 --> 00:02:53,160
Then of course, we also know what the first derivative of C zero is and what's the first derivative

37
00:02:53,160 --> 00:02:53,880
of Z one?

38
00:02:55,080 --> 00:03:01,260
Because the first derivative of Z zero is equal to the first derivative of Y of Ti.

39
00:03:02,370 --> 00:03:06,150
And this derivative y of T is equal to z one.

40
00:03:06,600 --> 00:03:11,100
So our first equation becomes the zero derivative is equal to one.

41
00:03:12,750 --> 00:03:18,330
And for the other equation, if we derive this equation on both sides and we have z, one derivative

42
00:03:18,330 --> 00:03:22,050
is equal to the second derivative of Y with respect to T.

43
00:03:23,070 --> 00:03:25,800
And what's the second derivative of Y with respect to T?

44
00:03:26,580 --> 00:03:27,720
It's the function F.

45
00:03:28,740 --> 00:03:30,690
So this will be our second equation.

46
00:03:32,730 --> 00:03:39,840
And now what we are going to do next is we will use a trick that we used already earlier when I introduce

47
00:03:39,840 --> 00:03:42,600
to you the Euler methods.

48
00:03:43,290 --> 00:03:46,290
So this was this one here, I wrote down.

49
00:03:46,290 --> 00:03:52,980
Since a function, the derivative can be expressed by this difference in the Y values divided by the

50
00:03:52,980 --> 00:03:54,120
small value h.

51
00:03:54,720 --> 00:04:00,900
We can solve this for the Y at the time T plus h, and it will be given by this expression.

52
00:04:00,990 --> 00:04:02,850
This is what we have programmed before.

53
00:04:03,990 --> 00:04:07,670
And then we have also translated this in terms of iteration.

54
00:04:07,680 --> 00:04:15,750
So in terms of indices where we had y with the index and plus one is given by the function f times h

55
00:04:15,750 --> 00:04:22,980
plus y at the step and and this is pretty similar to what we see now here.

56
00:04:23,520 --> 00:04:26,340
So I mean, to lead this line, let's go here.

57
00:04:26,490 --> 00:04:34,470
So we know now that the next value of C zero is given by the old value, plus the change, which is

58
00:04:34,470 --> 00:04:41,340
then z one since the derivative is equal to Z one times the step size h.

59
00:04:41,880 --> 00:04:47,760
And similarly, for Z one, we have that the next value with the higher index of C one is equal to the

60
00:04:47,760 --> 00:04:55,260
old value, plus the change which is given to or given by f and timestamp size.

61
00:04:56,890 --> 00:05:03,760
And now, since we have this relation for the C function c0 and C1, we we can just transform back to

62
00:05:03,760 --> 00:05:05,980
why and the first derivative of why.

63
00:05:06,400 --> 00:05:13,450
So we know now from this equation, from this one that the new value of Y will be equal to the old value

64
00:05:13,450 --> 00:05:15,730
plus h times the derivative.

65
00:05:16,630 --> 00:05:25,010
And we know that the next value for the derivative will be the old value for the derivative plus f and

66
00:05:25,030 --> 00:05:26,020
times the step size.

67
00:05:26,920 --> 00:05:29,260
And that's all that we have to program now.

68
00:05:30,760 --> 00:05:37,240
So since we will program this in a very similar manner, as for our first order solution, let me scroll

69
00:05:37,240 --> 00:05:42,680
up and let me copy the code this one here where we have to find Euler only.

70
00:05:44,770 --> 00:05:51,040
So I will copy and paste it here, and I will call this function only two for second order.

71
00:05:52,630 --> 00:05:59,140
So since it's now a second order differential equation and we have two of these equations here, we

72
00:05:59,140 --> 00:06:05,320
do not only need a starting value for Y, but we also need a starting value for the first derivative

73
00:06:05,320 --> 00:06:05,800
of Y.

74
00:06:06,520 --> 00:06:16,300
So I would call these values y zero zero and y one zero zero zero of its starting value of Y and y one

75
00:06:16,300 --> 00:06:17,710
zero will be starting

76
00:06:20,110 --> 00:06:24,340
value of y of T.

77
00:06:26,790 --> 00:06:32,940
OK, so we have to find these functions and what is the starting values?

78
00:06:33,240 --> 00:06:37,290
And now we will, of course, have to change this one here a bit.

79
00:06:37,800 --> 00:06:46,260
So we will have to introduce not only why, but also why one and we have to, first of all, said both

80
00:06:46,260 --> 00:06:48,240
of these equal to the starting values.

81
00:06:48,940 --> 00:06:50,610
And now we have to change here.

82
00:06:52,230 --> 00:06:58,320
This one, for example, would make a list for the y 0s, which means the actual values and the Y ones

83
00:06:58,320 --> 00:07:00,000
for the first derivatives of Y.

84
00:07:01,050 --> 00:07:10,080
And then also, we have to change this, of course, here and we will have to make another line of code

85
00:07:10,080 --> 00:07:16,050
with the Y ones and then we have to be careful what comes here and what comes here.

86
00:07:16,500 --> 00:07:19,050
Well, here comes the first derivative of Y.

87
00:07:19,050 --> 00:07:22,440
So this would be y one.

88
00:07:23,340 --> 00:07:25,050
And here comes the value of F.

89
00:07:25,350 --> 00:07:28,050
So this will be f of T.

90
00:07:28,050 --> 00:07:31,800
And then we have no two arguments, which will be y zero.

91
00:07:32,370 --> 00:07:37,200
And we want corresponding to this y and the first duart of Y.

92
00:07:39,210 --> 00:07:41,910
And now only we have to change.

93
00:07:41,910 --> 00:07:49,260
Also here list of Y to y zero zero and y one by one.

94
00:07:50,970 --> 00:07:53,640
And of course, also for the output.

95
00:07:54,090 --> 00:08:00,060
Here we write y zero values and y for values.

96
00:08:01,410 --> 00:08:07,980
And if I didn't make a mistake in typing this, then it should work and thus we will find out in the

97
00:08:07,980 --> 00:08:08,790
next lecture.

