1. The two problems that make calculus
Calculus is two questions. Everything else in this course — every rule, every theorem, every technique with a name — is machinery built to answer them.
How fast is something changing right now? And how much has accumulated so far? The first is the tangent problem, the second is the area problem. They look unrelated. They turn out to be the same question asked backwards, and that fact is the single most useful thing in mathematics.
Problem 1: the tangent
Average speed is arithmetic. Drive 120 km in 2 hours and your average speed was 60 km/h. Distance over time, done.
But your speedometer doesn't read an average. It reads a speed at an instant — and that quantity resists the same arithmetic. Speed is distance over time, and at a single instant no distance passes and no time elapses:
\text{speed at an instant} = \frac{0}{0}
That is not a number. It isn't even a badly-behaved number; the expression carries no information at all, because \frac{0}{0} is consistent with any answer you like.
Geometrically it's the same obstruction. Given a curve, the slope between two points is easy — rise over run. The slope at one point needs two points and you have one.
The way through is to refuse to take the instant directly. Compute the average over a short interval, then a shorter one, then shorter still, and watch where the answers head.
Take f(x) = x^2 at x = 1. Over the interval from 1 to 1 + h:
\frac{f(1+h) - f(1)}{h} = \frac{(1+h)^2 - 1}{h} = \frac{1 + 2h + h^2 - 1}{h} = \frac{2h + h^2}{h} = 2 + h
Every step there is legal as long as h \neq 0 — which it is, because we never let it be zero. And now the answer is obvious: as h shrinks, 2 + h heads for 2.
That's the whole trick. We never divide by zero. We divide by something small and watch. The value it heads toward is the derivative, and this course spends its first third on it.
Problem 2: the area
The area of a rectangle is base times height. The area under a curve has no such formula, because the height won't hold still.
Same move. Chop the region into thin rectangles, each using one height as if the curve were flat across its width, add them up, and let the rectangles get thinner.
For f(x) = x^2 between 0 and 1, cut [0,1] into n strips of width 1/n, and take each strip's height at its left edge:
\text{estimate} = \sum_{i=0}^{n-1} \left(\frac{i}{n}\right)^2 \cdot \frac{1}{n} = \frac{1}{n^3}\sum_{i=0}^{n-1} i^2 = \frac{1}{n^3} \cdot \frac{(n-1)n(2n-1)}{6}
Expand that and the n's mostly cancel:
= \frac{2n^3 - 3n^2 + n}{6n^3} = \frac{1}{3} - \frac{1}{2n} + \frac{1}{6n^2}
As n grows the correction terms die and the estimate heads for \frac{1}{3}.
Notice we did exactly what we did for the tangent: replace an impossible exact question with an easy approximate one, then take the approximation to its limit.
The punchline you'll spend the course earning
Those two answers look like different worlds. One is about steepness, one about accumulation. But watch:
The area under x^2 from 0 to b turns out to be \frac{b^3}{3}. And the derivative of \frac{b^3}{3} is b^2 — the function we started with.
That is not a coincidence about cubes. Differentiation and integration are inverse operations. Accumulate a rate and then ask how fast the accumulation is growing, and you get the rate back. This is the Fundamental Theorem of Calculus, it arrives in §4, and it converts the area problem — genuinely hard as a limit of sums — into the search for an antiderivative.
Isaac Newton and Gottfried Leibniz found this independently in the 1660s–70s, and it is why they are credited with inventing calculus rather than Archimedes, who had already computed plenty of specific areas by exhaustion two millennia earlier. Archimedes had the limits. He didn't have the link.
What "limit" has to mean
Both problems bottomed out in the same phrase: where the answers head. That phrase is doing enormous work and it isn't yet mathematics.
"Heads toward 2" needs to mean something checkable, something that distinguishes 2 + h \to 2 from a sequence that wobbles forever without settling. Making it precise is the job of §1, and the definition that does it — epsilon and delta — took mathematicians about 150 years to write down after calculus was already being used to predict planetary orbits.
That's worth knowing. The intuition came first and worked; the rigor came later and explained why. You'll learn them in the same order.
Doing it in Python
Watch the secant slopes for f(x) = x^2 at x = 1 close in on 2:
def f(x):
return x * x
print(f"{'h':>10} {'secant slope':>14}")
for h in (1, 0.5, 0.1, 0.01, 0.001, 0.0001):
print(f"{h:>10} {(f(1 + h) - f(1)) / h:>14.6f}")
print("\nheading for 2 -- and the algebra said 2 + h, which is exactly what we see")
Now the area, with left-endpoint rectangles:
def riemann_left(f, a, b, n):
"""Total area of n left-endpoint rectangles under f on [a, b]."""
width = (b - a) / n
return sum(f(a + i * width) for i in range(n)) * width
def f(x):
return x * x
print(f"{'n':>8} {'estimate':>12} {'error':>12}")
for n in (10, 100, 1_000, 10_000, 100_000):
est = riemann_left(f, 0, 1, n)
print(f"{n:>8} {est:>12.6f} {est - 1/3:>12.6f}")
print("\nheading for 1/3 = 0.333333")
print("the error halves when n doubles -- it is the -1/(2n) term in the algebra")
And the punchline, numerically. Compute the area from 0 to b for several b, then differentiate that function of b and see b^2 come back:
def riemann_left(f, a, b, n=200_000):
width = (b - a) / n
return sum(f(a + i * width) for i in range(n)) * width
def square(x):
return x * x
def area_up_to(b):
return riemann_left(square, 0, b)
h = 1e-4
print(f"{'b':>5} {'area(b)':>10} {'b^3/3':>10} {'d/db area':>11} {'b^2':>7}")
for b in (0.5, 1.0, 1.5, 2.0):
slope = (area_up_to(b + h) - area_up_to(b - h)) / (2 * h)
print(f"{b:>5} {area_up_to(b):>10.5f} {b**3/3:>10.5f} {slope:>11.4f} {b*b:>7.2f}")
print("\nthe rate the area grows IS the height of the curve -- that is the FTC")
Worked example
A ball is dropped. After t seconds it has fallen s(t) = 4.9t^2 metres. How fast is it falling at exactly t = 1?
Average velocity over [1, 1+h]:
\frac{s(1+h) - s(1)}{h} = \frac{4.9(1+h)^2 - 4.9}{h} = \frac{4.9(1 + 2h + h^2) - 4.9}{h} = \frac{9.8h + 4.9h^2}{h}
Cancel the h — legal, since h \neq 0:
= 9.8 + 4.9h
Now let h shrink: the velocity at t = 1 is \boxed{9.8} m/s.
Sanity-check the shape of that answer. It's g \cdot t with g = 9.8, which is the physics you'd expect, and we got it from arithmetic on the position function alone.
Note what happened to h. We could not set h = 0 at the start — the expression was \frac{0}{0}. After cancelling we could, because 9.8 + 4.9h is a perfectly ordinary function of h with no hole at zero. The algebra removed the singularity. Almost every limit you compute by hand in §1 is some version of that manoeuvre.
Your turn
1. For f(x) = x^3, simplify \frac{f(2+h) - f(2)}{h} and read off the tangent slope at x = 2.
2. Estimate the area under f(x) = x from 0 to 1 using n left rectangles, in closed form. What does it head toward, and is that the right answer?
3. A car's position is s(t) = t^2 + 3t. Find its velocity at t = 4 from the definition.
Solutions
1. Expand (2+h)^3 = 8 + 12h + 6h^2 + h^3:
\frac{8 + 12h + 6h^2 + h^3 - 8}{h} = \frac{12h + 6h^2 + h^3}{h} = 12 + 6h + h^2
As h \to 0 this heads for \boxed{12}. (Which is 3 \cdot 2^2 — the power rule, arriving in §2, in the wild.)
2. Strips of width 1/n, left heights i/n:
\sum_{i=0}^{n-1} \frac{i}{n} \cdot \frac{1}{n} = \frac{1}{n^2} \cdot \frac{(n-1)n}{2} = \frac{n-1}{2n} = \frac{1}{2} - \frac{1}{2n}
This heads for \frac{1}{2}. And it must: the region is a triangle with base 1 and height 1, whose area is \frac{1}{2} by geometry. Note the estimate is always below \frac{1}{2} — left endpoints undershoot an increasing function, which is a useful thing to know when you want a guaranteed bound rather than a guess.
3. s(4+h) = (4+h)^2 + 3(4+h) = 16 + 8h + h^2 + 12 + 3h = 28 + 11h + h^2, and s(4) = 28. So
\frac{s(4+h) - s(4)}{h} = \frac{11h + h^2}{h} = 11 + h \longrightarrow 11
The velocity at t = 4 is 11.
Check yourself in code
Do both problems at once for a cubic.
Print the secant slope of f(x) = x^3 at x = 2 for h = 0.1, 0.01, 0.001 (6 decimal places), then left-endpoint Riemann estimates of the area under g(x) = x^2 on [0, 1] for n = 10, 100, 1000 (5 decimal places).
Print exactly this:
secant h=0.1 12.610000
secant h=0.01 12.060100
secant h=0.001 12.006001
riemann n=10 0.28500
riemann n=100 0.32835
riemann n=1000 0.33283
def f(x):
return x ** 3
def g(x):
return x * x
for h in (0.1, 0.01, 0.001):
slope = (f(2 + h) - f(2)) / h
print(f"secant h={h:<8} {slope:.6f}")
# Now the areas: n left-endpoint rectangles under g on [0, 1].
def f(x):
return x ** 3
def g(x):
return x * x
for h in (0.1, 0.01, 0.001):
slope = (f(2 + h) - f(2)) / h
print(f"secant h={h:<8} {slope:.6f}")
for n in (10, 100, 1000):
width = 1 / n
est = sum(g(i * width) for i in range(n)) * width
print(f"riemann n={n:<7} {est:.5f}")
Two questions — the slope at a point, the area under a curve — and one method: replace the impossible exact computation with an easy approximate one, then watch where the approximations go. The rest of calculus is making that watching precise, and discovering that the two answers are inverse to each other.
Next: a limit argument that predates limits by two thousand years — where \pi r^2 and 2\pi r actually come from.