Skip to content

Instantly share code, notes, and snippets.

@BrianWeinstein
Created June 8, 2014 00:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrianWeinstein/c6d58762469a5f8de1ba to your computer and use it in GitHub Desktop.
Save BrianWeinstein/c6d58762469a5f8de1ba to your computer and use it in GitHub Desktop.
Ueff[x_, y_, m1_, x1_, y1_, m2_, x2_, y2_] :=
-((G*m1)/Sqrt[(x - x1)^2 + (y - y1)^2]) -
(G*m2)/Sqrt[(x - x2)^2 + (y - y2)^2] - (G*(m1 + m2)*(x^2 + y^2))/(2*Sqrt[(x1 - x2)^2 + (y1 - y2)^2]^3)
G = 1; m1 = 1; x1 = -1.25; y1 = 0; m2 = 0.45; x2 = 1.25; y2 = 0;
L1 = {FindRoot[D[Ueff[x, 0, m1, x1, y1, m2, x2, y2], x], {x, 0.5}][[1,2]], 0};
L2 = {FindRoot[D[Ueff[x, 0, m1, x1, y1, m2, x2, y2], x], {x, 1.5}][[1,2]], 0};
L3 = {FindRoot[D[Ueff[x, 0, m1, x1, y1, m2, x2, y2], x], {x, -1.5}][[1,2]], 0};
L4 = FindRoot[{D[Ueff[x, y, m1, x1, y1, m2, x2, y2], x] == 0,
D[Ueff[x, y, m1, x1, y1, m2, x2, y2], y] == 0}, {x, 0.5}, {y, 1}][[All,2]];
L5 = FindRoot[{D[Ueff[x, y, m1, x1, y1, m2, x2, y2], x] == 0,
D[Ueff[x, y, m1, x1, y1, m2, x2, y2], y] == 0}, {x, 0.5}, {y, -1}][[All,2]];
LPts = {L1, L2, L3, L4, L5};
LPts3D = Table[Flatten[{LPts[[i]], Ueff[LPts[[i,1]], LPts[[i,2]], m1, x1, y1, m2, x2, y2]}], {i, 1, 5}];
Show[
Graphics3D[
{Darker[Gray, 0.6], Sphere[LPts3D, 0.1],
Cyan, Sphere[{x1, y1, -0.85}, m1/2],
Magenta, Sphere[{x2, y2, -0.85}, m2/2]}],
Plot3D[
Ueff[x, y, m1, x1, y1, m2, x2, y2], {x, -4, 4}, {y, -4, 4},
PlotRange -> 2, Mesh -> 10, MeshStyle -> Dashed, PlotStyle -> Opacity[0.93],
ColorFunction -> ColorData["Rainbow"]], Boxed -> False, Axes -> False]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment