Numerical error
Results
Theory / Numerical method
Equations of motion. Newton's second law gives a set of four first-order ODEs for s = (x, y, vₓ, v_y): dx/dt = vₓ, dy/dt = v_y, dvₓ/dt = aₓ, dv_y/dt = a_y − g. Drag acceleration: a = 0 (A), a = −γ·v (B), a = −c·|v|·v (C). The coefficient c can be interpreted as c = ρ·C_D·A/(2m).
Euler method: sn+1 = sn + Δt·f(sn, tn). It is simple but only first-order accurate: the global error scales as Δt.
RK4: evaluates four slopes k₁…k₄ and combines them: sn+1 = sn + (Δt/6)(k₁ + 2k₂ + 2k₃ + k₄). The global error scales as Δt⁴, so for a sufficiently small step it is far more accurate.
Impact is not taken as the first point below ground: between the last point above ground and the first point below it, the position is interpolated with a cubic Hermite polynomial and the root y = 0 is found by bisection.
Analytical vs. numerical solution. Without drag and with linear drag an exact solution exists (shown dashed; for γ → 0 the no-drag limit is used). For quadratic drag the equations are coupled and are solved numerically – no elementary closed-form trajectory is used here.
Things to try
- No air resistance, Euler, Δt = 0.5 s: compare the numerical and analytical trajectories.
- Reduce Δt step by step: 0.5, 0.2, 0.1, 0.05, 0.01 s, and watch how the error changes.
- Repeat with RK4.
- Compare the motion on Earth, the Moon and Mars (comparison mode).
- Compare trajectories with and without air resistance.
- Without drag: do complementary angles such as 30° and 60° give equal ranges?
- Repeat the previous experiment with air resistance.
- How does the importance of quadratic drag change as the initial speed increases?