I'm trying to write an acceleration function that takes drag into account in a very basic way. The basic function is:
$$a(v) = 5 - 0.1v$$
As velocity increases, acceleration decreases because of drag until acceleration is zero, and "terminal velocity" is reached. (I know this is a very barebones model of drag but it fits my purposes, for a game.)
My issue is I can't figure out how to get this as a function of time (in seconds). In the above equation units are in $m/s^2$.
As a function of time I get:
$$a(t) = 5-d(t)$$
where
$$d(t) = 0.1\int_0^t a(x) dx$$
The main problem is that I can't figure out how to find the integral in d(t), which represents the function for drag. By integrating acceleration I want to get velocity, but since acceleration is dependent on velocity in $a(t)$, I don't know how to proceed.
You have the equation $$\frac{dv}{dt} = 5 - 0.1v(t)$$ A simple rearrangement gives you: $$\frac{1}{5 - 0.1v(t)}\frac{dv}{dt} = 1$$ Integrate this with respect to $t$: \begin{align} \int\frac{1}{5-0.1v(t)}\frac{dv}{dt}\;dt=\int\;dt&\Longrightarrow -10\log(5-0.1v) = t + C_0 \\ &\Longrightarrow \log(5-0.1v) = -0.1t-0.1C_0 \\ &\Longrightarrow 5 - 0.1v = C_1e^{-0.1t} \\ &\Longrightarrow v = 50 + C_2e^{-0.1t} \end{align} where $C_2$ is an arbitrary constant. To obtain the value of the constant $C_2$, you simply set an initial condition for $v$, plug it in, and solve for $C_2$. For example, the initial condition $v(0) = 0$ yields: $$v(0) = 50+C_2 = 0\Longrightarrow v(t) = 50 - 50e^{-0.1t}$$ You can then substitute this into your equation for $a(t)$ to obtain: $$a(t) = 5-0.1(50-50e^{-0.1t})=5e^{-0.1t}$$