1
00:00:00,330 --> 00:00:06,530
So in the previous lecture, we had our own encounter, we had chosen our starting we lost teeth such

2
00:00:06,540 --> 00:00:09,730
that our lips almost hits the Moon.

3
00:00:09,750 --> 00:00:17,580
And if we then don't do anything, we will get thrown out of the trajectory around the Earth and close

4
00:00:17,580 --> 00:00:20,100
to the Moon, and we will then just circle around the sun.

5
00:00:20,790 --> 00:00:26,310
This is, of course, really nice if you want to leave Earth and want to save a bit of fuel, but it

6
00:00:26,310 --> 00:00:33,870
can also be used to break at this point and then to go on a trajectory around the Moon.

7
00:00:34,290 --> 00:00:35,820
And this is what we want to do now.

8
00:00:36,510 --> 00:00:43,560
So the task for this very special lecture is to set up a space program where we will encounter an orbit

9
00:00:43,560 --> 00:00:49,470
around the Moon and we want to plan ahead what we want to do with our engine, at which point of time.

10
00:00:50,920 --> 00:00:51,430
So.

11
00:00:52,710 --> 00:00:57,400
For this, we have to modify our equations of motion, but only a single one.

12
00:00:57,420 --> 00:00:59,820
Only the motion of the spaceship, of course.

13
00:01:00,510 --> 00:01:04,650
And also we have the same thing as before and just add a single term here.

14
00:01:05,489 --> 00:01:11,880
So I told you that I want to break and breaking in space is not really possible.

15
00:01:12,060 --> 00:01:13,740
Can I just push a brake pedal?

16
00:01:14,250 --> 00:01:16,310
Because, yeah, you have no friction.

17
00:01:16,320 --> 00:01:20,020
So what you have to do is you have to accelerate it into the opposite direction.

18
00:01:20,040 --> 00:01:26,880
You have to use an engine, some booster along the opposite direction and with opposite direction,

19
00:01:26,880 --> 00:01:34,350
I mean opposite direction with respect to the relative velocity of our spaceship compared to the Moon,

20
00:01:34,860 --> 00:01:37,770
because we want to enter an orbit around the Moon.

21
00:01:37,770 --> 00:01:46,470
So we have to break along the opposite direction of the velocity of our spaceship relative to the velocity

22
00:01:46,470 --> 00:01:46,890
of the Moon.

23
00:01:47,730 --> 00:01:51,060
Sounds difficult, but if you think about it, it's not that difficult.

24
00:01:51,360 --> 00:01:56,040
You could just say, OK, here we have our distance spaceship to the Moon.

25
00:01:56,040 --> 00:02:03,990
And at this point you look down to the moon, you see your velocity and you push the the engine and

26
00:02:03,990 --> 00:02:07,710
you accelerate along the opposite direction along which you are moving.

27
00:02:09,030 --> 00:02:09,449
OK.

28
00:02:09,479 --> 00:02:16,140
So this will be the term just some, some some prefecture times the direction.

29
00:02:16,140 --> 00:02:18,180
So the direction is really what's important here.

30
00:02:18,930 --> 00:02:24,150
And the prefecture will be, of course, time dependent because we don't want to have this false the

31
00:02:24,150 --> 00:02:24,750
whole time.

32
00:02:24,750 --> 00:02:27,210
We just want to have it when our engine is on.

33
00:02:27,870 --> 00:02:29,240
And this is really what we want to do here.

34
00:02:29,250 --> 00:02:34,470
We have times where the engine is on and we have times where the engine is off.

35
00:02:35,550 --> 00:02:40,800
So the first question would be how can you program a function which is on and off?

36
00:02:41,790 --> 00:02:45,750
Of course, we could just take our F40 and use an if statement.

37
00:02:46,020 --> 00:02:52,830
And if our time is in a specified frame, then we use the term and if not, then we don't use the term.

38
00:02:53,790 --> 00:02:59,580
But it's always better to avoid if statements and mathematicians use, in this case, the so-called

39
00:02:59,580 --> 00:03:00,690
heavy side function.

40
00:03:01,290 --> 00:03:02,490
Let me show you how this works.

