Search code examples
pythonscipynumerical-methodsnumerical-integration

Better method to perform numerical integration on acceleration


I have a set of acceleration data points read from the sensor.

I also have the time at which the reading was taken.

How do I numerically integrate to find the instantaneous velocity?

I have tried the following which does give me the result but the I am wondering whether there is a better more accurate method.

v_1=v_0+a*dt

Where dt is calculated from the difference between the times at which the data was measured.

And by iterating the above I could find the instantaneous velocity.


Solution

  • If you only have a number of discrete data points, it is reasonable to assume that the acceleration changes linearly between the data points, i.e.,

    enter image description here

    When integrating this function, the midpoint rule is completely accurate. (Midpoint is typically better than trapezoidal btw.)

    You can get more fancy assuming that the acceleration is continuously differentiable in which case you'd have to construct a quadratic polynomial in each intersection and integrating that, resulting in Simpson's rule.