Im trying to model a 3 body system consisting of the sun, earth and moon.

G = 2.959*10^-4 ;(*gravitational constant in AU *)
M = 1;(*sun mass in solar masses*)
m = {3.004*10^-6, 
  3.694*10^-8};(*earth and moon mass in solar masses*)
r = {0.9832898881618759`, 0.002428907`, 0.9808609811618759`}; 
   \[Psi] = 0;
rx = r Cos[\[Psi]](* sun earth, earth moon, moon sun initial positions in x plane*) 
ry = r Sin[\[Psi]](* sun earth, earth moon, moon sun initial positions in y plane*)
v = {0.001762413343260659`, 
  0.0040054254086806474`}(*earth,moon initial velocities*)
T = {365.2, 28}(*earth moon period*)

Im trying to use NDsolve to solve the second order differential equations so that i can plot the motion of the earth revoling around the sun and the moon orbiting the earth. For now im trying to start with modelling the earth orbiting the sun with the gravitational forces of the sun and the moon acting upon it

I have the equations of motion for the the gravitational force act ing on the earth

    planet = Table[NDSolve[{
(x^\[Prime]\[Prime])[t] + (
  G*M*Subscript[x, e][t])/(Subscript[x, e][t]^2 + 
    Subscript[y, e][t]^2)^(3/2) + (
   Subscript[x, em][t])/(Subscript[x, em][t]^2 + 
    Subscript[y, em][t]^2)^(3/2) == 
 0, (y^\[Prime]\[Prime])[t] + (
  G*M*Subscript[y, e][t])/(Subscript[x, e][t]^2 + 
    Subscript[x, e][t]^2)^(3/2) + (
   Subscript[y, em][t])/(Subscript[x, em][t]^2 + 
    Subscript[y, em][t]^2)^(3/2) == 0,
Subscript[x, e][0] == rx[[i]], Subscript[x, em][0] == rx[[j]], 
Subscript[y, e][0] == 0, Derivative[1][Subscript[x, e]][0] = 0, 
Derivative[1][Subscript[y, e]][0] == v[[i]], 
Derivative[1][Subscript[x, em]][0] = 0, 
Derivative[1][Subscript[y, em]][0] == v[[j]]}, {x, y, Subscript[x,
 e], Subscript[y, e], Subscript[x, em], Subscript[y, em]}, {t, 0, 
365}], {i, 1, 1}, {j, 2, 2}]

subscripts denote
 em = earth to moon.

When i run this i receive the error NDSolve: Equation or list of equations expected instead of True in the first \ argument

Could anyone point out what is causing this?

  • 1
    $\begingroup$ Maybe consider using NBodySimulation. See this example. $\endgroup$ – Chip Hurst Oct 21 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.