# Distance given two velocities

I have a home trainer that is connected to an application that I am writing which needs to calculate a distance traveled given the speeds that the trainer is sending.

As such, every second, the trainer sends the instantaneous speed of the rider.

Example:

At Second 0: 10 km/h At Second 1: 15 km/h At Second 2: 12 km/h

..

Again, all that I receive are the speeds.

Each second, I need to calculate the total distance traveled.

Example: At second 1, I should know how far the rider has traveled (knowing the speeds from Second 0 and Second 1). At second 2, again, I would need to know how far the rider has traveled (knowing the speed at Second 1 and at Second 2) and so on.

What would be the correct way to at least approximate it?

• Just add up the distance moved every second. Jan 1, 2022 at 1:04
• If your familiar with numerical integration, all those methods apply based on your assumptions for the velocity between the intervals of announcement. Jan 1, 2022 at 2:23
• \begin{aligned}V_{i}=a_{i}t+b_{i}\\ X_{i}=\dfrac{a_{i}}{2}t^{2}+b_{i}t\\ t=1\\ X=\sum X_{i}\end{aligned}
– Eli
Jan 1, 2022 at 8:43
• Thank you! Is it correct to assume that a at index i is (v at index i) - (v at index (i-1)) as t is always 1 in my sample data points that I receive? Basically, a is the slope between the data points. Is this correct? Thank you. Jan 1, 2022 at 15:53

Thus the average speed between time $$t=i$$ and $$t=i+1$$ is $$\dfrac{v_{\rm i}+v_{\rm i+1}}{2}$$ and so the distance travelled in this time interval is $$\dfrac{v_{\rm i}+v_{\rm i+1}}{2}\times ((i+1)-i) = \dfrac{v_{\rm i}+v_{\rm i+1}}{2}$$