41
00:03:02,970 --> 00:03:05,130
This is basically just a step function.

42
00:03:05,430 --> 00:03:11,100
So I start with Telus just for the plotting and pitot in space.

43
00:03:12,180 --> 00:03:12,420
Oops.

44
00:03:12,420 --> 00:03:14,070
Sorry, typos

45
00:03:17,220 --> 00:03:22,170
and alan space goes from, I don't know, it doesn't matter here zero to 100.

46
00:03:22,680 --> 00:03:32,130
And what we want to plot is for the x axis to T list the time and then for the wireless R plot to have

47
00:03:32,130 --> 00:03:33,660
a site function and p dot.

48
00:03:34,500 --> 00:03:35,220
Have you sites?

49
00:03:35,220 --> 00:03:36,630
We see it's an important function.

50
00:03:36,630 --> 00:03:42,540
It's implemented in NumPy, so the guy who was named heavy side.

51
00:03:42,540 --> 00:03:44,490
So that's why it's not with a y.

52
00:03:44,490 --> 00:03:51,680
What would an AI and he rewrite it rewrite T list minus some shift, for example.

53
00:03:51,690 --> 00:03:52,440
Twenty five.

54
00:03:53,670 --> 00:03:54,990
And then we have to write here.

55
00:03:54,990 --> 00:03:56,980
A number could read zero one.

56
00:03:56,980 --> 00:03:58,350
That doesn't really matter for us.

57
00:03:58,800 --> 00:04:02,750
If you want to know the details, you can look that description, but it doesn't matter.

58
00:04:02,760 --> 00:04:04,080
We should just write one here.

59
00:04:04,530 --> 00:04:05,790
This is what matters for us.

60
00:04:06,900 --> 00:04:14,310
And what happens then is it's a step function that zero for arguments that are smaller than this number,

61
00:04:14,760 --> 00:04:18,779
and it is one for arguments that are larger than this lumber.

62
00:04:19,890 --> 00:04:26,850
So now we can subtract another heavy side function with a different shift, for example.

63
00:04:26,850 --> 00:04:27,780
75.

64
00:04:29,580 --> 00:04:34,290
And so then we get such such a step, step up, step down.

65
00:04:34,950 --> 00:04:40,440
And it is one only between these two arguments and this is exactly what we want.

66
00:04:41,340 --> 00:04:47,580
We could now, of course, write this here in brackets and multiply some factor, like 100.

67
00:04:48,090 --> 00:04:53,250
And then you see, it's zero all the time and then only in this range here it's a hundreds.

68
00:04:54,000 --> 00:04:56,840
So this is what we will add to our EV ODI.

69
00:04:57,720 --> 00:05:03,300
So let me scroll back up to the notebook and copy the Odyssey and a few plots, and then I'll be back

70
00:05:03,300 --> 00:05:10,140
in a second and then we modify all of these commands and then we go to approach this moon orbit.

71
00:05:10,770 --> 00:05:11,640
So here I'm back.

72
00:05:11,790 --> 00:05:15,180
We have just discussed the equation of motion and the heavy side function.

73
00:05:15,540 --> 00:05:21,720
And now we want to add this term he with the heavy side function to our F ODI, which I have copied

74
00:05:21,720 --> 00:05:22,320
from above.

75
00:05:22,890 --> 00:05:24,420
And then also I have copied here.

76
00:05:24,690 --> 00:05:30,450
This is code that we have written before with the starting conditions and the solution by integrated

77
00:05:30,450 --> 00:05:32,760
solve underscore IVP and the plots.

78
00:05:33,330 --> 00:05:38,130
And then here, another plot spaceship tune that's all just copied from above.

79
00:05:39,330 --> 00:05:42,080
OK, so we will leave everything as it is.

80
00:05:42,090 --> 00:05:46,110
We will just use here the same starting velocity that we had before.

81
00:05:46,950 --> 00:05:51,930
One point thirty four times we orbit and then we can.

82
00:05:51,960 --> 00:05:59,910
Basically rallied as soon as we have out a Tier two additional term to the equation, so I will right

83
00:05:59,910 --> 00:06:00,300
here.

