Extrapolating pos., vel. given initial pos., vel. and constant acc.

In summary, the conversation discusses the process of determining the position and velocity of an object at any point in time, assuming a constant acceleration. The use of a Verlet integrator and a step-by-step method is suggested, as well as the option of using closed form equations for velocity and acceleration. The difference between Euler and trapezoidal step processes is also mentioned. Finally, the conversation ends with the discussion of the exact solution for constant acceleration and possible limitations of using a stepwise approach.
  • #1
Blixt
11
0
Hi there!

I'm working (programming) on a little project where I want to be able to get the position of an object at any point in time assuming its acceleration doesn't change. The object has an initial position and velocity.

It's very easy to extrapolate the position after x time given a constant velocity, but now the velocity will be changing over time as well, which is where I'm having problems. Would anyone be so kind and point me in the right direction? =)

If my question wasn't clear, here's an example that describes it more practically: I have a ship in space (far out, practically unaffected by gravity) and it's floating in one direction and pointing in another. Now I start the forward thrusters which accelerate the ship constantly. From this point on, I want to be able to get the position and velocity of the ship at any time forward.

Also, does this ship ever reach a maximum speed (assuming its thrusters do not exert any force stronger than what we have today)? Or will it slowly creep up in speed until it is disintegrated (assuming the ship has unlimited fuel and a constant mass)? The second case seems unlikely to me, but I've never had a physics class so what do I know? =)

If the first case is true, how do I implement this into the formula (if possible)?
 
Physics news on Phys.org
  • #3
Yeah, I've implemented Verlet into my projects many times (see http://blixt.org/js [Broken] for a web browser demonstration =)

The problem I'm describing is very easy to solve with any step-by-step solution:

step:
velocity = velocity + acceleration
position = position + velocity
repeat step

I need a solution where I can say, "I knew the position and velocity at time x, now I need to know the position and velocity at time (x + 1234 milliseconds)" which is hard to solve efficiently (and accurately) with step-by-step methods.
 
Last edited by a moderator:
  • #4
If you asking for a closed form solution given a constant acceleration then that is simple calculus.

