Using calculus to convert between velocity and acceleration

AbigailRocketblast

New member
Joined
Oct 1, 2013
Messages
11
Hello,

It is years since I did calculus. I have a problem in which I need to convert velocity data to acceleration and acceleration data to velocity as part of a computer program.

The data is real world data that comes to my program at something like 40 samples per second. I have written some coe for both differentiation and integration, but am having difficulty testing what I have written is correct. If I get the following values of velocity, can you confirm that the calculated acceleration values are correct:

40sps --> 0.025

Velocity Acceleration
0.0 -
0.3 12 [(0.3-0.0) / 0.025]
0.2 - 4 [(0.2-0.3) / 0.025]
0.7 20 [(0.7-0.2) / 0.025]
1.2 20 [(1.2-0.7) / 0.025]
0.8 -16 ... etc ...
0.8 0
0.9 4
1.1 8
1.3 8


Thanks for your help

( the values looked cleaner in the editor - is it still understandable, though?)
 
Last edited:
Hello,

It is years since I did calculus. I have a problem in which I need to convert velocity data to acceleration and acceleration data to velocity as part of a computer program.

The data is real world data that comes to my program at something like 40 samples per second. I have written some coe for both differentiation and integration, but am having difficulty testing what I have written is correct. If I get the following values of velocity, can you confirm that the calculated acceleration values are correct:

40sps --> 0.025 s between samples

\(\displaystyle \begin{array}{rl}
\text{Velocity (ft/s)} & \text{Acceleration (ft/s^2)} \\
0.0 \\ & 12\;\; [(0.3-0.0)/0.025]\\
0.3 \\ & -4\;\; [(0.2-0.3)/0.025]\\
0.2 \\ & 20\;\; [(0.7-0.2)/0.025]\\
0.7 \\ & 20\;\; [(1.2-0.7)/0.025]\\
1.2 \\ & -16 \\
0.8 \\ & 0 \\
0.8 \\ & 4 \\
0.9 \\ & 8 \\
1.1 \\ & 8 \\
1.3 & \text{etc...} \end{array}\)

YES, the "first difference" gives you the average acceleration
between velocity readings. But this direct method is sensitive to statistical fluctuations in the determination of the velocity. You may need averaging somewhere downline.
 

YES, the "first difference" gives you the average acceleration
between velocity readings. But this direct method is sensitive to statistical fluctuations in the determination of the velocity. You may need averaging somewhere downline.

That's great, thanks.

And thanks for the comment on averaging.

I also need to do integration of acceleration to velocity. I figured the trapezium rule would be easy to use, but I can't seem to get it to work out.

With the base of the trapezium as a and the 2 sides are b and c, the area if 0.5*a*(b+c). So, based on the numbers I had before ...