84
00:06:01,950 --> 00:06:08,910
This factor, I will call be off a break and then we have to program here this direction, which is

85
00:06:08,910 --> 00:06:09,840
basically this one.

86
00:06:10,320 --> 00:06:18,420
The velocity of the space ship with respect to the velocity of the moon and then divides by the known.

87
00:06:20,160 --> 00:06:20,680
All right.

88
00:06:20,730 --> 00:06:21,840
So, all right.

89
00:06:21,970 --> 00:06:34,420
Minus the art times before minus the three divided by and pitot taught Lynn Rock tot mom.

90
00:06:36,120 --> 00:06:43,950
And then once again, we three minus three or four or vice versa doesn't matter in this case.

91
00:06:44,130 --> 00:06:45,210
What do you have to be careful here?

92
00:06:45,430 --> 00:06:47,360
You have to write me four minus three.

93
00:06:47,910 --> 00:06:50,910
Otherwise, it will be an acceleration, which is not what you want.

94
00:06:50,920 --> 00:06:51,900
We want to really break.

95
00:06:53,250 --> 00:06:54,780
OK, so this is the new term here.

96
00:06:55,380 --> 00:07:00,300
Be our times the distance of two vectors of the velocities divided by the norm of this distance.

97
00:07:01,020 --> 00:07:06,780
And now we must, of course, program the hour before and we leave three.

98
00:07:07,950 --> 00:07:21,360
So the three is ah, and we could just take this one plus 12 plus 12.

99
00:07:22,680 --> 00:07:33,060
And B, four, nine plus 12 and 12 plus 12, you could, of course, just calculate it, but I just

100
00:07:33,060 --> 00:07:37,020
want to show you this just shift of this index by 12th because we have 12 variables.

101
00:07:37,530 --> 00:07:42,840
And yeah, the first 12 are the positions and the other 12 are the velocities.

102
00:07:44,270 --> 00:07:46,520
So now I can find the brake function.

103
00:07:47,510 --> 00:07:50,990
So this will be B art is and now we need an amplitude.

104
00:07:51,320 --> 00:07:56,030
And you have to be honest, I spend like maybe half an hour trying a bit of a parameters.

105
00:07:56,450 --> 00:07:58,070
And this is what I came up with.

106
00:07:58,640 --> 00:08:07,760
So I have 27 million so times 10 to the power of six.

107
00:08:09,290 --> 00:08:13,040
This will be Newton, 27 Newton or 27 Mega Newton.

108
00:08:13,610 --> 00:08:20,480
And we apply this force for a certain time and this we will construct by using the heavy side function,

109
00:08:20,480 --> 00:08:20,930
of course.

110
00:08:21,560 --> 00:08:23,120
So I will just copy this.

111
00:08:23,810 --> 00:08:26,900
We will, of course, use the same type of command here.

112
00:08:28,580 --> 00:08:30,020
This was our amplitude.

113
00:08:32,090 --> 00:08:35,210
Sorry, here we of course, have the exponent 10 to the power of six.

114
00:08:36,020 --> 00:08:37,789
And now we have here.

115
00:08:37,789 --> 00:08:38,840
Do you have your site function?

116
00:08:39,919 --> 00:08:45,320
OK, so we don't have to list anymore, but tea, which is important to change.

117
00:08:45,530 --> 00:08:49,520
So now for the first time, our differential equation is actually T dependent.

118
00:08:49,910 --> 00:08:55,520
But that's no problem because it was it could have been Tiede dependent all the time.

119
00:08:56,510 --> 00:09:04,490
And now we must subtract here the starting time and the end time, and we see here that we approach

120
00:09:04,490 --> 00:09:08,720
the Moon approximately after 0.11 years.

121
00:09:09,290 --> 00:09:13,580
So I will use the engine approximately at this point of time.

122
00:09:14,570 --> 00:09:20,540
So let me copy this time factor here and then multiply it by zero point one one, which will then be

123
00:09:20,750 --> 00:09:22,280
zero point one one years.

124
00:09:23,210 --> 00:09:24,440
So here's where it goes.

125
00:09:25,100 --> 00:09:31,100
T minus zero point one one times.

