Give me (L(q,\dot q,t)) and I’ll give you the motion. This repo auto-derives the Euler–Lagrange equations with SymPy and integrates the resulting ODEs with SciPy. It includes ready-to-run examples (pendulum, double pendulum, N-body gravity, and spring–mass networks) and lightweight animations.
- Symbolically derive Euler–Lagrange equations from a user-specified Lagrangian (SymPy).
- Convert to first-order ODEs and integrate (SciPy
solve_ivp). - Jupyter notebooks with visualizations and energy-drift diagnostics.
- python3 -m venv .venv
- source .venv/bin/activate
- pip install -r requirements.txt
- pip install -e .
- notebooks/01_simple_pendulum_lib.ipynb — minimal library usage.
- notebooks/02_double_pendulum.ipynb — chaotic two-link example.
- notebooks/03_springs_random.ipynb — 4-mass spring ring with random initialization and animation.
pre-commit run --all-files
pytest -q
pytest --cov=src/euler_lagrange_solutions --cov-report=term-missing
MIT Licence
If you use this code in academic work, please cite the repository.
- End-to-end EL pipeline (symbolic → numeric → integration).
- Clean, modern Python: type hints, tests, CI, pre-commit.
- Clear demos with small, readable notebooks + animations.