# Plot the elliptical orbit from a Lagrangian?

Posted 8 days ago
141 Views
|
2 Replies
|
1 Total Likes
|
 Can anyone help me? I want to make the orbit ellipse. Please help me to fix my code. lagrangian = 1/2 (x'[t]^2 + y'[t]^2) + 1/Sqrt[x[t]^2 + y[t]^2]; eq = Table[ D[lagrangian, x1] - D[D[lagrangian, D[x1, t]], t] == 0, {x1, {x[t], y[t]}}]; sol = NDSolve[Join[eq, {x[0] == 1, x'[0] == 0, y[0] == 0, y'[0] == 1}], {x[t], y[t]}, {t, 0, 5}]; ParametricPlot[{x[t], y[t]} /. sol[[1]], {t, 0, 5}] enter image description here
2 Replies
Sort By:
Posted 8 days ago
 it's easier to trouble shoot code if you look at it one line at a time instead of all at once. also, it's easier for other people to read the code if you use the first icon to paste in your code.