126
00:09:31,100 --> 00:09:37,610
Then this time factor and then this heavy side function will be the point where the engine is turned

127
00:09:37,640 --> 00:09:38,270
off again.

128
00:09:38,690 --> 00:09:43,960
And I don't know, I just take zero point twelve.

129
00:09:45,500 --> 00:09:52,460
So basically, we have the engine on four one hundredths of a year, which is, of course not how it

130
00:09:52,460 --> 00:09:53,030
would be done.

131
00:09:53,030 --> 00:09:57,430
In reality, they're they would really just boost for a few, I don't know, few seconds.

132
00:09:57,440 --> 00:09:58,190
Few minutes.

133
00:09:58,340 --> 00:09:58,790
I don't know.

134
00:09:58,790 --> 00:10:06,650
I'm not an astrophysicist, but definitely not for one hundredth of a year, which is almost four days.

135
00:10:07,220 --> 00:10:10,580
But anyway, this is what I just found to work.

136
00:10:10,880 --> 00:10:19,040
So we boost here for four days with a force of twenty seven Meghan Newton divided by the mass of the

137
00:10:19,040 --> 00:10:19,920
object, of course.

138
00:10:19,970 --> 00:10:26,420
So this is here an acceleration then, and this is our heavy side function.

139
00:10:26,430 --> 00:10:33,980
So this means the engine is turned on just in this range from zero one two zero point twelve years.

140
00:10:35,300 --> 00:10:39,620
OK, and if I did not make a mistake, then I think it should work now.

141
00:10:39,920 --> 00:10:40,400
Let's see.

142
00:10:41,060 --> 00:10:44,150
I run this, run this and run this all three cells.

143
00:10:44,690 --> 00:10:48,500
And I think, no, it will take a bit of time.

144
00:10:49,310 --> 00:10:51,590
This one worked, but now it's running here.

145
00:10:52,760 --> 00:10:55,160
Maybe we have to think for how long we want to run.

146
00:10:55,160 --> 00:10:59,450
Actually, I want to run only for 0.3 years as before.

147
00:10:59,510 --> 00:11:04,040
So before we look, let me rerun this zero point three and this is what we get.

148
00:11:05,030 --> 00:11:10,040
So first of all, let's look again at the trajectory without the engine.

149
00:11:10,400 --> 00:11:12,140
This was this oval shape.

150
00:11:12,140 --> 00:11:17,360
And then once we encountered the moon, we leave it, which we also saw here at the distance plot.

151
00:11:18,380 --> 00:11:24,500
And now with the engine turned on at this short amount of time, we get such a trajectory.

152
00:11:25,040 --> 00:11:31,670
First, the Oval and then you see it moves somewhere close to the trajectory of the Moon.

153
00:11:33,020 --> 00:11:38,330
And you see this is what happens when you plot the distance spaceship moon.

154
00:11:38,870 --> 00:11:45,080
It goes first on this funky oval shape and then here and 0.11.

155
00:11:45,080 --> 00:11:51,710
Maybe here to here we turn on the engine and we break the spaceship a whole lot.

156
00:11:52,130 --> 00:11:55,130
And then you see, this is what we end up with.

157
00:11:56,120 --> 00:11:58,100
So that's pretty cool, I think.

158
00:11:58,550 --> 00:12:03,560
It's not the last thing that I want to show you is a plot similar to this one where we have plotted

159
00:12:03,560 --> 00:12:09,110
the trajectory of the spaceship with respect to the Earth, where the Earth was fixed here.

160
00:12:09,110 --> 00:12:10,880
So as well as with respect to Earth.

161
00:12:11,510 --> 00:12:14,390
So I copied this code here and adapted it.

162
00:12:14,540 --> 00:12:17,300
And instead, now we are in the reference frame of the Moon.

163
00:12:17,780 --> 00:12:23,360
So we have X and Y with respect to the Moon and the X and Y limits are a bit zoomed in, of course,

164
00:12:23,360 --> 00:12:28,460
because the radius of the trajectory is, of course, pretty, pretty small here.

165
00:12:28,790 --> 00:12:35,900
As you can see, it's oscillating pretty closely around the Moon compared to the previous rotation around

