4
$\begingroup$

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!

$\endgroup$
  • $\begingroup$ Can you give the physical context ? $\endgroup$ – Tony Piccolo Dec 13 '13 at 8:49
  • $\begingroup$ How do you mean? Like a physical analog? Since this if for a game I'm afraid there really isn't one; the best I can describe it as is in the question: an object moving across a line over a period of time where the object's velocity depends on its position on the line. $\endgroup$ – Roland Dec 13 '13 at 9:00
  • $\begingroup$ @Roland. Are you sure that the first thing to do would to be to look at the velocity. I have the feeling that the velocity must be written as an ordinary differential equation with boundary conditions. $\endgroup$ – Claude Leibovici Dec 13 '13 at 9:12
  • $\begingroup$ @ClaudeLeibovici - I'm note sure at all. I started with velocity since it was the only thing I could think of that I could fully define, and integrating seemed like the correct solution. Since I'm barely starting calculus could you elaborate on what "an ordinary differential equation with boundary conditions" might mean in my context? $\endgroup$ – Roland Dec 13 '13 at 9:18
3
$\begingroup$

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$$

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you for the answer, I'll start looking into differential equations but I've got a doubt and a few questions if you wouldn't mind. If its too complicated/long to post here then let me know; but could you explain to me what it is you are doing in the supplied context? I'm trying to find a function for position given time that uses my formula for velocity which in turn is calculated from the position (as written), I don't see how V can simply be rewritten or what the coefficients a and b signify in my context. Sorry if I just don't get it. $\endgroup$ – Roland Dec 13 '13 at 9:53
  • $\begingroup$ @Roland in your case $a=v_i$ and $b=\frac{\Delta V}{L}$. Note that we can rewrite $V$ as $\frac{dx}{dt}$ because the definition of velocity is the change in position with respect to time i.e. $\frac{dx}{dt}$. You can thus differentiate $x$ to see that the solution does indeed satisfy your conditions. $\endgroup$ – E.O. Dec 13 '13 at 10:00
  • $\begingroup$ Thanks for the edit, it helps to connect things but reveals a problem that I can't resolve. If the velocities at the beginning and end of the line are equal, the answer should resolve to a simple $x = vt$, but with your final equation I'm going to get $\Delta v = 0$ and those divisions will be undefined. Can you account for this? $\endgroup$ – Roland Dec 13 '13 at 10:24
  • $\begingroup$ @Roland indeed, it seems like I forgot a solution, I will add it now $\endgroup$ – E.O. Dec 13 '13 at 12:35
  • $\begingroup$ After having run a few tests - Wow. That's just beautiful. A quick followup question if I may: if the object crosses a certain position I need to find at what point in time the object did so, I should be able to solve your equation for $t$ somehow and expect that to be it, correct? Or is there a simpler way? (should this be a separate question?) $\endgroup$ – Roland Dec 13 '13 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.