[tex] a(t)=a[/tex]
[tex] v(t)=\int_0^t a(t') dt' = at + v_0[/tex]
[tex] x(t)=\int_0^t v(t') dt' = \frac{1}{2}at^2+v_0t+x_0[/tex]

Since your velocity is time dependent then you will either need to find a closed form equation for the velocity or acceleration and apply the appropriate integrations. It appears that you intend constant acceleration so then the above equations should be enough.
 
  • #5
See, now you lost me a bit =) I quit school for work at the age of 15 and never got around to learning calculus. Being a web developer I've never come across the need for calculus, and therefore I quite frankly suck at it. So would you mind explaining the formulas in less LaTeX-ish forms? =)

This is how I interpret them, in my programming terms:

function getVelocity(initialVelocity, acceleration, time):
return initialVelocity + acceleration * time

function getPosition(initialPosition, initialVelocity, acceleration, time):
return 0.5 * acceleration * time * time + initialVelocity * time + initialPosition

Is that right?
 
  • #6
I made a test case to get a more visual look on the whole thing. It looks like this: http://blixt.org/js/extrapolate.html [Broken]

My step-by-step method appears to differ slightly from the formula. I'm not sure why, any ideas? The difference is too great to be floating point inaccuracy. I'm using the formulas I wrote in my previous post. (The velocities match, so the difference is in how I calculate the position step-by-step and what getPosition returns.)

Also, one thing I'd love to implement into the formula is the limit on the velocity vector (check the checkbox.) Is this possible at all?
 
Last edited by a moderator:
  • #7
Blixt said:
The problem I'm describing is very easy to solve with any step-by-step solution:
step:
velocity = velocity + acceleration
position = position + velocity
repeat step
The position part is the problem, you need average velocity to determine it:

step:
velocity_previous = velocity
velocity = velocity+acceleration
position = position + .5* (velocity_previous + velocity)
repeate step

This will result in an exact result, limited by the precision of numbers on your computer. Since acceleration is constant, there's no point in averaging new and previous accelerations. This step process is a form of numerical integration. The step process you showed above would be called "Euler", the step process I show where averaging is done, is called "trapezoidal".
 
Last edited:
  • #8
Blixt said:
I have a ship in space (far out, practically unaffected by gravity) and it's floating in one direction and pointing in another. Now I start the forward thrusters which accelerate the ship constantly. From this point on, I want to be able to get the position and velocity of the ship at any time forward.

You don't need calculus or numerical integration for this.

You can use the standard equations for motion with constant acceleration, but since the acceleration and initial velocity aren't in the same direction, you need to use the vector versions:

[tex]\vec v = {\vec v}_0 + \vec a t[/tex]

[tex]\vec r = {\vec r}_0 + {\vec v}_0 t + \frac{1}{2} \vec a t^2[/tex]

These simply represent similar pairs of equations for the x, y and z components of the motion:

[tex]v_x = v_{0x} + a_x t[/tex]

[tex]v_y = v_{0y} + a_y t[/tex]

[tex]v_z = v_{0z} + a_z t[/tex]

[tex]x = x_0 + v_{0x} t + \frac{1}{2} a_x t^2[/tex]

[tex]y = y_0 + v_{0y} t + \frac{1}{2} a_y t^2[/tex]

[tex]z = z_0 + v_{0z} t + \frac{1}{2} a_z t^2[/tex]

You have to specify the initial position of the ship ([itex]x_0, y_0, z_0[/itex]), the initial velocity components ([itex]v_{0x}, v_{0y}, v_{0z}[/itex]) and the acceleration components ([itex]a_x, a_y, a_z[/itex]). Then you can use the equations above to calculate the position (x, y, z) and velocity components ([itex]v_x, v_y, v_z[/itex]) at any time t.

This is the exact solution for constant acceleration. A stepwise procedure which calculates each point based on the one preceding it (instead of always basing it on the initial point) will usually give you only an approximation. This can be because of one or both of (1) accumulated roundoff error (2) intrinsic limitations in whatever step-by-step approximation you're using, which of course depend on the particular method.
 
Last edited:
  • #9
Like Jeff has stated, are you using an Euler or Verlet integrator? If you are, reduce the time step and see how they match up. The Verlet integrator should give you an error on the order of the square of the time step, the Euler integrator is on the order of the time step. So reducing the time step should help improve your global positioning error.

EDIT: As for limiting the velocity, that would just be a programming problem. Given an acceleration solve the amount of time it will take for your velocity to reach the limit. Then, use the standard equations for any time t less than the limit, above the limit keep the velocity constant. jtbell's post is usefull because up to now I have neglected discussing anything other than a one-dimensional problem. I would note though that for vectors,

[tex]v = \sqrt{v_x^2+v_y^2+v_z^2}[/tex]

If you want to find the magnitude, you need to use the above formula like I have to find the total speed.
 
  • #10
Born2bwire said:
Like Jeff has stated, are you using an Euler or ... integrator? ... error ...
For constant acceleration the trapezoidal integrator algorithm is exact (since velocity changes linearly, then a linear approximation can be exact), but the repeated additions will involve floating point truncation errors. If the step size is the full time period you end up with the standard equation for distance versus time and acceleration.

t = Δt = t1 - t0

v1 = v0 + a t

x1 = x0 + 1/2 (v0 + v1) t
x1 = x0 + 1/2 (v0 + (v0 + a t)) t
x1 = x0 + 1/2 (2 v0 + a t) t
x1 = x0 + v0 t + 1/2 a t2
 
Last edited:
  • #11
Born2bwire said:
EDIT: As for limiting the velocity, that would just be a programming problem. Given an acceleration solve the amount of time it will take for your velocity to reach the limit. Then, use the standard equations for any time t less than the limit, above the limit keep the velocity constant.

Hmmm... What if the max velocity magnitude is 100, and the initial velocity is (100, 0), and the acceleration (0, -100)? It'll be at max velocity already at t=0.0, but I want the path to curve until the velocity eventually (at infinity, I guess, if dealing with exact numbers) reaches (0, -100) unless the acceleration changes. Have a look at how it behaves in my example.

The way I do it in my step-by-step solution is that I normalize the current velocity vector if its magnitude/length/norm is above the limit and then create a new vector that's been weighed by the acceleration, slowly turning in the direction of the acceleration while maintaining its magnitude.
 
  • #12
Blixt said:
Also, does this ship ever reach a maximum speed?
By definition, no, you've stated that acceleration is constant, so there is no maximum velocity. (constant acceleration would conflict with relativistic properties where the speed of light is the limit). There is a minimum velocity, zero, at the point when the ship changes direction.

You can use the step by step method with averaged velocity as I've shown, or you can just use the formulas given above (the formulas wouldn't be affected by truncation).
 
  • #13
