Skip to content
DoingCamp CS

Make it comfy

Lesson style

Quick mode shows the key picture, a summary and the practice. Good for a refresher.

Theme
Font

Both fonts are designed to be easy to read. Some readers with dyslexia prefer Lexend.

Text size
Spacing
Animations

Lesson 2 of 20 · about 15 min

Limits

The Big Drop's speed display has to show the speed at one instant, but "distance moved in zero time, divided by zero time" is 0 ÷ 0. The way out is to ask what the numbers get close to as the time gap shrinks. That's a limit. You'll walk up to tricky points from both sides, find values a formula can't reach directly, and spot limits that don't exist at all.

🧭 What you need first: Rates of change

The story

The Big Drop’s display should show the rider’s speed at each moment. Your average-speed code from lesson 1 measures the drop between t=1t = 1 and t=1+kt = 1 + k:

q(k)=h(1+k)−h(1)kq(k) = \frac{h(1 + k) - h(1)}{k}

To get the speed at t=1t = 1, you’d set the gap kk to 0. But then the top is h(1)−h(1)=0h(1) - h(1) = 0 and the bottom is 0: the program crashes with a division by zero. The question isn’t silly, though. As the gap gets smaller and smaller, the average speed clearly settles on something.

Ancient Greek philosophers argued about exactly this. Zeno said that at any single instant a flying arrow covers no distance, so how can it be moving? It took until the 1800s for mathematicians (Cauchy, then Weierstrass) to give a precise answer: don’t plug in zero, ask what the values approach. That’s a limit.

Another way: walking toward a wall

Walk halfway to a wall, then half the remaining distance, then half again. You never touch the wall, but there’s no doubt where you’re heading: the distance shrinks toward 0. A limit is “where you’re heading”, which can be perfectly clear even if you never arrive.

Play with it

Sneak up on the answer

Here is q(k)q(k), the average speed (as a rate of height change) from t=1t = 1 to t=1+kt = 1 + k. At k=0k = 0 it’s undefined: there’s a hole in the graph. Walk toward 0 and watch the table.

🎯 1/2: Get within 0.001 of k = 0 from the LEFT and from the RIGHT.

q(k) = (h(1 + k) − h(1)) / k. Walk toward x = 0 from one side, closer and closer, and watch the values. Then try the other side.

Come from the
xf(x)

f(x) is −1 for x below 0 and 1 for x from 0 up. What is the limit as x → 0?

When the sides disagree

🎯 1/2: Approach 0 from both sides, within 0.001.

f(x) = −1 for x < 0, 1 for x ≥ 0. Walk toward x = 0 from one side, closer and closer, and watch the values. Then try the other side.

Come from the
xf(x)

A famous one

sin⁡xx\frac{\sin x}{x} is 0 ÷ 0 at x=0x = 0 too. It matters for the derivative of sine in lesson 7.

🎯 1/1: Find the limit of sin(x)/x as x → 0 (x in radians).

f(x) = sin(x)/x. Walk toward x = 0 from one side, closer and closer, and watch the values. Then try the other side.

Come from the
xf(x)
Name it

The real words

  • The Limit:

    lim⁡x→cf(x)=L\lim_{x \to c} f(x) = L

    means you can make f(x)f(x) as close to LL as you like by taking xx close enough to cc, with x≠cx \neq c. The precise “epsilon–delta” version of this sentence was written down by Weierstrass in the 1800s.

  • What happens at cc is irrelevant: q(0)q(0) is undefined, yet lim⁡k→0q(k)=−9.8\lim_{k \to 0} q(k) = -9.8. Algebra shows why: h(1+k)−h(1)=−4.9(2k+k2)h(1 + k) - h(1) = -4.9(2k + k^2), so q(k)=−9.8−4.9kq(k) = -9.8 - 4.9k for every k≠0k \neq 0, which heads to −9.8-9.8.

  • One-sided limits: lim⁡x→c−\lim_{x \to c^-} uses only x<cx < c; lim⁡x→c+\lim_{x \to c^+} uses only x>cx > c. The two-sided limit exists exactly when both exist and are equal.

  • How limits fail:

    • a jump: the sides approach different values;
    • blowing up: 1/x1/x near 0 grows without bound (we write →∞\to \infty, but there’s no finite limit);
    • wild wiggling: sin⁡(1/x)\sin(1/x) swings between −1 and 1 infinitely often near 0 and never settles.
  • A function is continuous at cc when there’s no surprise: lim⁡x→cf(x)=f(c)\lim_{x \to c} f(x) = f(c). Polynomials, sin⁡\sin, cos⁡\cos and exe^x are continuous everywhere, so for them you can just plug in.

  • Limits at infinity: the pool’s volume 450(1−e−t/4)450(1 - e^{-t/4}) approaches 450 as t→∞t \to \infty without ever quite reaching it.

Build it

Limits by table

Write table(f, c, side): a list of f(c + side × 10⁻ⁿ) for n = 1, 2, …, 6, where side is −1 (from the left) or 1 (from the right). Then q(k) = (h(1 + k) − h(1)) / k for the Big Drop (h is included).

Challenge

A limit detector

Write guess_limit(f, c): take the last values of table(f, c, −1) and table(f, c, 1) (your table is included). If they're within 1e-4 of each other, return their average rounded to 4 decimal places; otherwise return None (the sides disagree, or the values haven't settled).

A table can fool you: sin⁡(1/x)\sin(1/x) happens to look settled at some sample points and not others. That’s why mathematicians prove limits with algebra, and why your detector says “guess”. Still, this is exactly the kind of check programmers run to catch numerical bugs.

Remember it

g(x) = (x² − 4)/(x − 2). What is the limit of g(x) as x → 2?

Got it?

Finish the lesson to color it in on your map and collect its concept cards.

Did this lesson click?