Table of Contents
Back in high school, I remember being introduced to the key concepts in calculus. First, the derivative was presented as the slope of the tangent line to a curve at a given point. Then the integral was defined as the area under the curve. And finally the leap of faith: both operations were inverses of each other.
I remember being confused about this statement we were asked to blindly accept. And college did not help much in that regard. We were given a bunch of rules to compute derivatives and integrals, but the connection between them was never made clear. And that is precisely what we are going to do in this post. We will start by revisiting the definitions of the derivative and the integral, and then we will try to gain some geometric intuition about why they reverse each other.
All the code used to generate the animations in this article is available at the following public repository:
Auxiliary repository1. Derivative: The slope of the tangent line
The derivative $f’(x_0)$ of a function $f(x)$ at a point $x_0$ was introduced to us as the slope of the tangent line to a curve at $x_0$. In order to estimate it, we would take two points on the curve, $x_0$ and $x_0 + \Delta x$, and calculate the slope of the secant line between them:
$$ \begin{equation} s(x)\approx \frac{f(x_0 + \Delta x) - f(x_0)}{\Delta x} \end{equation} $$
As the distance between the points decreases, our approximation of the slope of the tangent line would improve. And in the limit, as $\Delta x$ approaches zero, we would obtain the exact slope $s(x)$ of the tangent line at the point $x_0$. This is the definition of the derivative:
$$ \begin{equation} s(x) = f’(x) = \frac{\partial f(x)}{\partial x} = \lim_{\Delta x \to 0} \frac{f(x + \Delta x) - f(x)}{\Delta x} \end{equation} $$
The following animation illustrates how the derivative is built geometrically as the slope of the secant line between two points on the curve.
2. Integral: The area under the curve
Then things got a bit more complicated when we were introduced to the integral. The integral of a function $f(x)$ over an interval $[a, b]$ was defined as the area under the curve $A$. In order to estimate it, one would divide the interval into $n$ subintervals of equal width $\Delta x$, where n is given by:
$$ \begin{equation} n = \frac{b - a}{\Delta x} \end{equation} $$
Then we would sum the areas of the rectangles formed by the function values at the left endpoint of each subinterval. This is known as the left Riemann sum:
$$ \begin{equation} A \approx \sum_{i=0}^{n-1} f(a + i\cdot \Delta x) \cdot \Delta x \end{equation} $$
As the width of the subintervals decreases, the approximation of the area under the curve would improve. And in the limit, as $\Delta x$ approaches zero, we would obtain the exact area $A(x)$ under the curve. This is the definition of the integral:
$$ \begin{equation} A(x) = \int_{a}^{x} f(y) \cdot dy = \lim_{\Delta x \to 0} \sum_{i=0}^{n-1} f(a + i\cdot \Delta x) \cdot \Delta x \end{equation} $$
The following animation illustrates how the integral is built geometrically as the area under the curve.
3. Differentiating the area under the curve
And here is where magic happened! In order to show us how to compute the derivative of a function, the teacher started by applying the definition in Eq.(2) for a set of simple functions, such as polynomials. Then we were given a set of rules to compute the derivative of more complex functions.
Nonetheless, for computing the integral, we were simply told that it was the inverse operation of the derivative. So if we wanted to compute the integral of a function, we should find a function whose derivative is the one we are interested in. And that was it!
I remember wondering: how come the area under the curve is the inverse operation of the slope of the tangent line? It was not intuitive to me at all!"
Luckily, it turns out that there is a very simple geometric explanation for this. In order to understand it, we will resort to the geometric approximation of the derivative and the integral as defined them in the previous sections.
- The derivative is approximated by the slope of the secant line between two points on the curve.
- The integral is approximated by partitioning the interval into subintervals and summing the areas of the rectangles formed by the function values at the left endpoint of each subinterval.
So say we want to differentiate the function that corresponds to the area under the curve $A(x)$ in the interval $[x_0, x]$. According to Eq.(1), its derivative $A’(x)$ would be approximated by:
$$ \begin{equation} A’(x) \approx \frac{A(x + \Delta x) - A(x)}{\Delta x} \end{equation} $$
We can expand the numerator using Eq.(4):
$$ \begin{equation} A’(x) \approx \frac{\sum_{i=0}^{n} f(x_0 + i\cdot \Delta x) \cdot \Delta x - \sum_{i=0}^{n-1} f(x_0 + i\cdot \Delta x) \cdot \Delta x}{\Delta x} \end{equation} $$
Notice how the first sum has $n+1$ terms, while the second sum has $n$ terms. This results in all terms being cancelled out except for the last one:
$$ \begin{equation} A’(x) \approx f(x_0 + n\cdot \Delta x) = f(x) \end{equation} $$
So the derivative of the area under the curve $A(x)$ is the function $f(x)$ itself! This is illustrated in the following animation:
4. Integrating the slope of the tangent line
How about going the other way? Say we want to integrate the function that corresponds to the slope of the tangent line $s(x)$ at a point $x$.
First of all, notice how adding a constant to the function $f(x)$ does not change its derivative $f’(x)$, as illustrated below:
That implies that information is lost, so we will only be able to recover the function up to a constant. According to Eq.(4), area under the slope curve $s(x)$ in the interval $[x_0, x]$ can be approximated by:
$$ \begin{equation} \int_{x_0}^{x} s(y) \cdot dy \approx \sum_{i=0}^{n-1} s(x_0 + i\cdot \Delta x) \cdot \Delta x \end{equation} $$
where $n=\frac{x - x_0}{\Delta x}$. We can expand the sum using Eq.(1):
$$ \begin{equation} \int_{x_0}^{x} s(y) \cdot dy \approx \sum_{i=0}^{n-1} \frac{f(x_0 + (i+1)\cdot \Delta x) - f(x_0 + i\cdot \Delta x)}{\Delta x} \cdot \Delta x \end{equation} $$
or splitting it in two sums:
$$ \begin{equation} \int_{x_0}^{x} s(y) \cdot dy \approx \sum_{i=1}^{n} f(x_0 + i\cdot \Delta x) - \sum_{i=0}^{n-1} f(x_0 + i\cdot \Delta x) \end{equation} $$
Most terms in the sum cancel out except for the first and last ones, so the expression simplifies to:
$$ \begin{equation} \int_{x_0}^{x} s(y) \cdot dy \approx f(x_0 + n\cdot \Delta x) - f(x_0) = f(x) - f(x_0) \end{equation} $$
So the integral of the slope of the tangent line $s(x)$ is the function $f(x)$ itself, up to a constant! That constant is the value of the function at the starting point $x_0$, which is an arbitrary choice.
This is illustrated in the following animation:
5. Conclusion
In this post, we revisited the definitions of the derivative and the integral, and we tried to gain some geometric intuition about why they reverse each other. We have shown this can be visually understood by using the geometric approximations of the derivative and the integral. So hopefully, you will not need to accept this concept on blind trust as I had to back in high school!
6. References
- Fundamental Theorem of Calculus. Geometric meaning/Proof. Wikipedia
- Riemann sum. Wikipedia
- Integration and the fundamental theorem of calculus. Chapter 8, Essence of calculus, by 3Blue1Brown (Grant Sanderson)