Jeff Reid said:
By definition, no, you've stated that acceleration is constant, so there is no maximum velocity. (constant acceleration would conflict with relativistic properties where the speed of light is the limit). There is a minimum velocity, zero, at the point when the ship changes direction.

You can use the step by step method with averaged velocity as I've shown, or you can just use the formulas given above (the formulas wouldn't be affected by truncation).

I see. What if this was a "real" situation where we had a spaceship with some kind of propulsion method that could output a force for a very long period of time. Would the acceleration of the ship stay relatively constant? Just curious =)

In most space movies, spaceships going on "full thrust" appear to reach some kind of max speed (I'm basing this on that a spaceship can follow an already accelerating [equivalent] spaceship, even when starting from a low velocity.)

Oh, and I updated my step-by-step code to use the trapezoidal method, and now it shows the same results as the formula =) I'm still pretty stuck on how to give the formula the "norm limit" functionality that my step-by-step method has (See my previous post.)
 
  • #14
Blixt said:
What if this was a "real" situation where we had a spaceship with some kind of propulsion method that could output a force for a very long period of time. Would the acceleration of the ship stay relatively constant?
If you ignore relativistic effect, then there is no max speed. If relativistic effects apply, then any object with mass as observed from the rocket would always travel below the speed of light.

In most space movies, spaceships going on "full thrust" appear to reach some kind of max speed
This is not realistic.
 
  • #15
Blixt said:
I see. What if this was a "real" situation where we had a spaceship with some kind of propulsion method that could output a force for a very long period of time. Would the acceleration of the ship stay relatively constant? Just curious =)

Actually, the acceleration would not be constant because in a real situation the mass of the rocket is changing with time. Force is the time derivative of the momentum, mass times velocity. Normally, most systems have constant mass and so F=ma. However, in a rocket, the mass of the rocket decreases as the fuel is spent, and so you have to take that into account. Thus, F=ma+v*dm/dt, so for a constant force we would have a changing acceleration.
 
  • #16
Born2bwire said:
Actually, the acceleration would not be constant because in a real situation the mass of the rocket is changing with time. Force is the time derivative of the momentum, mass times velocity. Normally, most systems have constant mass and so F=ma. However, in a rocket, the mass of the rocket decreases as the fuel is spent, and so you have to take that into account. Thus, F=ma+v*dm/dt, so for a constant force we would have a changing acceleration.

Yup, I saw that one coming (which is why I defined my imaginary ship in my first post to have a constant mass =)

Anyways, to get back to the question in this thread: Is there a way to make the same formula we have now to calculate velocity and position for any time, but with the addition of terminal velocity? I hope the term "terminal velocity" doesn't confuse, because in this case the force moving the object isn't gravity, but an acceleration in any direction. And let's say the restraining force causing the terminal velocity is some unseen matter (because in the application I'm programming, it's not feasible to have the objects approach the speed of light =)

