Lagrange

Find barycentric L1 and L2 Lagrange points from normalized mass ratio

#!/usr/bin/env python3
import sys
from scipy.optimize import brentq
R = float(sys.argv[1])
m1 = R / (R + 1.0)
m2 = 1.0 / (R + 1.0)
x1 = -m2
x2 =  m1
def f(x):
    r1 = abs(x - x1)
    r2 = abs(x - x2)
    return (
        x
        - m1 * (x - x1) / r1**3
        - m2 * (x - x2) / r2**3
    )
eps = 1e-12
L1 = brentq(f, x1 + eps, x2 - eps)
L2 = brentq(f, x2 + eps, x2 + 2.0)
r1 = x2 - L1
r2 = L2 - x2
print(f"Primary   : {x1:.12f}")
print(f"Secondary : {x2:.12f}")
print(f"L1        : {L1:.12f}")
print(f"L2        : {L2:.12f}")
print(f"L1 offset : {r1:.12f}")
print(f"L2 offset : {r2:.12f}")

Unknown's avatar

About Linuxgal

Need a spiritual home? Consider joining us at Mary Queen of the Universe Latter-day Buddhislamic Free Will Christian UFO Synagogue of Vishnu
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment