# Equation that integrates previous y-value.

I am making a game that has some sort of physics equations, although heavily modified to make it work better. I am trying to find the maximum velocity of a ship according to these rules/steps:

thrust = ((p*r)^0.5)*10

-where r is a constant (0.04) and p is the power (3.33x10^5 in this case)

friction = f*v*a

-where f is another constant (500), v is the velocity, and a is yet another constant (1.5 in this case)

force = t-friction
acceleration = force/mass (mass = 1403.14)
velocity += acceleration

Ok, so there are several steps involved to find the velocity, but I am trying to make an equation that can show the velocity at any point in time, assuming you are accelerating the whole time. This equation would also give me the maximum velocity.

The problem I am having is that the equation would involve the previous y value, and I don't know how to put that into an equation.

Somthing like y = y_previous + (107.457 - (750 * y_previous) / mass)

Thanks for any help.

Simon Bridge
Homework Helper
Where the change in y depends on the previous value of y, the equivalent continuous equations is:
$$\frac{dy}{dt}=ky$$ ... where k is a constant.

The solution is an exponential.

I have done a bit of research, and this appears to be a differential equation, of which I have no understanding of, and staring at the weird equations doesn't seem to help...

The dy/dt bit that you have there, how can I apply to my equation? I get what it means, that the change in y with respect to the change in time is equal to the y value multiplied by a constant, yet I don't know how to use that.

Simon Bridge
Homework Helper
For a computer $$\frac{dy}{dt}\approx \frac{\Delta y}{\Delta t}$$ where ##\Delta t## is your time-step.

##v_{n+1}=v_n+\Delta v##

Putting your equations together: $$\Delta v = \frac{1}{m}\left( t-fav_n \right) = c+kv$$... where c=t/m and k=fa/m are constants.

http://mathinsight.org/from_discrete_to_continuous_dynamical_systems

Is it c + kv or c - kv? Because c + kv would mean the friction adds to the acceleration.

As for the link, I can't view the videos at the moment, my internet is really slow right now.

So with the equation you have there, where do you go from there? How do you put that into a graph, because it is still pretty much in the form of v = vn-1+Δv?

Simon Bridge
Homework Helper
from what I put - yeah. cut and paste error :)
off the first line, k=-fa/m but it is probably clearer to make k positive for fa positive.
Thus c-kv.

Trying to find a tutorial page that does not use video:

I'd write $$\frac{dv}{dt} = c-kv$$ ... and solve the differential equation.

$$v(t) = \frac{c}{k}+v_0e^{-kt}$$ ... ##v_0=v(t=0)##.

Plot that and you see it tends towards the value c/k as time gets very big. So that is your top speed.

You need to learn how to do this - getting other people to do it usually costs money.

Ok thanks for your help. When you plot that, do you mean that that is the equation I can use for the graph, or that I have to find each individual value by plugging it into the formula? In this case, would v0 = 0, because it starts from rest? Then that would make the equation just v(t) = c/k.

Simon Bridge
Homework Helper
There's something missing isn't there?
... as long as t>fav, which is the case for v=0, there should be motion
... I think I put the brackets in the wrong place.
Good thing I'm not charging you :)

[edit:]Checked the math...

The actual equation should have been:

$$v(t)=\frac{c}{k}\big(1-e^{-kt}\big)$$

The discrete form gives $$v_n = \frac{c}{k}\big(1-e^{-nk\Delta t}\big):n=0,1,2,\cdots$$ ... for constant time interval Δt.

By "plot that" I just mean make a graph of the equation.

Aside:
since you only have acceleration as long as (t-fav)>0, that means that when v=t/fa, the acceleration stops.
therefore v=t/fa is the final speed.

from the continuous equation:
c=t/m, and k=fa/m so c/k = t/fa is the final speed ... in agreement with your model.

Last edited:
• 1 person
Thankyou so much, this is just what I wanted. It might be a while before I get to the stage of understanding how to get to that point, but I'll learn eventually. I'll continue to research and I'll ask my teachers, but unfortunately they don't offer Specialist Maths at my school... Anyway, this is great. Thanks again.