This webpage uses the Runge-Kutta-Fehlberg fourth-order method with fifth-order error checking (RKF45) to approximate the solution to the equations of motion for a projectile subjected to constant gravity and linear and quadratic drag
d 2 x d t 2 = − d x d t ( b + c ( d x d t ) 2 + ( d y d t ) 2 ) d 2 y d t 2 = − g − d y d t ( b + c ( d x d t ) 2 + ( d y d t ) 2 ) . \begin{aligned} \dfrac{d^2 x}{dt^2} &= -\dfrac{dx}{dt}\left(b+c\sqrt{\left(\dfrac{dx}{dt}\right)^2+\left(\dfrac{dy}{dt}\right)^2}\right) \\ \dfrac{d^2 y}{dt^2} &= -g-\dfrac{dy}{dt}\left(b+c\sqrt{\left(\dfrac{dx}{dt}\right)^2+\left(\dfrac{dy}{dt}\right)^2}\right). \end{aligned} d t 2 d 2 x d t 2 d 2 y = − d t d x ⎝ ⎜ ⎛ b + c ( d t d x ) 2 + ( d t d y ) 2 ⎠ ⎟ ⎞ = − g − d t d y ⎝ ⎜ ⎛ b + c ( d t d x ) 2 + ( d t d y ) 2 ⎠ ⎟ ⎞ . Where g g g is the gravitational acceleration constant, b b b is the linear drag coefficient for the projectile divided by its mass and c c c is the quadratic drag coefficient for the projectile divided by its mass. y < 0 y < 0 y < 0 is not allowed in the solver, as it is assumed that y = 0 y=0 y = 0 is the ground. If c = 0 c=0 c = 0 , exact solutions are used. Namely, if b ≠ 0 b\neq0 b = 0
x ( t ) = x 0 + x ˙ 0 b ( 1 − e − b t ) y ( t ) = y 0 − g t 2 2 + y ˙ 0 b ( 1 − e − b t ) , \begin{aligned} x(t) &= x_0 + \dfrac{\dot{x}_0}{b}\left(1-e^{-bt}\right) \\ y(t) &= y_0 - \dfrac{gt^2}{2} + \dfrac{\dot{y}_0}{b}\left(1-e^{-bt}\right), \end{aligned} x ( t ) y ( t ) = x 0 + b x ˙ 0 ( 1 − e − b t ) = y 0 − 2 g t 2 + b y ˙ 0 ( 1 − e − b t ) , whereas if b = 0 b=0 b = 0
x ( t ) = x 0 + x ˙ 0 t y ( t ) = y 0 + y ˙ 0 t − g t 2 2 . \begin{aligned} x(t) &= x_0 + \dot{x}_0 t \\ y(t) &= y_0 + \dot{y}_0 t - \dfrac{gt^2}{2}. \end{aligned} x ( t ) y ( t ) = x 0 + x ˙ 0 t = y 0 + y ˙ 0 t − 2 g t 2 .