Projectile motion solver

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

d2xdt2=dxdt(b+c(dxdt)2+(dydt)2)d2ydt2=gdydt(b+c(dxdt)2+(dydt)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}

Where gg is the gravitational acceleration constant, bb is the linear drag coefficient for the projectile divided by its mass and cc is the quadratic drag coefficient for the projectile divided by its mass. y<0y < 0 is not allowed in the solver, as it is assumed that y=0y=0 is the ground. If c=0c=0, exact solutions are used. Namely, if b0b\neq0

x(t)=x0+x˙0b(1ebt)y(t)=y0gt22+y˙0b(1ebt),\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}

whereas if b=0b=0

x(t)=x0+x˙0ty(t)=y0+y˙0tgt22.\begin{aligned} x(t) &= x_0 + \dot{x}_0 t \\ y(t) &= y_0 + \dot{y}_0 t - \dfrac{gt^2}{2}. \end{aligned}
Simulation parameter form.
Parameter Value Explanation
Gravitational acceleration in metres per second squared.
Linear dissipation coefficient divided by projectile mass.
Quadratic dissipation coefficient divided by projectile mass.
End time for the simulation in seconds.
Initial horizontal position of projectile.
Initial horizontal velocity of projectile.
Initial vertical position of projectile.
Initial vertical velocity of projectile.
Number of steps used for exact solution.
Error tolerance.
Tolerance type, can be either absolute (0) or relative (1).
Initial step size.
Minimum allowed step size.
Time increment for skipping ahead in animation.
Time you want to skip ahead to in animation when you press the skip button.
Width (in px) of Plotly windows used for plotting and animation below.
Height (in px) of Plotly windows used for plotting and animation below.
Proportion of animation time passed per real time. tScale=1.0t_{\mathrm{Scale}}=1.0 means animation and real time match. tScale<1.0t_{\mathrm{Scale}}<1.0 means the animation is going more slowly than real time. tScale>1.0t_{\mathrm{Scale}}>1.0 means it is going more rapidly.