Skip to content
Tutorials Center
My learning

Topics

Lesson 6 of 68 ยท Limits and Continuity

Continuity

Learn the definition of continuity, the types of discontinuity, the intermediate value theorem, and write a bisection root finder in Python.

Informally, a function is continuous if you can draw its graph without lifting your pencil. Engineers lean on this: a temperature does not jump from 20 to 80 degrees in zero time, and a beam's deflection has no sudden gaps. Continuity is the property that lets limits, derivatives and root-finding algorithms behave.

This lesson makes the pencil test precise, catalogues the ways a function can fail to be continuous, and then uses the intermediate value theorem to build one of the most reliable numerical algorithms: bisection.

The definition

A function f is continuous at a point a when three things hold:

  1. f(a) is defined,
  2. lim (x โ†’ a) f(x) exists,
  3. the limit equals the value: lim (x โ†’ a) f(x) = f(a).

If any condition fails, f is discontinuous at a. A function is continuous on an interval if it is continuous at every point there. Polynomials, sin, cos, exp are continuous everywhere; rational functions and tan are continuous wherever they are defined; ln and square roots are continuous on their domains.

Sums, products, quotients (with nonzero denominators) and compositions of continuous functions are continuous. That is why direct substitution works for so many limits.

Types of discontinuity

flowchart TD
    D["Discontinuity at x = a"] --> R["Removable<br/>limit exists, but f(a) is<br/>missing or wrong"]
    D --> J["Jump<br/>left and right limits<br/>exist but differ"]
    D --> I["Infinite<br/>function blows up<br/>near a"]
    D --> O["Oscillating<br/>no limit, wild swings"]

Four ways continuity can fail; only the removable kind can be repaired by redefining one value.

  • Removable: f(x) = (x**2 - 1)/(x - 1) has a hole at 1. Define f(1) = 2 and it becomes continuous.
  • Jump: a step function, such as the cost of parking by the whole hour. The left and right limits exist but differ.
  • Infinite: 1/x**2 at 0 shoots to infinity, a vertical asymptote.
  • Oscillating: sin(1/x) at 0 swings between -1 and 1 infinitely often.
Python Classify discontinuities with sympy

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The first case shows equal finite one-sided limits (a removable hole). The second shows both sides at infinity. The third shows -1 and 1: a jump.

Piecewise functions

Engineers write piecewise functions all the time (a switch that turns on at t = 0, a tax bracket). To make one continuous at a join, the pieces must meet there. Suppose

f(x) = x**2 for x < 2, and f(x) = kยทx โˆ’ 2 for x โ‰ฅ 2.

The left limit at 2 is 4. The right piece gives 2k โˆ’ 2. For continuity, 2k โˆ’ 2 = 4, so k = 3.

Python Choose k so the pieces meet

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

With k = 3 the two branches join at height 4. With k = 2 the right branch starts at 2, leaving a visible gap.

The intermediate value theorem

If f is continuous on the closed interval [a, b] and N is any number between f(a) and f(b), then some c in [a, b] has f(c) = N. A continuous function cannot skip values.

The most useful special case: if f(a) and f(b) have opposite signs, then f has a root between a and b. The theorem guarantees a root exists, but does not say where. Notice what fails without continuity: 1/x is negative at -1 and positive at 1, yet it has no root, because of the break at 0.

Bisection: finding roots by halving

The theorem leads straight to an algorithm. Take an interval where the sign changes, look at the midpoint, and keep the half whose endpoints still have opposite signs. Repeat. Each step halves the interval, so after n steps the bracket has width (b โˆ’ a)/2**n.

flowchart TD
    S["Start: f(a) and f(b)<br/>have opposite signs"] --> M["m = (a + b) / 2"]
    M --> C{"sign of f(m)<br/>equals sign of f(a)?"}
    C -->|"yes"| A["a = m"]
    C -->|"no"| B["b = m"]
    A --> W{"b - a small enough?"}
    B --> W
    W -->|"no"| M
    W -->|"yes"| E["root is near (a + b) / 2"]

Bisection halves the bracket until it is as narrow as you need.

Python A bisection root finder

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

About 34 halvings shrink an interval of width 1 below 1e-10. Bisection is slow compared with Newton's method (see Linearization and Newton's Method), but it never fails when the sign change is genuine and f is continuous, which is why it is used as a safe fallback.

Be careful with the last example: 1/x has endpoints of opposite sign, so the sign check passes, and the algorithm happily converges to a point next to 0, where there is a pole rather than a root. Always check |f(root)| afterward, since the theorem only promises a root for continuous functions.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which condition is NOT part of the definition of continuity at a?

    Continuity needs a defined value, an existing limit, and equality of the two. Differentiability is a stronger property that is not required.
  2. 2. f(x) = (x**2 - 4)/(x - 2) has what kind of discontinuity at x = 2?

    It simplifies to x + 2 for x not equal to 2, so the limit is 4 but f(2) is undefined: a removable hole.
  3. 3. For f(x) = x**3 - 2x - 5, f(2) = -1 and f(3) = 16. What does the IVT guarantee?

    f is continuous and changes sign on [2, 3], so there is at least one root in the interval. The theorem does not locate it.
  4. 4. After 10 bisection steps on an interval of width 1, how wide is the bracket?

    Each step halves the width, so after 10 steps it is 1/2**10 = 1/1024.

Summary

  • Continuous at a means: defined, limit exists, limit equals value.
  • Discontinuities are removable, jump, infinite or oscillating; only removable ones can be patched.
  • Piecewise functions are continuous when the pieces meet at the join.
  • The intermediate value theorem: a continuous function that changes sign on [a, b] has a root there.
  • Bisection turns that theorem into a robust algorithm that halves the bracket each step.

Next: The Derivative as a Rate of Change.