[Math] Am I correct? Distance when velocity depends on position

calculusclassical-mechanicsintegration

I hope I'm in the right place to be asking this: I'm looking for somebody that knows better than I who can verify whether or not I've done things correctly. In trying to implement a feature for a game I'm working on, I've come up to the following problem (I apologize if my notation/terms are off, I'm strictly amateur):

Suppose I have an object that is moving across a 1D line over a period of time where its position on the line determines its instantaneous velocity like so:

$$V(x) = v_i + { x \Delta v \over L}$$

Where $V$ is velocity as a function of the position, $L$ is the length of the line, $v_i$ is the velocity of the object at the beginning of the line (when $x = 0$) and $\Delta v$ is the difference between the velocity at the end of the line (when $x = L$) and the velocity at the beginning.

I want to figure out a function $X(t)$ to determine the position of the object given an amount of time using the above formula for velocity, which itself depends on the position. Is simply substituting $x = X(t)$ and attempting to integrate valid? (I've just started learning calculus so I'm not at all confident in what I'm doing)

$$V(X(t)) = v_i + { X(t) \Delta v \over L}$$

$$X(t) = \int(v_i + { X(t) \Delta v \over L})\,dt$$

Once I tried solving I simply got:

$$X(t) = {tv_iL \over L – t\Delta v}$$

Is this correct? I expected some terms to end up with exponents or something more complicated, but the numbers I've tested seem to be alright. It kind of seems to me like I've just multiplied velocity times time, but I thought velocity not being constant would make that incorrect. Or maybe I've just been staring at the screen too long?

Corrections and insights appreciated, and thanks for taking the time.


Followup:

I programmed some tests and obtained the following results

Given: Length = 120, vi = 100, vf = 50; starting at position 0 and moving for time 5

  • Approximation: 210.1165 @ dT = 0.0005 x timesteps = 10000
  • My Formula: 162.1622
  • E.O.'s Formula: 210.116524478485

And now I'm off to learn about differential equations!

Best Answer

The word you are probably looking for to solve this problem is differential equation. As it is currently written, the notation is slightly confusing and is probably what is tripping you up.

Let us first rewrite $V$ as $\displaystyle\frac{dx}{dt}$. For generality we will replace the coefficients with $a$ and $b$. Then your equation becomes $$\frac{dx}{dt}=a+bx$$ We can rearrange this to get $$\frac{1}{a/b+x}\frac{dx}{dt}=b$$ We then integrate both sides with respect to $t$ $$\begin{align*}\int\frac{1}{a/b+x}\frac{dx}{dt}dt&=\int b dt \\ \int\frac{1}{a/b+x}dx&=bt+c \\ \\ \log(a/b+x)&=bt+c \\\\ \frac ab+x&=e^{bt+c} \\ x&=Ae^{bt}-\frac ab \\\end{align*}$$ We want $x(0)=x_0$ so $$x_0=Ae^0-\frac ab\to A=x_0+\frac ab$$ Therefore your general equation is $$x=\left(x_0+\frac ab\right)e^{bt}-\frac ab$$ Edit: In your particular case the equation is $$x=\left(x_0+\frac{v_i L}{\Delta v}\right)e^{t\Delta v/L}-\frac{v_i L}{\Delta v}$$ Edit 2: As was pointed out in the comments, this is a solution for $\Delta v\ne0$. In the case that $\Delta v=0$ we get the following solution $$\begin{align*}\frac{dx}{dt}&=a \\ \int\frac{dx}{dt}dt&=\int adt \\ x&=ax+c \\ x&=ax+x_0\end{align*}$$ So your solution when $\Delta v=0$ is therefore $$x=v_it+x_0$$

Related Question