5MM023: Matlab Assignment Task(See Canvas for Submission Deadline)This assignment is designed to test your ability to use Matlab to solve a mathematicalmodelling problem. You are asked to write a Matlab program, which can include scriptsand function files which you write. The program should be user friendly i.e., your programshould require very little knowledge of programming or mathematical modelling from theuser in order to use/run it. You should make comments within your program so it is clearto anyone using it what each part of your program does. This assignment counts for30% of your final grade for this module.For a detailed breakdown of how the marks will be distributed please see assessmentrubric on Canvas.• Submission Date: See Canvas.• All work which you submit must be your own. Cheating is a serious offense and will be dealt with under the University disciplinary procedures.• This assignment should typically take about 10 hours. If you spend significantlymore than this on the assignment then you may disadvantage yourself with regardto the other aspects of this module and other modules.I am here to help in anyway I can, so please ask for my help if you are havingdifficulty. Good luck and enjoy as this is a really interesting problem!1The Three Body ProblemLet us consider the motion of a spacecraft in the gravitational field of two bodies (suchas the Earth and the Moon). The equations governing the motion of the spacecraft forma system of second order differential equations. The system is illustrated below.Figure 1: The Three Body Problem. E and M are the distances the Earth and Moon arefrom the centre of mass respectively.Both bodies impose a force on the spacecraft according to Newton’s gravitational law, butthe mass of the spacecraft is too small to significantly affect the motion of the bodies. Wetherefore neglect the influence of the spacecraft on the two stellar bodies. Our coordinatesystem has its origin at the centre of mass of the Earth and Moon. The governingequations are given byd2xdt2 = 2dydt + x –M(x + E)r3E–E(x – M)r3Md2ydt2 = -2dxdt + y –Myr3E–Eyr3Mwhere rE = p(x + E)2 + y2, rM = p(x – M)2 + y2, and M = 1 – E. The Earth andMoon are assumed to have circular orbits around the centre of mass of the system. Tosimplify the problem, we therefore consider a coordinate system which is rotating withthe Earth and Moon. In this system, the Earth does not move and is located at (-E; 0)and the moon is located at (M; 0). The governing equations contain terms in r12 , whichcorrespond to the gravitational force. (Ok, in the governing equations it is actually r13 ,but this term is still associated with the gravitational force, ask me if you would like anexplanation.) The equations also contain terms dy dt and -dx dt , which correspond to theCoriolis force, as well as terms x and y, which correspond to the Centrifugal force.Before you try and solve this system of second-order differential equations we must reduceit to a set of four first order equations. To do this, we define z1 = x;z2 =dxdt ;z3 = y;andz4 = dy dt : In vector form, we getZ =26664z1z2z3z437775=26664x _x y _y37775:2Therefore,Z_ =26664z_1z_2z_3z_437775=26664_x ¨x _y ¨y37775=266664z22z4 + z1 – M(z1+E)r3E–E(z1-M)r3Mz4-2z2 + z3 – Mz3r3E–Ez3r3M377775:where rE = p(z1 + E)2 + z32, rM = p(z1 – M)2 + z32, and M = 1 – E. Set the valueE = 0:012277.Your AssignmentYour job as modellers is to write a Matlab program which prompts the user for thelength of time you wish to solve the spacecraft motion for, the initial position and theinitial velocity of the spacecraft. Use the following values to test your program:Time from: t = 0 to t = 24:Initial Position: x(0) = 1:15; y(0) = 0:Initial Velocity: dxdt (0) = 0; dy dt (0) = 0:008688:After establishing these values your program will solve the given system of equations andplot the solution (the trajectory of the spacecraft) in a figure window. The solution forthe test parameters above is plotted in the figure below. You should be able to reproducethis plot with you program.Figure 2: Solution to the Three Body Problem for the test parameters.3
