0

Given the initial position and velocity, I want get the trajectory of an object in a gravitational field. Instead of using Kepler's Laws, I want to solve the following differential equations:

enter image description here

DSolve[{x[0] == a, y[0] == b, Derivative[1][x][0] == c, 
  Derivative[1][y][0] == 
   d, (x^\[Prime]\[Prime])[t] == -((G M x[t])/(x[t]^2 + y[t]^2)^(
    3/2)), (y^\[Prime]\[Prime])[t] == -((G M y[t])/(x[t]^2 + y[t]^2)^(
    3/2))}, {x, y}, t]

But instead of solving it, Mathematica just returns the expression itself. Any help?

lovetl2002
  • 143
  • 4

1 Answers1

4

After correcting several syntax errors, you may get a numerical solution by e.g. with arbitrary values for G and M:

G = 1;
M = 1;
a = 1; b = 0;
c = 0; d = 0.5;
tmax = 3;
sol = NDSolve[{x[0] == a, y[0] == b, x'[0] == c, y'[0] == d, 
    x''[t] == -((G M x[t])/(x[t]^2 + y[t]^2)^(3/2)), 
    y''[t] == -((G M y[t])/(x[t]^2 + y[t]^2)^(3/2))}, {x, y}, {t, 0, 
    tmax}];

ParametricPlot[Evaluate[{x[t], y[t]} /. sol], {t, 0, tmax}]

enter image description here

Or an ubounded orbit with a bit more initial velocity:

G = 1;
M = 1;
a = 1; b = 0;
c = 0; d = 1.5;
tmax = 10;
sol = NDSolve[{x[0] == a, y[0] == b, x'[0] == c, y'[0] == d, 
x''[t] == -((G M x[t])/(x[t]^2 + y[t]^2)^(3/2)), 
y''[t] == -((G M y[t])/(x[t]^2 + y[t]^2)^(3/2))}, {x, y}, {t, 0, 
tmax}];

ParametricPlot[Evaluate[{x[t], y[t]} /. sol], {t, 0, tmax}]

enter image description here

Cesareo
  • 3,963
  • 7
  • 11
Daniel Huber
  • 51,463
  • 1
  • 23
  • 57