Differential equation

xs = G * mE * -xs / |xs| + G * mm * Xm-xs/ |xm-xs|^3
non-linear

x(t)=sin(t)
x(t)=sin(x(t))
x(t)=cos(y(t))
t=(y(t))^2

differential equation that govern the motion
simple solution method

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import math
from xxx import *
 
moon_distance = 384e6
 
def orbit():
    num_steps = 50
    x = numpy.zeros([num_steps + 1, 2])
 
    for i in range(num_steps + 1):
        angle = 2.*path.pi * i / num_steps
        x[i, 0] = moon_distance * math.cos(angle)
        x[i, 1] = moon_distance * math.sin(angle)
 
    return x
 
x = orbit()
 
@show_plot
def plot_me():
    matplotlib.pyplot.axis('equal')
    matplotlib.pyplot.plot(x[:, 0], x[:, 1])
    axes = matplotlib.pyplot.gca()
    axes.set_xlabel('Longitudinal position in m')
    axes.set_ylabel('Lateral position in m')
plot_me()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import math
from xxx import *
 
h = 0.1
g = 9.81
acceleration = numpy.array
initial_speed = 20. # m / s
 
@show_plot
def trajectory():
    angles = numpy.linspace(20., 70., 6)
 
    num_steps = 30
    x = numpy.zeros([num_steps + 1, 2])
    v = numpy.zeros([num_steps + 1, 2])
 
    for angle in angles:
 
        matplotlib.pyplot.plot(x[:, 0], x[:, 1])
    matplotlib.pyplot.axis('equal')
    axes = matplotlib.pyplot.gca()
    axes.set_xlabel('Horizontal position in m')
    axes.set_ylabel('Vertical position in m')
    return x, v
 
trajectory()