1
00:00:00,060 --> 00:00:05,400
The throughout the section, we have already solved several ordinary differential equations, but to

2
00:00:05,400 --> 00:00:08,700
be honest, all of them, we could have also solved analytically.

3
00:00:09,630 --> 00:00:16,770
So so far, our new routine didn't serve any purpose, but now we will finally come to an example which

4
00:00:16,770 --> 00:00:18,150
we cannot solve analytically.

5
00:00:18,690 --> 00:00:24,870
So here we can really use our new routine, which we have to find and called Euler to to solve second

6
00:00:24,870 --> 00:00:27,120
order ordinary differential equations.

7
00:00:27,810 --> 00:00:32,880
And the example will be the harmonic oscillator or more precisely, a pendulum.

8
00:00:34,020 --> 00:00:35,730
So you probably know this example.

9
00:00:36,150 --> 00:00:43,260
There's a pendulum swinging and it's described by the angle, so you could also write that down in terms

10
00:00:43,260 --> 00:00:44,070
of the coordinates.

11
00:00:44,370 --> 00:00:49,500
But I will write it down here in terms of the angle and the differential equation looks like this.

12
00:00:49,800 --> 00:00:57,020
So you have the first term, which is basically characterizing the force acting on the angle or, you

13
00:00:57,030 --> 00:01:03,750
know, the the force acting on the pendulum, which is characterized by a second or the derivative of

14
00:01:03,750 --> 00:01:04,349
the angle.

15
00:01:04,860 --> 00:01:08,730
Then we have here a damping term, which is friction basically.

16
00:01:08,740 --> 00:01:09,930
So loss of energy.

17
00:01:10,530 --> 00:01:14,400
And then we have a third term which describes the gravity force.

18
00:01:15,060 --> 00:01:23,130
So the force will always point straight down and it's not perpendicular to the pendulum, so not along

19
00:01:23,130 --> 00:01:28,680
the radial direction, and therefore it will not be linear and theto as you sometimes see this.

20
00:01:29,490 --> 00:01:36,120
But this is in general not correct because in general, the correct differential equation is characterized

21
00:01:36,120 --> 00:01:43,890
by a sign of theta, which is just due to the fact that the force is not always radial, but it is pointing,

22
00:01:43,890 --> 00:01:45,360
always straight down.

23
00:01:46,830 --> 00:01:48,300
So you have these three terms.

24
00:01:48,720 --> 00:01:56,130
B is the damping parameter, and C is basically determined by the pendulum length it's given by the

25
00:01:56,130 --> 00:01:59,790
gravity constant, divided by the length of the pendulum.

26
00:02:01,320 --> 00:02:07,260
So before we really solve this equation, which cannot be solved analytically, that has come to the

27
00:02:07,260 --> 00:02:09,150
case that you probably know already.

28
00:02:09,300 --> 00:02:13,170
This is called the small angle of a small angle approximation.

29
00:02:14,130 --> 00:02:20,560
So if theta is really, really small, then you can approximate the sign of theta to be equal to the

30
00:02:20,560 --> 00:02:21,060
theater.

31
00:02:22,110 --> 00:02:26,460
And if you then consider a case without damping, then you have the differential equation.

32
00:02:26,880 --> 00:02:32,520
Theta second derivative is a is equal to minus C times sign of theta.

33
00:02:33,030 --> 00:02:35,220
So this becomes this one here.

34
00:02:35,610 --> 00:02:39,000
And so this is an equation that is linear in the terms of theta.

35
00:02:40,020 --> 00:02:46,020
And also, it's very easy to solve because a function that solves this is, of course, the sign or

36
00:02:46,020 --> 00:02:47,160
the cosine function.

37
00:02:47,730 --> 00:02:55,110
So a possible solution would be this one here where you have a course in function square root of g over

38
00:02:55,110 --> 00:02:56,070
all times T.

39
00:02:57,510 --> 00:03:03,060
So let's see if our routine is able to restore this result.

40
00:03:03,480 --> 00:03:07,380
So this differential equation is just a tiny bit more difficult into to freefall.

41
00:03:07,380 --> 00:03:09,540
So the freefall we had theta.

42
00:03:10,920 --> 00:03:12,810
So basically we had here why?

43
00:03:12,870 --> 00:03:15,270
Second, derivative is given by minus g.

44
00:03:15,990 --> 00:03:19,260
And here we have A. Another term with the function itself.

45
00:03:20,160 --> 00:03:22,710
So what this means is we have to modify our code.

46
00:03:22,890 --> 00:03:27,510
So here these are the two cells from the free fall, which I've copied.

