Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Numerical ODE Solver — From First Principles

Hand-implemented Euler and RK4 integrators (no scipy.integrate), validated on two problems: projectile motion with quadratic air drag, and the simple harmonic oscillator.

What's here

  • solvers.py — generic Euler and RK4 steppers
  • projectile.py — 2D projectile motion with drag; Euler vs RK4 trajectory and convergence-order comparison
  • sho.py — SHO with exact analytic solution as ground truth; long-time energy conservation comparison

Key results

  • 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.

Next

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.

About

Hand-implemented Euler and RK4 integrators (no scipy.integrate), validated on two problems: projectile motion with quadratic air drag, and the simple harmonic oscillator.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages