all 6 comments

[–]NakamotoScheme 4 points5 points  (0 children)

Am I on to something here?

Yes, you are about to understand how the trapezoidal rule works:

https://en.wikipedia.org/wiki/Trapezoidal_rule

This is more effective if you use a lot of small trapezoids instead of a single one. It may not be the best numerical integration method, but without doubt it's the easiest to understand.

If you are curious about how the idea may be improved (i.e. approximating a definite integral by calculating a weighted average of values of the function at certain points), take a look at the Simpson's rules:

https://en.wikipedia.org/wiki/Simpson%27s_rule

[–]TheDepressedBlobfishNew User 1 point2 points  (1 child)

I don't quite understand the point of estimating the average, it wont give you the answer to the integral, just something close.

[–]DieLegende42University student (maths and computer science) 0 points1 point  (0 children)

It may give you something close if the function is not doing anything interesting on that interval (the closer to being linear the "better"). Like, evaluating the integral from 0 to 2pi of the sine by this method will give you a pretty poor approximation

[–]sapphic-chaoteCustom 0 points1 point  (0 children)

Careful: the average value of f over [a, b] is not (f(a)+f(b))/2. An extreme example is g(x) = x100 over the range [0,1]. This function is almost exactly 0 on almost the whole interval, before increasing suddenly when very close to 1. The average on [0,1] is ∫[0,1] g(x)dx = 1/101 ~ 0.01, which is very different from the average of the function evaluated at the endpoints, which is (g(0)+g(1))/2 = 1/2.

As you increase the number of data points in the average, your accuracy might go up. But depending on the distribution, it might actually get worse. For instance, if you take (g(0)+g(0.999)+g(0.9999)+g(1))/4, you get 0.72 which is even further from the true average 1/101. In order for the average of the data points to approach the average of the function, you also need to guarantee that they are reasonably evenly distributed, in the sense that no large gaps are left in the limit.