2 Grammar improved.

And the samechanged indices for the other functions (ie the E-L equation for x2 was stored in eqnx[2], etc). I combined all these elements, along with ICs, into a master list.

Plot[x1[t]x1[t]/.soln[[1]]soln[[1]];
Plot[x1[t], {t,0,20}]


I get a blank screen for x1 and every other function. Rather annoying! This makes it impossible for me to even animate it; I created points as follows:

And the same indices for the other functions. I combined all these elements, along with ICs, into a master list.

Plot[x1[t]/.soln[[1]], {t,0,20}]


I get a blank screen. Rather annoying! This makes it impossible for me to even animate it; I created points as follows:

And changed indices for the other functions (ie the E-L equation for x2 was stored in eqnx[2], etc). I combined all these elements, along with ICs, into a master list.

x1[t]/.soln[[1]];
Plot[x1[t], {t,0,20}]


I get a blank screen for x1 and every other function. Rather annoying! This makes it impossible for me to even animate it; I created points as follows:

1

# Solving and Animating Three Body Problem

I am attempting to solve a three-body problem using the Lagrange formalism, with a 1/r potential.

I started off by defining T and U (kinetic and potential energy) as follows:

Tx = .5 m1  x1'[t]^2 + .5 m2 x2'[t]^2 + .5 m3  x3'[t]^2;
Ty = .5 m1  y1'[t]^2 + .5 m2 y2'[t]^2 + .5 m3  y3'[t]^2;

U1 = G m1 m2 /((x1[t] - x2[t])^2 + (y1[t] - y2[t])^2)^.5 +
G m1 m3 /((x1[t] - x3[t])^2 + (y1[t] - y3[t])^2)^.5;

U2 = G m2 m1 /((x2[t] - x1[t])^2 + (y2[t] - y1[t])^2)^.5 +
G m2 m3 /((x2[t] - x3[t])^2 + (y2[t] - y3[t])^2)^.5;

U3 = G m3 m1 /((x3[t] - x1[t])^2 + (y3[t] - y1[t])^2)^.5 +
G m3 m2 /((x3[t] - x2[t])^2 + (y3[t] - y2[t])^2)^.5;
U = U1 + U2 + U3;
T = Tx + Ty;
lag = T - U;


And assigning arbitrary values to constants.

Where x1[t] and y1[t] are the x and y coordinates of mass 1, and the same for masses 2 and 3.

From here, I found the Euler-Lagrange EQs via the function

EL[q_] := D[lag, q] - Dt[D[lag, D[q, t]], t];


Where I input x1[t], x2[t], etc. as q. I stored them in a list such that

eqnx[1] = EL[x1[t]] == 0 // FullSimplify;
eqny[1] = EL[y1[t]] == 0 // FullSimplify;


And the same indices for the other functions. I combined all these elements, along with ICs, into a master list.

IC1 = {x1[0] == 0, y1[0] == 0, x1'[0] == 0, y1'[0] == 0};
IC2 = {x2[0] == 10, y2[0] == 0, x2'[0] == 0, y2'[0] == 0};
IC3 = {x3[0] == 0, y3[0] == 15, x3'[0] == 0, y3'[0] == 0};
eqnlist = Join[delist, IC1, IC2, IC3];


Where delist was created by joining all the elements of eqnx and eqny.

I then plugged eqnlist into NDSolve with arbitrary bounds of t (since DSolve could/would not solve a complicated, non-linear system of ODEs for me) as follows:

soln = NDSolve[eqnlist, {x1, y1, x2, y2, x3, y3}, {t, 0, 20}][[1]];


From here, I am stuck. soln is a list with six elements, each corresponding to one of the functions I want, but I am unable to store them into x1[t], y1[t], etc; when I run

Plot[x1[t]/.soln[[1]], {t,0,20}]


I get a blank screen. Rather annoying! This makes it impossible for me to even animate it; I created points as follows:

point1 = Graphics[{PointSize[Medium], Red,
Point[Dynamic[{x1[t], y1[t]}]]}];


With the indices and colors changed for masses 2 and 3, and have set up Animate as follows:

Animate[Show[point1, point2, point3], {t, 0, 20}]


I am not sure how to resolve my assigning-functions-properly problem, and I am reasonably sure that this may solve my animation problem (or it could be that my animation is bugged to begin with!).