00001 function yp = yprime(t,y) 00002 %YPRIME Define differential equations for restricted three-body problem. 00003 % YP = YPRIME(T,Y) defines a system of ordinary differential 00004 % equations representing the motion of a body of small mass 00005 % in orbit about the earth and moon. This is a simple example 00006 % of the "restricted three-body problem," which models the 00007 % motion of a body of small mass in the vicinity of two other 00008 % massive bodies. 00009 % 00010 % The coordinate system moves with the earth-moon system. 00011 % The 1-axis goes through the centers of the earth and the moon. 00012 % The 2-axis is perpendicular, in the plane of motion of the third body. 00013 % The origin is at the center of gravity of the two heavy bodies. 00014 % Let mu = the ratio of the mass of the moon to the mass of the earth. 00015 % The earth is located at (-mu,0) and the moon at (1-mu,0). 00016 % 00017 % T represents time. It is ignored in YPRIME because the differential 00018 % equations are not functions of time. 00019 % 00020 % Y is a column or row vector with 4 elements. 00021 % Y(1) and Y(3) = coordinates of the third body. 00022 % Y(2) and Y(4) = velocity of the third body. 00023 % 00024 % The output YP is a column vector with 4 elements representing 00025 % derivatives of y with respect to t given the input Y. 00026 % 00027 % YPRIME is suitable as input to one of the ODE solvers, such as ODE23. 00028 % For example: 00029 % 00030 % [t,y]=ode23(@yprime,[0 1],[0 1 2 3]) 00031 00032 % Copyright 1984-2006 The MathWorks, Inc. 00033 % All Rights Reserved. 00034 00035 mu = 1/82.45; 00036 mus = 1-mu; 00037 r1 = norm([y(1)+mu, y(3)]); % Distance to the earth 00038 r2 = norm([y(1)-mus, y(3)]); % Distance to the moon 00039 yp(1) = y(2); 00040 yp(2) = 2*y(4) + y(1) - mus*(y(1)+mu)/r1^3 - mu*(y(1)-mus)/r2^3; 00041 yp(3) = y(4); 00042 yp(4) = -2*y(2) + y(3) - mus*y(3)/r1^3 - mu*y(3)/r2^3; 00043 % yp = yp';