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
- No drag + Euler + Δt=0.5 s. Compare numerical and analytical trajectories.
- Reduce Δt through 0.5, 0.2, 0.1, 0.05 and 0.01 s.
- Repeat with RK4 and compare convergence.
- Compare Earth, Moon and Mars.
- Compare drag-free and resisted motion.
- Compare 30° and 60° without drag, then with drag.
- Increase v₀ under quadratic drag and observe the stronger drag effect.