Basically, I'm looking for the equivalent of constantly adding the acceleration to the velocity, followed by forcing the magnitude of the velocity to be a certain amount, but (and here's the really tricky part) only if the velocity exceeds a certain limit. The effect will be that even once the velocity hits max, the direction of the velocity will still be changing (it's being influenced by the acceleration.)

I understand this is a hard nut to crack, and I'll take any solution even if it's not exactly what I described above. The only requirements are that it looks good on the screen (the velocity starting in one direction, then slowly changing to be in the direction of the acceleration, constantly accelerating as well, but not beyond the max velocity) and that it's deterministic given the initial parameters (position, velocity, acceleration.)
 
  • #17
In order to limit the velocity, you'd need to choose from a variety of functions that would have such a limit. For example, y = 100 - 1 / xn is a family of curves with 100 as the limit. A similar family of equations would be y = 100 - 1 / ax.
 
  • #18
Blixt said:
Hmmm... What if the max velocity magnitude is 100, and the initial velocity is (100, 0), and the acceleration (0, -100)? It'll be at max velocity already at t=0.0, but I want the path to curve until the velocity eventually (at infinity, I guess, if dealing with exact numbers) reaches (0, -100) unless the acceleration changes. Have a look at how it behaves in my example.

The way I do it in my step-by-step solution is that I normalize the current velocity vector if its magnitude/length/norm is above the limit and then create a new vector that's been weighed by the acceleration, slowly turning in the direction of the acceleration while maintaining its magnitude.

That will not be a problem if you implement it as I suggested. You can just use algebra to solve for the time when your velocity will meet your desired limit. Then, you can just use a conditional to implement the ideal equations for any time less than this limit and then set the velocity to the limit velocity and acceleration to zero for your equations for any times greater or equal to the limit. But treat the time limit point as the starting point for new equations. That is, just use (t-t_0) as your time and set your initial v and x as the points at the time limit.

If you are looking to cap the speed but still apply an acceleration, then I do not know off-hand how you will get this easily, in closed-form, a priori.
 
Last edited:
  • #19
Born2bwire said:
That will not be a problem if you implement it as I suggested. You can just use algebra to solve for the time when your velocity will meet your desired limit. Then, you can just use a conditional to implement the ideal equations for any time less than this limit and then set the velocity to the limit velocity and acceleration to zero for your equations for any times greater or equal to the limit.

Ah, but consider it again. Velocity is (100, 0) and acceleration is (0, -100). Max velocity is 100. Now I calculate the time the velocity reaches 100, which gives me t=0. So now I use the first formula from time 0 to 0 (i.e., it won't affect the end result), then I apply the second formula for the remaining time. This will result in the object moving in a straight line along the x-axis.

What I want is for the object to move along a curve which is slowly changing its direction just like it does without this limit, but at any point in time the magnitude of the velocity must not exceed 100. After a certain amount of time, the object will be moving mostly along the y-axis.

Edit:
Ah, I see now in your last paragraph that you mention what I'm after. I've been looking all over the web for something similar and haven't found it. I've even tried curve fitting to make approximations of the curve, but I haven't gotten any good results from that either. I'm considering just using steps after all and only allowing times on which a step occur. Since I will be using cubic splines to visualize the positions, the inaccuracies this will cause will be hidden from the client, but unfortunately this will increase the CPU usage quite a bit for the server.
 
  • #20
Velocity and speed are different. If you want to stop accelerating upon reaching a desired velocity, it would be fine (provided that the acceleration can achieve your desired velocity). Capping at a specified speed but allowing for acceleration is a different problem. If you said the initial velocity was (100,0) and you wanted to stop accelerating at V = (-100,0) with an acceleration of (-100,0), then that can be solved as I stated above. The time would be 2. If you had an acceleration of (0,-100), then you could not achieve the desired velocity and you would not be able to solve it. This is the difference between limiting the velocity and limiting the speed.
 
  • #21
Born2bwire said:
Velocity and speed are different. If you want to stop accelerating upon reaching a desired velocity, it would be fine (provided that the acceleration can achieve your desired velocity). Capping at a specified speed but allowing for acceleration is a different problem. If you said the initial velocity was (100,0) and you wanted to stop accelerating at V = (-100,0) with an acceleration of (-100,0), then that can be solved as I stated above. The time would be 2. If you had an acceleration of (0,-100), then you could not achieve the desired velocity and you would not be able to solve it. This is the difference between limiting the velocity and limiting the speed.

Ah yeah I didn't think about that. With "magnitude of velocity", what I really meant was "speed". So the scalar change of position over 1 unit of time would not be allowed to exceed 100. But these kind of special rules don't belong in maths I guess, so I'll just use a step-by-step method and run it as many times as is needed to get the position at a certain time.

Edit: Another uneducated idea: What if I calculate the curve up to the point where the speed exceeds 100 per 1 unit of time, then after that I calculate the same curve, but with a "counter-acting weighing" (I have no idea what a mathematical term would be) that makes the curve more compressed as time increases, to counter the effect of the ever-increasing velocity? Maybe I'm just rambling...
 
Last edited:
  • #22
Blixt said:
Ah yeah I didn't think about that. With "magnitude of velocity", what I really meant was "speed". So the scalar change of position over 1 unit of time would not be allowed to exceed 100. But these kind of special rules don't belong in maths I guess, so I'll just use a step-by-step method and run it as many times as is needed to get the position at a certain time.

Edit: Another uneducated idea: What if I calculate the curve up to the point where the speed exceeds 100 per 1 unit of time, then after that I calculate the same curve, but with a "counter-acting weighing" (I have no idea what a mathematical term would be) that makes the curve more compressed as time increases, to counter the effect of the ever-increasing velocity? Maybe I'm just rambling...

The problem is that as soon as you start renormalizing the velocity due to a speed cap, then your acceleration is no longer constant and you can't use the simple algebraic equations that I gave you ealier. Now, if we knew the exact acceleration that you would need ahead of time, then we could calculate the appropriate integrals for you to use and then you could find the position and velocity at any point in time. But this would change as you changed the initial conditions and speed cap. So if you are going to have a time dependent acceleration that is undetermined at the beginning of the program, then you will need to use a time-stepping integrator. Off the top of my head, the best you can do is use the exact equations for a constant acceleration up to the point that you need to introduce the speed cap. Then use an appropriate integrator.
 
  • #23
Born2bwire said:
The problem is that as soon as you start renormalizing the velocity due to a speed cap, then your acceleration is no longer constant and you can't use the simple algebraic equations that I gave you ealier. Now, if we knew the exact acceleration that you would need ahead of time, then we could calculate the appropriate integrals for you to use and then you could find the position and velocity at any point in time. But this would change as you changed the initial conditions and speed cap. So if you are going to have a time dependent acceleration that is undetermined at the beginning of the program, then you will need to use a time-stepping integrator. Off the top of my head, the best you can do is use the exact equations for a constant acceleration up to the point that you need to introduce the speed cap. Then use an appropriate integrator.

Ah, I see. I'll do that then! Thanks so much for putting up with me, all of you guys! =)
 
  • #24
Born2bwire said:
The problem is that as soon as you start renormalizing the velocity due to a speed cap, then your acceleration is no longer constant and you can't use the simple algebraic equations that I gave you ealier. Now, if we knew the exact acceleration that you would need ahead of time, then we could calculate the appropriate integrals for you to use and then you could find the position and velocity at any point in time. But this would change as you changed the initial conditions and speed cap. So if you are going to have a time dependent acceleration that is undetermined at the beginning of the program, then you will need to use a time-stepping integrator. Off the top of my head, the best you can do is use the exact equations for a constant acceleration up to the point that you need to introduce the speed cap. Then use an appropriate integrator.

Hm, just a question out of curiosity... How would that work with the "calculating of appropriate integrals"? Sounds like we're entering a territory completely alien to me, but I'm still curious...

It wouldn't work in this case though, I guess, since the acceleration vector is only constant in magnitude; its direction will be changing.
 

1. What does it mean to extrapolate position, velocity, and constant acceleration given initial position and velocity?

Extrapolation is the process of estimating values beyond a set of known data points. In the context of position, velocity, and constant acceleration, it refers to predicting the future position and velocity of an object based on its starting position and velocity, as well as the rate at which its velocity is changing.

2. How is extrapolation different from interpolation?

Interpolation involves estimating values within a set of known data points, while extrapolation involves estimating values beyond the known data points.

3. What is the formula for extrapolating position, velocity, and constant acceleration?

The formula for extrapolating position, velocity, and constant acceleration is: x = x0 + v0t + 1/2at^2, where x is the final position, x0 is the initial position, v0 is the initial velocity, a is the constant acceleration, and t is the time interval.

4. Can extrapolation accurately predict the future position and velocity of an object?

Extrapolation can provide a rough estimate of the future position and velocity of an object, but it may not be entirely accurate. The accuracy of the extrapolation depends on the assumptions made about the object's motion and the precision of the initial data.

5. What are some real-world applications of extrapolating position, velocity, and constant acceleration?

Extrapolation is commonly used in fields such as physics, engineering, and economics to make predictions about future trends or values based on past data. For example, it can be used to predict the path of a projectile, the growth of a population, or the value of a stock over time.

Similar threads

  • Other Physics Topics
Replies
6
Views
865
  • Sci-Fi Writing and World Building
Replies
18
Views
1K
Replies
15
Views
711
  • Special and General Relativity
Replies
11
Views
938
  • Special and General Relativity
Replies
29
Views
1K
  • Introductory Physics Homework Help
Replies
3
Views
667
  • Introductory Physics Homework Help
Replies
11
Views
590
  • Classical Physics
Replies
4
Views
1K
  • Special and General Relativity
4
Replies
115
Views
5K
  • Other Physics Topics
Replies
23
Views
2K
Back
Top