0.0 -
0.3 12
0.2 -4 0.1 [0.5*0.025*(-4 + 12) = 0.1]
0.7 20 0.2 [0.5*0.025*(20 + -4) = 0.2]
1.2 20 0.5 [0.5*0.025*(20 + 20) = 0.1
0.8 -16 0.05
0.8 0 -0.2
0.9 4
1.1 8
1.3 8

This doesn't seem to be working out at all. What am I doing wrong here?

Thank you
 
Last edited:
Sampled Data

Getting Integrals, and derivatives of sampled data is often done by fitting a polynomial.
When calculating derivatives, the results are very sensitive to "noise" in the data, and over-sampling the number of points is useful.

All of these algorithms reduce to a weighted sum of the data.
Click here, to get a useful demonstration.
 
Getting Integrals, and derivatives of sampled data is often done by fitting a polynomial.

Thanks, Bob.

How can polynomials be used to convert from velocity to acceleration? Or vice-versa?

When the data coming in is more or less unpredictable.

Thanks,
 
Last edited:
Thanks, Bob.

How can polynomials be used to convert from velocity to acceleration? Or vice-versa?

When the data coming in is more or less unpredictable.

Thanks,

The idea would be to create a polynomial function that approximates your velocity data, for example. Then you can mathematically take the derivative and get an approximation for the acceleration. However, this assumes you want to find expected or predicted values of acceleration based on an existing set of velocity data. I would imagine that if you're dealing with live, real-world data you wouldn't be fitting anything. Instead you could either take the instantaneous acceleration (just the change in the last two velocity data points divided by time) or start a moving average (average of the last 40 instantaneous acceleration calcs, to get a 1-second moving average).

I'm quite sure there are other, more sophisticated ways to do this depending on what you ultimately need the data for. If it's just general information for planning it may not matter, but obviously if you are designing a control system of some sort you may need to account for very rapid changes in acceleration that a moving average might mask, and becomes a more complex question that would require further research on the application itself.
 
Thank you Ted, as you say, and as I suspected, polynomials aren't suitable for our application. I have used polynomials before, I once used a 5th order polynimial to straighten the response of a nuclear radiation detector that was used to determine the thickness of materials manufactured in sheet form. So I understand that use.

As for my application, we already have filtering available in the software, so that isn't an issue.

What is, though is how I go about integratng a bunch of numbers by hand. Can anyone show me how I should be doing that?

Thanks
 
Thank you Ted, as you say, and as I suspected, polynomials aren't suitable for our application. I have used polynomials before, I once used a 5th order polynimial to straighten the response of a nuclear radiation detector that was used to determine the thickness of materials manufactured in sheet form. So I understand that use.

As for my application, we already have filtering available in the software, so that isn't an issue.

What is, though is how I go about integratng a bunch of numbers by hand. Can anyone show me how I should be doing that?

Thanks
A beginning text on numerical methods should have a chapter or two on numerical evaluation of integrals. My text (from almost fifty years ago) discusses the trapezoidal rule, Richardson's deferred method, Simpson's rule, and Gauss quadrature. I have not used those methods in decades so I do not want to give advice, but probably there is software available that lets you use such methods.
 
The data is real world data that comes to my program at something like 40 samples per second.
40sps --> 0.025

I hope that you will take time to look at the demo:
Click Here

I used the demo to get the following:


DEMONSTRATION: h=0.025
Let v0, be the most current velocity data point.
Let v1, v2, v3, and v4 be earlier data points.

A = the current acceleration based on cubic polynomial

A = (125*v0 -136*v1 -48*v2 +88*v3 -29*v4)/(84*0.025)
 
Last edited:
A beginning text on numerical methods should have a chapter or two on numerical evaluation of integrals. My text (from almost fifty years ago) discusses the trapezoidal rule, Richardson's deferred method, Simpson's rule, and Gauss quadrature. I have not used those methods in decades so I do not want to give advice, but probably there is software available that lets you use such methods.

Thanks, Jeff. Where can I get your text?

I am writing software to do this - so getting some other software to do it isn't the right way to go.
 
Last edited:
I hope that you will take time to look at the demo:
Click Here

I used the demo to get the following:


DEMONSTRATION: h=0.025
Let v0, be the most current velocity data point.
Let v1, v2, v3, and v4 be earlier data points.

A = the current acceleration based on cubic polynomial

A = (125*v0 -136*v1 -48*v2 +88*v3 -29*v4)/(84*0.025)

I will check out the demo - I'm not keep on installing unknown software, though.

Please can you explain in layman's terms why that converts from a to v. And where did the constants come from?

Do you have a similar polynomial for a to v?

Thanks,
 
Is this a really hard question?

Are my workings wrong in the example I gave? If so, in what way?

How should one do the integration of a stream of unpredictable, though evenly spaced in time, numbers?

Thank you
 
I hope that you will take time to look at the demo:
Click Here

I used the demo to get the following:


DEMONSTRATION: h=0.025
Let v0, be the most current velocity data point.
Let v1, v2, v3, and v4 be earlier data points.

A = the current acceleration based on cubic polynomial

A = (125*v0 -136*v1 -48*v2 +88*v3 -29*v4)/(84*0.025)

Well, I tried that polynomial with the data I used in my first post and the results are considerably different.

0.00
0.30
0.20
0.70
1.20
0.80-41.86
0.80-5.05
0.9024.10
1.105.86
1.308.05

I'm not sure where to go with this now.

Thanks
 
Top