Hacker News new | ask | show | jobs
by roelschroeven 1153 days ago
Isn't it the case that other numerical integration methods only work if you have a f(x) that you can evaluate for any x you want (albeit possible costly)?

It seems to me that in many practical applications, the only thing you have to work with it is samples at discrete moments in time. It certainly seems to be the case here: "I would measure car's speed at every instant and produce an average of those measurements." We only know f(t_0), f(t_1), f(t_2), ... (and if we're lucky t_1-t_0 = t_2-t_1 = t_3-t_2 and so on); we have no way to compute things like f((t_0 + t_1)/2). In that case, how can we improve our calculation?

1 comments

Even if you're limited to uniform sampling, something as simple as the trapezoid rule will give you quadratic convergence instead of linear for the naive Sum(f(t_i) * delta). In other words, error proportional to 1/n^2, instead of 1/n, where n is the number of samples, which is going to be a huge difference. There are many methods depending on the constraints of your problem - your ability to choose sampling intervals, knowledge of the bounds of your function or its derivatives, etc. The PSA is to study these things, instead of just writing the first thing that seems familiar from a long-ago calculus class.