Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

In all of the literature that I've found, numerical integration is used to approximate the value of the integral of some function over an interval. I'm trying to do something a little different:

I have a bunch of sampled values coming in at varying, small time steps. At each time step, I want to return the integral of the input for that time step.

So, for each time step, I simply add the new value multiplied by $\Delta t$ to a running total, and return the total for that time step.

This seems to produce the result that I want. However, is this the best way to do this? Without having the entire history of the input, is there a method of integrating that can reduce the error of the output for each time step?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

If you don't know anything about where the input comes from, you can't do better. If you have a model of the input, you can do better. If you think it is polynomial of degree $n$, you can interpolate the last $n+1$ readings and be there. If you think it is periodic you can do an FFT on your favorite span and get an answer. The quality of your answer is dependent on the quality of your model.

Integration is a low-pass filter. If the function was $1$ for a long time, the integral becomes large, so you need to say you are returning the integral since some time.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.