Projectile Motion: Numerical vs Analytical

Explore initial velocity, launch angle, gravity and air resistance. Compare Euler and RK4 integration with exact solutions where available, and inspect numerical error directly.

Trajectory y(x)

NumericalAnalyticalComparison snapshots

Quantitative results

Position vs time

Velocity vs time

Numerical error

Theory / numerical method

Newton's second law gives a first-order system for s=(x,y,vₓ,vᵧ). The derivative function returns ds/dt=(vₓ,vᵧ,aₓ,aᵧ).

Euler: sₙ₊₁ = sₙ + Δt f(sₙ,tₙ). It is simple and first-order accurate.

RK4: evaluates four slopes and combines them as sₙ₊₁ = sₙ + (Δt/6)(k₁+2k₂+2k₃+k₄). It is much more accurate for the same sufficiently small Δt.

No drag and linear drag have closed-form solutions used here for independent validation. Quadratic drag is solved numerically in this demonstration.

Things to try
  1. No drag + Euler + Δt=0.5 s. Compare numerical and analytical trajectories.
  2. Reduce Δt through 0.5, 0.2, 0.1, 0.05 and 0.01 s.
  3. Repeat with RK4 and compare convergence.
  4. Compare Earth, Moon and Mars.
  5. Compare drag-free and resisted motion.
  6. Compare 30° and 60° without drag, then with drag.
  7. Increase v₀ under quadratic drag and observe the stronger drag effect.