Solving numerically, the position of a rocket from its forces So how would you solve this equation of the rocket, to find the position of the rocket as it changes with time?
$$T(t) - m(t)g - kv^2 = m(t)a$$
Thrust(changes with time) - weight(changes with time) - drag(changes with velocity) = mass(changes with time) * acceleration
If I knew the thrust function, the change in mass function and the value of $k$.
Would you be able to create code to numerically solve this, conceptually?
 A: You also need some initial condition, like the velocity $v$ at $t=0$, let's call it $v_0$, and the position $x$ at $t=0$, let's call it $x_0$.
We know that the acceleration is the change of velocity with time, $a = \frac{dv}{dt}$, and the velocity is the change of position with time, $v = \frac{dx}{dt}$. I am assuming this problem to be 1-dimensional.
If we want to do this numerically, we cannot take infinitesimally small time steps $dt$, so we must choose some (small) finite step size $\Delta t$, at which we will want to evaluate the position.
From the equation you gave, we can derive an expression for $a(t)$ by simply dividing by $m(t)$. Now we can start our numerical calculation. Let's denote the individual timesteps with an index $k$, so the times at which we evaluate the variables will be at $k \cdot \Delta t$.
At $t=0$, we already know acceleration, velocity, and position. They are $a(0) = \frac{T(0) - m(0)g -kv(0)^2}{m(0)}$, $v(0)=v_0$, and $x(0) = x_0$. To get $x(\Delta t)$, we use the approximation $x(\Delta t) \approx x(0) + \Delta t \cdot v(0)$. The same goes for the velocity, $v(\Delta t) = v(0) + a(0) \cdot \Delta t$. Now that we know $a(\Delta t)$, $v(\Delta t)$, and $x(\Delta t)$, we can repeat this whole process to get $x(2\Delta t) \approx x(\Delta t) + v(\Delta t) \cdot \Delta t$ and $v(2\Delta t) \approx v(\Delta t) + a(\Delta t)\cdot \Delta t$, and so on, for any $k\Delta t$.
This is just one possible approximation, but in my opinion the one that's the easiest to understand. Others formulas try to improve numerical accuracy by including more terms or shifting some times slightly, but that's a bit outside the scope of this answer.
A: Yes, you will need a discretization of time $t_1, t_2, ... , t_N$. Then:
$$ T(t_1) - m(t_1) g = m(t_1) \, a(t_1)$$
(I assumed that $v(t_1) = 0$) and you solve for $a$:
$$ a(t_1) = \frac{T(t_1)}{m(t_1)}-g $$
Now you can compute $v$ for the next instant:
$$v(t_2) = a(t_1) \, (t_2-t_1)$$
Then you compute the next acceleration $a(t_2)$ then $v(t_2)$, $a(t_3)$ and so on...
