A Preview of Calculus
Calculus grew out of a handful of old problems that ordinary algebra cannot finish: the area of a curved region, the slope of a curve at one point, the speed of a body at one instant, and the sum of infinitely many numbers. This lesson shows that all of them are solved by one idea, the limit, before the rest of the course makes that idea precise.
For a gentler first look at the two main ideas, see Calculus Intro.
The area problem
Algebra handles areas of polygons: cut them into triangles. A circle has no corners, so the ancient trick was to approximate it by polygons with more and more sides and see what the areas approach. A regular -gon inscribed in a circle of radius 1 consists of triangles with two sides 1 and apex angle , so its area is
import math
for n in [6, 12, 24, 96, 1000, 100000]:
area = n / 2 * math.sin(2 * math.pi / n)
print(f"n = {n:>6}: area = {area:.10f} gap to π = {math.pi - area:.2e}")n = 6: area = 2.5980762114 gap to π = 5.44e-01
n = 12: area = 3.0000000000 gap to π = 1.42e-01
n = 24: area = 3.1058285412 gap to π = 3.58e-02
n = 96: area = 3.1393502030 gap to π = 2.24e-03
n = 1000: area = 3.1415719828 gap to π = 2.07e-05
n = 100000: area = 3.1415926515 gap to π = 2.07e-09
The area of the circle is the limit of the polygon areas, . Notice the gap shrinks by a factor of about 100 each time grows by 10: the error behaves like a constant times . Measuring how fast an approximation converges will be a recurring theme (it is what separates a good numerical method from a bad one).
The same strategy works for the region under a graph: cover it with thin rectangles, add their areas, and let the width go to zero. That limit is the definite integral, the subject of chapter 5 (Areas and Distances).
import numpy as np
import matplotlib.pyplot as plt
f = np.sqrt
n = 8
xs = np.linspace(0, 4, n + 1)
plt.figure(figsize=(6, 4))
t = np.linspace(0, 4, 400)
plt.plot(t, f(t), color="black", label="y = √x")
plt.bar(xs[:-1], f(xs[1:]), width=4 / n, align="edge", alpha=0.35, edgecolor="C0", label="right-endpoint rectangles")
plt.legend()
plt.title("Approximating the area under y = √x on [0, 4]")
for m in [8, 80, 800, 8000]:
x = np.linspace(0, 4, m + 1)
print(m, round(float(np.sum(f(x[1:])) * 4 / m), 6))
print("exact 16/3 =", round(16 / 3, 6))8 5.765042
80 5.381061
800 5.33826
8000 5.333831
exact 16/3 = 5.333333
Right-endpoint rectangles overshoot here because is increasing; as grows the overshoot disappears.
The tangent problem
What is the slope of the curve at the point ? A slope needs two points, and the tangent line touches the curve at only one. So take a second point on the curve, compute the slope of the secant line , and let slide towards :
As this tends to . That is the slope of the tangent, and it is the derivative of at 2.
f = lambda x: 1 / x
for h in [1, 0.1, 0.01, -0.01, -0.1, 0.0001]:
print(f"h = {h:>7}: secant slope = {(f(2 + h) - f(2)) / h:.6f}")h = 1: secant slope = -0.166667
h = 0.1: secant slope = -0.238095
h = 0.01: secant slope = -0.248756
h = -0.01: secant slope = -0.251256
h = -0.1: secant slope = -0.263158
h = 0.0001: secant slope = -0.249988
From both sides the slopes close in on −0.25. The algebra above is a proof; the table is evidence.
Velocity
If is the position of a car, the average velocity over is , the slope of a secant on the position graph. The velocity at the instant is the limit as . So the velocity problem and the tangent problem are the same problem. This is worked out in The Tangent and Velocity Problems.
Infinite sums
Zeno's paradox: to cross a room you first cover half the distance, then half of what is left, and so on, so you must complete infinitely many steps. The total distance is
The partial sums are , and the th one equals , which has limit 1. An infinite sum is defined as the limit of its partial sums, when that limit exists. Not every such sum has one: grows without bound, though extremely slowly. Chapter 11 builds the tests that tell the two cases apart (Series).
One idea behind everything
| Problem | Approximation | Exact answer is the limit of |
|---|---|---|
| area under a curve | sum of rectangle areas | sums as the |
| tangent slope | secant slope | secant slopes as |
| instantaneous velocity | average velocity | averages as the |
| infinite sum | partial sum | partial sums as |
The Fundamental Theorem of Calculus (chapter 5) then reveals that the area problem and the tangent problem are inverse to each other.
In software
Programs live inside the "approximation" column of that table. A physics engine advances a game by small time steps and adds up (a Riemann sum). An optimiser estimates gradients from small differences (secant slopes). math.sin and math.exp are computed from a few terms of an infinite series. Knowing that the exact answer is a limit tells you what to expect: smaller steps and more terms help, up to the point where floating-point rounding takes over, a trade-off studied in Numerical Calculus and Floating Point.
Exercises
Exercise 1: Rectangles under a line
Divide into equal pieces and use right-endpoint rectangles under . Find a formula for the total area in terms of and its limit.
Answer
, with limit 2.
Solution
The exact area is the triangle , as it should be.
Exercise 2: A secant slope by algebra
For , find the slope of the secant line through and , simplify it, and find the tangent slope at .
Answer
Secant slope ; tangent slope 6.
Solution
Exercise 3: A repeating decimal as a series
Write as an infinite sum, find the th partial sum and its limit.
Answer
; ; the limit is .
Solution
The terms are . The partial sum of a geometric sum with first term and ratio is :
Exercise 4: Perimeters approach the circumference
The perimeter of a regular -gon inscribed in a circle of radius 1 is . Print it for and compare with .
Answer
.
Solution
Each side subtends the angle , so its length is (half the side is ).
import math
for n in [6, 60, 600, 6000]:
print(n, round(2 * n * math.sin(math.pi / n), 8))
print("2π =", round(2 * math.pi, 8))6 6.0
60 6.28031475
600 6.2831566
6000 6.28318502
2π = 6.28318531
Test yourself
What single idea solves the area, tangent, velocity and infinite-sum problems?
- Factoring
- The limit
- The Pythagorean theorem
- Logarithms
The secant slope of between and is . What is the tangent slope at ?
- 0
Which of these infinite sums has a finite value?