166
00:12:35,900 --> 00:12:36,290
the Earth.

167
00:12:37,400 --> 00:12:40,780
And here I changed the indices.

168
00:12:40,790 --> 00:12:46,820
So previously we had here three and four for the Earth, and now it's six and seven for the Moon and

169
00:12:46,820 --> 00:12:47,960
you see already the results.

170
00:12:48,500 --> 00:12:49,350
This is what we get.

171
00:12:49,370 --> 00:12:56,450
We have a point where we enter the vicinity of the Moon, which is positioned here at zero zero and

172
00:12:56,450 --> 00:13:00,830
then we oscillate on the rather strange looking trajectory.

173
00:13:00,840 --> 00:13:04,700
So it looks pretty funny, actually very, very oval.

174
00:13:05,120 --> 00:13:11,930
And also, since these points here are quite far still from the position of the Moon, it will still

175
00:13:11,930 --> 00:13:14,390
very strongly feel the influence of the Earth.

176
00:13:14,990 --> 00:13:21,170
So this is why it will not move on the same oval, the whole time of why it will be shifted around the

177
00:13:21,170 --> 00:13:21,710
whole time.

178
00:13:22,740 --> 00:13:29,820
So we could fix this if we want to make our orbits here are circular.

179
00:13:30,120 --> 00:13:35,910
And if we would make it pretty small, this we could achieve, for example, by breaking another time

180
00:13:35,910 --> 00:13:44,420
when we are here, so we could now add here in our plots, for example, when we are here at this point

181
00:13:44,430 --> 00:13:51,720
or also maybe at this point we could break another time so we could change here on a break function

182
00:13:51,720 --> 00:13:56,670
and add another two heavy side functions and another brake maneuver.

183
00:13:57,480 --> 00:14:03,060
But I want to leave it as it is, even though it looks a bit funny, it is a trajectory and an orbit

184
00:14:03,060 --> 00:14:06,990
around the Moon, even though it's not very, very stable.

185
00:14:06,990 --> 00:14:12,360
I think if you would simulate this for several years, you would eventually leave the Moon once again.

186
00:14:12,750 --> 00:14:18,090
But you could easily avoid this in reality by just breaking another time, as I just told you.

187
00:14:19,210 --> 00:14:25,240
And we could go even one step further by breaking at this point, even stronger.

188
00:14:25,990 --> 00:14:29,890
And then we would hit the Moon, we would crash into the Moon.

189
00:14:30,850 --> 00:14:37,870
So now it's really just a matter of optimizing the parameters or adding more break maneuvers and making

190
00:14:37,870 --> 00:14:39,340
everything a bit more complicated.

191
00:14:39,820 --> 00:14:42,460
And then you can really achieve everything we want.

192
00:14:43,000 --> 00:14:49,480
So if you want to do it, that's nice exercise to play a bit more with the code and the parameters.

193
00:14:49,900 --> 00:14:57,490
But eventually, everything comes down to using the integrator to solve IBP, and it comes also down

194
00:14:57,850 --> 00:15:01,360
to programming this differential equation here.

195
00:15:02,170 --> 00:15:05,350
And for this one, we have a four body problem.

196
00:15:05,680 --> 00:15:14,080
We had 12 plus 12 equations, 12 equations for the coordinates of the four objects and 12 equations

197
00:15:14,200 --> 00:15:16,210
for the velocities.

198
00:15:17,350 --> 00:15:21,970
So that's the end of this lecture about the three body problem, which we have actually turned into

199
00:15:21,970 --> 00:15:22,990
a full body problem.

200
00:15:23,470 --> 00:15:28,990
And we have learned quite a lot about in America and also about the physics, especially.

201
00:15:28,990 --> 00:15:35,410
I think this is a very nice lecture because we have achieved this moon orbit, we have achieved the

202
00:15:35,980 --> 00:15:37,990
surface K by a moon and counter.

203
00:15:37,990 --> 00:15:45,820
We have achieved the regular purpose escape and we have achieved a circular and an overall trajectory

204
00:15:46,000 --> 00:15:46,840
around the Earth.

