Hand-implemented Euler and RK4 integrators (no scipy.integrate),
validated on two problems: projectile motion with quadratic air
drag, and the simple harmonic oscillator.
solvers.py— generic Euler and RK4 steppersprojectile.py— 2D projectile motion with drag; Euler vs RK4 trajectory and convergence-order comparisonsho.py— SHO with exact analytic solution as ground truth; long-time energy conservation comparison
- Convergence order confirmed numerically: Euler ~O(h), RK4 ~O(h⁴)
- Euler is unconditionally unstable for oscillatory systems — energy grows without bound over long integration times regardless of step size, while RK4's drift is far slower but nonzero. This motivated looking into symplectic integrators (leapfrog) as a next step for long-time energy-conserving simulation.
Generalizing the solver (vector states of arbitrary size, adaptive step size) and building a leapfrog/Störmer-Verlet integrator, toward the charged particle EM simulation project.