Passer en coordonnées sphériques dans le lagrangien libre.
import warnings
warnings.filterwarnings("ignore")
import sympy as sp
sp.init_printing()
t = sp.Symbol("t")
t
r = sp.Function("r")(t)
r
sp.diff(r)
theta = sp.Function("\\theta")(t)
theta
phi = sp.Function("\\phi")(t)
phi
x = r * sp.cos(theta) * sp.cos(phi)
x
y = r * sp.cos(theta) * sp.sin(phi)
y
z = r * sp.sin(theta)
z
m, vx, vy, vz = sp.symbols("m v_x v_y v_z")
vx
L = m * (vx ** 2 + vy ** 2 + vz ** 2) / 2
L
xd, yd, zd = x.diff(), y.diff(), z.diff()
xd
res = L.subs(
{
vx: xd,
vy: yd,
vz: zd
}
).expand()
res
l = sp.Symbol("l")
final = res.subs(r.diff(), 0).subs(r, l).trigsimp()
final
e1 = sp.Eq(final.diff(theta.diff()).diff(t) - final.diff(theta), 0)
e1
e2 = sp.Eq(final.diff(phi.diff()).diff(t) - final.diff(phi), 0)
e2
Rajouter la force de gravitation.