Tags

This is a lecture post for my students in the CUNY MS Data Analytics program. In this series of lectures I discuss mathematical concepts from different perspectives. The goal is to ask questions and challenge standard ways of thinking about what are generally considered basic concepts. Consequently these lectures will not always be as rigorous as they could be.

This week let’s take a closer look at integration. People often describe integration as area under the curve. This is indeed true, yet I always found it a bit difficult to understand how you get from area under the curve to the Fundamental Theorem of Calculus. This theorem can be cast two different ways, and I’m referring to it as $\int_a^b f(x) dx = F(b) - F(a)$, where $F$ is the antiderivative of $f$.

I like starting with simple examples since it’s a lot easier to understand the behavior of something when you minimize the variables introduced. Hence, let’s start by looking at a line.

xs <- seq(-1,5, by=0.02)
f <- function(x) x - 1
plot(xs, f(xs), type='l', col='green')
abline(h=0, v=0, col='grey')


There’s nothing particularly remarkable here, so let’s change that. What happens if we add to this graph the cumulative Riemann sum of $f$ for the interval [-1,5]? In other words let’s graph $F(x) = \sum_{k=-1}^x f(k) \Delta x$.

lines(xs, cumsum(f(xs)*.02), col='blue')


Well this looks kind of like a parabola, and obviously the limit is, but what’s the intuition around it? The simplest thing to do is to see what the cumulative sum of $f(x) \Delta x$ is.

head(cumsum(f(xs)*.02), 20)
[1] -0.0400 -0.0796 -0.1188 -0.1576 -0.1960 -0.2340 -0.2716 -0.3088 -0.3456
[10] -0.3820 -0.4180 -0.4536 -0.4888 -0.5236 -0.5580 -0.5920 -0.6256 -0.6588
[19] -0.6916 -0.7240


This is telling us that the area of a thin strip is rather small. It’s also telling us that since the slope is positive, a little bit less negative area is being added each time. Eventually something interesting happens as $x \rightarrow 1$. The value of the original function $f$ starts to get really small, eventually approaching 0 when $x = 1$. Consequently, there isn’t much contribution to the area from these parts of the line. At $x = 1$ the slope is exactly 0, which is where $f(x) = 0$. Once $x > 0$ the area contribution becomes positive and consequently the value of the Riemann sum begins to increase.

The second form of the Fundamental Theorem of Calculus is similar to our construction of the Riemann sum. It states that $\int_a^x f(t) dt = F(x) - F(a)$. This alternate construction gives the integral as a function of $x$ such that the derivative yields $\frac{d}{dx}(F(x) - F(a)) = F'(x) = f(x)$. The graph above confirms this since the slope $F'(1) = 0$ and this is exactly the value of $f(1)$.

Let’s explore the relationship of this version of the Fundamental Theorem of Calculus and the Riemann sum further. Both formulations describe a function in terms of a starting point up to some value $x$. Consider the interval [-1,1], where $a=-1, x=1$. At $F(a)$, the value is -0.04. This initial value is always going to be close to 0, since we take the limit of $\Delta x$ to 0. Getting back to our function $F$, at $x=1$ the total area is -2. We can verify this with some geometry since this is a triangle with area $A = \frac{(-2 - 0) (1 - -1)}{2} = -2$. In R this looks like

F <- function(x) sum(f(x) * .02)
> F(xs[xs <= 1])
[1] -2.02


Hence it seems reasonable that the integral for this special case is F(1), or $\sum_{-1}^1 f(x) \Delta x = F(1) = -2$. As shown above, the value computed in R is -2.02. I’ll leave it as an exercise to explain why this is so. Another useful point to look at is 3. Visually we can see that the area from -1 to 3 is represented by two congruent triangles with opposite sign, so the value must surely be 0.

> F(xs[xs <= 3])
[1] 1.665335e-16


Indeed, this value is close. We’ve successfully illustrated the relationship between area under the curve and the Fundamental Theorem of Calculus. However, this is the second version of the theorem and we started with the first. This second version relies on some constant point $a$ with a starting value $F(a) = 0$ whereas the first version uses two arbitrary points. Remember that with the Riemann sum we need to start with an initial starting point $a$ and the area will be close to 0 with small $\Delta x$. Suppose we want the value of $\int_1^3 f(x) dx$. By shifting the starting point to $a=1$, we could use the same technique so that F(3) gives us the right value.

 lines(xs[xs >= 1], cumsum(f(xs[xs >= 1])*.02), col='brown')


This has the effect of shifting the parabola by 2, which is essentially $F(1)$. Of course we don’t need to shift the starting point at all. Instead we can simply compute the difference of the two Riemann sums. This has the effect of cancelling any fixed starting point and give us the two arbitrary end points of the interval.

> F(xs[xs <= 3]) - F(xs[xs <= 1])
[1] 2.02


This gives us that $\sum_{x=a}^b f(x) \Delta x = F(b) - F(a)$. Taking the limit then gets us to the familiar $\int_a^b f(x) dx = F(b) - F(a)$.

#### Exercises

1. Why is F(xs[xs <= 1]) = -2.02 and not -2?
2. What happens when you use an interval of 0.5 instead of 0.02?
3. Are there situations where the area of the first x value of the Riemann sum won’t approach 0?