47
00:03:29,160 --> 00:03:31,590
So let's go back down and let's modify them.

48
00:03:32,520 --> 00:03:33,870
So here I will write.

49
00:03:33,990 --> 00:03:37,350
Blink for L is equal to two.

50
00:03:37,830 --> 00:03:43,980
And so over a constant C, which is this one is given by

51
00:03:47,190 --> 00:03:59,250
nine point eight one divided by the length and then the damping I will also consider to be zero damping

52
00:03:59,970 --> 00:04:01,380
B is equal to zero.

53
00:04:01,890 --> 00:04:11,310
So this one would appear to be pendulum geometry and then we can define our function f only e.

54
00:04:13,380 --> 00:04:21,540
So the f only function would in this case, be if we take this on the left and this on the right, it

55
00:04:21,540 --> 00:04:32,790
would be minus B times y one and then another term, which is minus C times y zero.

56
00:04:34,050 --> 00:04:40,170
So bring these two terms on the right, and we have this approximation that the sine is equal to the

57
00:04:40,170 --> 00:04:41,060
theater itself.

58
00:04:41,070 --> 00:04:48,240
And here Cetus called Y is zero and the first derivative is called y one.

59
00:04:49,920 --> 00:04:52,200
Now we must define the starting values.

60
00:04:52,650 --> 00:04:56,850
And here we will once again use T zero as equal to zero.

61
00:04:57,420 --> 00:04:59,520
And then maybe that it's not so.

62
00:04:59,810 --> 00:05:08,840
Using Let me go right here, Theta Zero and Theta one, but it would not be necessary, actually.

63
00:05:11,730 --> 00:05:20,550
And then we can also right here, six zero zero and to one zero.

64
00:05:21,390 --> 00:05:27,120
And I've tested this before and while used to work quite well, our 0.2 and zero.

65
00:05:27,660 --> 00:05:33,210
So you have to remember that three to zero must be small since we are here in the small angle approximation.

66
00:05:33,720 --> 00:05:36,990
So, yeah, make sure that this value is pretty small.

67
00:05:37,410 --> 00:05:39,780
Otherwise, it will just be unreasonable.

68
00:05:40,800 --> 00:05:43,050
And then we can increase the number of and max.

69
00:05:43,290 --> 00:05:47,670
And I think there's one, of course, we have to have to change now.

70
00:05:48,960 --> 00:05:52,200
So as I said, this would not have been necessary to change.

71
00:05:52,200 --> 00:05:54,720
We could have just wrote here why and also why.

72
00:05:55,290 --> 00:06:00,720
But I think it's a bit more reasonable and you can understand it better since I changed it.

73
00:06:02,490 --> 00:06:06,720
So now we can run the cell, calculate the solution and plot it.

74
00:06:07,140 --> 00:06:08,580
So here, right, Peter.

75
00:06:09,420 --> 00:06:12,090
And this time I only want to plot thetr.

76
00:06:12,120 --> 00:06:13,830
I don't care about the first derivative.

77
00:06:15,180 --> 00:06:25,560
So the analytical solution will be test, test, beta test thetr and it will be co-signed.

78
00:06:25,890 --> 00:06:37,640
So will be theta zero times and P dots cosine and P dot, square root and G over.

79
00:06:38,580 --> 00:06:50,520
So nine point eight one over A and then times T times test T, and I hope that this will now get give

80
00:06:50,520 --> 00:06:51,430
the correct result.

81
00:06:52,140 --> 00:06:53,190
And it looks pretty good.

82
00:06:54,150 --> 00:06:58,560
It looks like, yeah, it looks like a perfect cosine function.

83
00:06:59,460 --> 00:07:06,000
And really, there is no wonder because the analytical solution is in fact the cosine function and our

84
00:07:06,000 --> 00:07:10,110
step size was small enough to be able to recreate this result.

85
00:07:10,950 --> 00:07:11,880
So that was pretty good.

86
00:07:13,170 --> 00:07:21,210
We have used our second order method that we have to find here to solve now the pendulum, the harmonic

87
00:07:21,210 --> 00:07:24,330
oscillator in small angle approximation.

88
00:07:25,770 --> 00:07:32,070
However, this small angle approximation is, of course, only an approximation, and this approximation

89
00:07:32,070 --> 00:07:34,890
is only done so that we are able to solve it analytically.

90
00:07:35,580 --> 00:07:37,620
But since we have a nice cold, we don't need it.

91
00:07:37,920 --> 00:07:44,040
We could actually use here the sign of theta and solve the actual equation, and this is what we are

92
00:07:44,040 --> 00:07:46,020
going to do in the next lecture.

