# Why don't terms in the summation expression for an integral (almost) cancel out?

If I think of an integral, $$\int_a^b f(x) dx$$ as roughly $$\sum f(x)\delta x$$ where $$\delta x$$ is very very small, then can't I write this sum as

$$f(x)x - f(x)(x-\delta x) + f(x-\delta x)(x-\delta x) +\dots -f(a)a$$

Then, since $$\delta x$$ is so small, assuming $$f(x)$$ is "smooth" in some sense, shouldn't $$f(x) \approx f(x-\delta x)$$ so $$f(x)(x-\delta x) \approx f(x-\delta x)(x-\delta x)$$

and then all terms would cancel out except for $$f(x)x$$ and $$f(a)a$$?

I.e. wouldn't this give $$\int_a^b f(x)dx \approx f(x) x - f(a)a$$?

Why does this not give a decent approximation?

For example, I think this is always exact for a constant function. I would then think it should be pretty good for any function that doesn't change too quickly at any point.

but what is "too quickly"

I thought it would also be pretty good for a linear function, but this is not the case...

• How did you get to that sum? Nov 7, 2018 at 6:06
• @inavda $\sum_{i-a}a^b f(a) \delta x$ is $f(a)\delta x + f(a+\delta x)\delta x + \dots + f(b-\delta x) \delta x + f(b)\delta x$, but I can replace all $\delta x$ with $x-(x-\delta x)$. Then I can separate the $x$ and $x-\delta x$ parts. (note the sum i am taking in $\delta x$ increments) Nov 7, 2018 at 6:09
• The error in your approximation looks like $f'(x) \delta x$, but there are on the order of $\frac{1}{\delta x}$ terms in the sum, so you can't ignore it. Nov 7, 2018 at 6:13
• @QiaochuYuan If you could elaborate on why the error looks like that and the number of terms I would gladly accept that as an answer. If not, I am grateful for at least you comment. Thank you. (Also, intuitively it seems like you are saying "the error is not so big if the derivative is not large, but because the sum has many terms in the end it is not negligible. I was thinking something along those lines but was thinking if I could make "the error" small enough the number of terms shouldn't matter). Nov 7, 2018 at 6:16
• @user106860 : $f(x - \delta x)$ is approximately $f(x) - f'(x)\ \delta x$ because the derivative of a function linearizes it there, or equivalently, it is the sensitivity to a vanishingly small change in the input, and $\delta x$ is such a vanishing change. Nov 7, 2018 at 7:41

Sure, $$f(x) \approx f(x-\delta x)$$, so you can pair off most of the terms in pairs that are approximately $$0$$. But they are only approximately zero, and there are a lot of them ($$(b-a)/\delta x$$ of them, and $$\delta x$$ is very small!). So, the total sum of them may still be non-negligible because there are so many of them.
Indeed, using the same reasoning, you could just say that in $$\sum f(x)\delta x$$ each term is very small, since $$f(x)$$ is bounded and $$\delta x$$ is small. Your approach would then say that $$0$$ is a good approximation to the integral. Of course this is wrong, because although each term is small (roughly proportional to $$\delta x$$), the number of terms is large in a way that cancels it out (proportional to $$1/\delta x$$).
We can be more precise and say that $$f(x)-f(x-\delta x)\approx f'(x) \delta x$$ if $$f$$ is differentiable. So, the errors in your terms are also roughly proportional to $$\delta x$$, at least as long as $$f'(x)$$ is bounded and stays away from $$0$$. We can thus expect a non-negligible total error when we add up $$(b-a)/\delta x$$ such errors.
To be even more precise, we can expect the error to be $$\int_a^b xf'(x)\, dx$$, since each term of the error has the form $$(x-\delta x)(f(x)-f(\delta x))\approx xf'(x)\delta x$$. We can verify this rigorously: if you integrate $$\int_a^b f(x)\, dx$$ by parts with $$u=f(x)$$ and $$v=x$$ (assuming $$f$$ is continuously differentiable) you get $$\int_a^b f(x)\,dx=xf(x)\bigg|_a^b-\int_a^b xf'(x)\,dx=(bf(b)-af(a))-\int_a^b xf'(x)\,dx.$$ The first term is exactly what you find with your approximation, so the error is indeed $$\int_a^b xf'(x)\,dx$$. In this sense, then, the error you are making is akin to saying that the derivative of $$xf(x)$$ should be $$f(x)$$, which is what you get by differentiating just the $$x$$ factor but ignoring the fact that $$f(x)$$ may also be changing.