## Calculate distance - accleration, time, distance

Hi guys,

Sorry I am not into physics that much, basically I am a software developer..., my question might be silly., but, I want to calculate distance between two points. The situation here is - if an object is moved from say point x to point y in t amount of time with an acceleration which is not constant, can we calculate the distance between those points?

We dont know what are the positions of x and y. All we know is how much time did they take to move the object from x to y and acceleration at every second.

Thanks,
aspr

 PhysOrg.com science news on PhysOrg.com >> 'Whodunnit' of Irish potato famine solved>> The mammoth's lament: Study shows how cosmic impact sparked devastating climate change>> Curiosity Mars rover drills second rock target
 As long as the initial velocity is zero (or otherwise known), it's no problem. How's your calculus? Acceleration is the derivative of velocity, which itself is the derivative of displacement (i.e. position). $$a \equiv \frac{dv}{dt} \hspace{1in} v \equiv \frac{dx}{dt}$$ To find a change in displacement (x), one must integrate (reverse the derivative) of velocity---which may require first integrating the acceleration. Numerically, there are lots of different methods to perform integrations. The simplest method, is Euler's method (pronounced Oil-er). To find the velocity at some time 2', given the velocity at 1' you do: $$v_2 = v_1 + a_{1,2}\times \Delta t$$ Where delta t is the time interval, and $$a_{1,2}$$ is the acceleration between 1 and 2.
 Thanks for the reply zhermes. Yes, I think initial velocity is zero because we are moving an object from still position (point x). After moving some distance it stops at point y. I was good at calculus when I was in high school., it has been 6 years since then and now I am very bad at it. I am sure if I go and check out some tutorials or notes I think i can get my calculus back. I did search the web and I found out this: Please correct me if I am wrong v = v$$_0$$ + at; (Is 'a' here average acceleration? because it might be different at start, in the middle and at end.) v = at (since v$$_0$$ = 0); v = dx/dt; at = dx/dt; dx = at * dt??? Is this how i need to approach? if so what should I do from there?

## Calculate distance - accleration, time, distance

What you have is right, but at the same time, not quite. In your question, you said that the acceleration is changing. The equation that you posted, however, can only, sadly, be used for constant acceleration. If you do some extra work, tinker with it and whatnot, you might be able to get it right, but otherwise, I'd go for a different approach.

As Zhermes has so kindly explained, the acceleration is simply the slope of the graph of the velocity, and velocity is simply the slope of the graph of position. Yes, I'm starting at the basics for Calc. here, but I'm not sure how much you remember. Finding the slope of an equation with respect to x is done by simply taking the derivative of the equation. What you need to do is the opposite.

Starting with an equation for acceleration (which I sincerely hope that you have, rather than a set of numbers. If the latter is the case, I'll have to fix this up a bit.), you simply take the integral twice. If you'd post the equation for acceleration, as well as any questions you have, I'd be more than willing to help you as much as I can.

 Quote by Lame One Starting with an equation for acceleration (which I sincerely hope that you have, rather than a set of numbers. If the latter is the case, I'll have to fix this up a bit.), you simply take the integral twice.
I was assuming this was an iPhone's accelerometer, or something like that. Please clarify.

 Hey zhermes, you got me right., I was thinking of developing an application to build my portfolio. I want to develop an application which can calculate height of an object taking help of the accelerometer in iPhone, something like a pedometer but the person wont move he just moves his phone. Sorry I should have said this before.. but yes thats what I am trying to develop and.. I have to get my physics right. So now do you understand the question clearly or did I make a mess? Thanks, aspr
 Okay, gotcha! That's a really awesome idea---I've always wanted to try using the accelerometer data in iPhone apps. Lets make sure the concepts are clear first, consider a simper situation. You have a known constant velocity v' (no acceleration), and you want to find the displacement. Velocity is just the change in displacement over the change in time $$v = d/t$$ thus to find the distance, you multiple your velocity by your time interval: $$d = v \Delta t$$. If your velocity is changing, this doesn't work. If your velocity was ALMOST constant, it would be pretty accurate though.... thus, lets use time intervals small enough that the velocity can be TREATED as constant. Thus the change in distance for at some particular moment in time i,' will be: $$\Delta d_i = v_i \Delta t$$ where I'm assuming that the time interval is the same at every point in time (i.e. the phone is sampling the velocity [or acceleration or whatever] ever $$\Delta t$$ period). Thus, if the distance we've gone so far is $$x_i$$, and we want to find the distance at the next instant in time, $$x_{i+1} = x_i + \Delta x$$, we simply do: $$x_{i+1} = x_i + v_i \Delta t$$. No problem. Now in your case, the velocity isn't constant, so we have to do the exact same thing with the velocity first, then apply it to the displacement: $$v_{i+1} = v_i + a_i \Delta t$$ and combine that with the above. Okay, end result for your application, using Euler's method (which I have been describing): your code might look something like this (note: i don't actually know what any of the iPhone accelerometer objects or methods are called): Code: while( .... ) { deltaT = [accelerometer getSamplingInterval]; accel = [accelerometer getAcceleration]; vel += accel*deltaT; //integrate velocity dist += vel*deltaT; //use new velocity to integrate distance } There may not be any method to get the sampling interval (or it may vary), thus you would have to compute it manually like.... Code: while( .... ) { timeOld = timeNew; //store previous time timeNew = [clock getTime]; //get new time deltaT = timeNew - timeOld; /* code from above */ } If the changes in accerleration are relatively small, and the sampling rate is relatively fast---this will work well. Otherwise, you'll need a better integration method (i.e. fourth order runge-kutta would probably be your best bet). But you should start with Euler's method. Let me know if anything is unclear.
 Thanks zhermes. In iPhone we can set an timer and call the getAcceleration method so we can decide what deltaT should be. I also came to know that the iPhone accelerometer is not that good and it has lot of spikes. I havnt started this app yet., but I will work on this and update you. It might take sometime for me to understand this and I am moving to a new apt so it might take more. I will try it out and surely update you on this. Thank you so much for the help.....
 Interesting... cool. Happy to help asprsai---I'd really like to hear how it goes!

 Tags accleration, distance, time