Skip to content

Functions, Limits, and Continuity

“A function” sounds like the least interesting item on a prerequisites list. It is on this one because Chapter 2 will ask whether a linear mapping is injective, surjective or bijective and use the answer to decide whether a matrix has an inverse — and Chapter 5 will differentiate things, which requires a limit, which requires knowing what a limit is.

Both are ten-minute ideas that get skipped and then quietly cost hours.

  • Domain, codomain and image, and why the image is usually smaller than the codomain.
  • Injective, surjective, bijective — and the exact sentence that connects them to matrix inverses.
  • What a limit is, including the two-sided requirement that makes it fail.
  • Continuity as “no jumps”, stated precisely enough to check.
  • Why differentiable implies continuous but not the reverse, with ReLU as the example that matters.

Intuition: a function is a machine with a rule

Section titled “Intuition: a function is a machine with a rule”

A function is three things, not one: a set of allowed inputs, a set the outputs are drawn from, and a rule. The rule must give exactly one output for each input — that requirement is the whole definition, and everything else is bookkeeping about the two sets.

diagram Diagram mermaid

The gap between image and codomain is the part people skip, and it is exactly the gap that Chapter 2 turns into a statement about solvability. If f(x)=x2f(x) = x^2 with domain and codomain both R\mathbb{R}, the image is only [0,)[0, \infty). Ask for an xx with f(x)=4f(x) = -4 and there is none — not because the arithmetic is hard, but because 4-4 is in the codomain and not in the image. Replace ff with a matrix and that is precisely the situation ”Ax=b\mathbf{A}\mathbf{x} = \mathbf{b} has no solution”.

f:DC,xf(x)f : \mathcal{D} \to \mathcal{C}, \qquad x \mapsto f(x)
  • D\mathcal{D} is the domain: every input the function accepts.
  • C\mathcal{C} is the codomain: the set the outputs live in.
  • Im(f)={f(x):xD}C\operatorname{Im}(f) = \{f(x) : x \in \mathcal{D}\} \subseteq \mathcal{C} is the image: the outputs actually achieved.

The book writes Im(Φ)\operatorname{Im}(\Phi) for the image of a linear mapping Φ\Phi and calls it the range or column space when Φ\Phi is a matrix. Same object, three names, and §2.7 uses all of them.

These three words are the reason this page exists.

f is injectivef(x)=f(y)    x=yf is surjectiveIm(f)=Cf is bijectiveboth\begin{aligned} f \text{ is \textbf{injective}} \quad&\Longleftrightarrow\quad f(x) = f(y) \implies x = y \\[2pt] f \text{ is \textbf{surjective}} \quad&\Longleftrightarrow\quad \operatorname{Im}(f) = \mathcal{C} \\[2pt] f \text{ is \textbf{bijective}} \quad&\Longleftrightarrow\quad \text{both} \end{aligned}

In words a reader can hold on to:

propertyplain Englishwhat fails without it
injectivedifferent inputs give different outputs — nothing collapsesyou cannot undo ff: two inputs share an output, so “which one was it?” has no answer
surjectiveevery value in the codomain is hit by somethingsome targets are unreachable, so “solve f(x)=bf(x) = b” can fail
bijectivea perfect pairing, both waysnothing; a bijection has a genuine inverse f1f^{-1}

An inverse exists exactly when ff is bijective. That is the sentence. Chapter 2 then says: a square matrix is invertible exactly when the linear mapping it defines is bijective, which happens exactly when its columns are linearly independent, which happens exactly when its rank is full, which happens exactly when its determinant is nonzero. Five statements, one condition — and the chain starts here.

limxaf(x)=L\lim_{x \to a} f(x) = L

reads: as xx gets arbitrarily close to aa, f(x)f(x) gets arbitrarily close to LL. Two things this does not say, both of which matter:

  • It says nothing about f(a)f(a). The function need not even be defined at aa.
  • It requires the same LL from both sides.

The two-sided requirement is where limits fail:

limxaf(x)  =  limxa+f(x)  =  Llimxaf(x)=L\lim_{x \to a^-} f(x) \;=\; \lim_{x \to a^+} f(x) \;=\; L \quad\Longleftrightarrow\quad \lim_{x \to a} f(x) = L

For f(x)=sign(x)f(x) = \operatorname{sign}(x) the left limit at 00 is 1-1 and the right limit is +1+1. They disagree, so limx0f(x)\lim_{x\to 0} f(x) does not exist — regardless of the fact that f(0)=0f(0) = 0 is perfectly well defined.

The canonical example of a limit that exists where the function does not is

limx0sinxx=1,\lim_{x \to 0} \frac{\sin x}{x} = 1,

which is undefined at 00 but has a perfectly good limit approaching it. Every derivative is a limit of this kind: a quotient that is 0/00/0 at the point of interest and has a limit anyway.

ff is continuous at aa when all three of these hold:

  1. f(a)f(a) is defined,
  2. limxaf(x)\lim_{x\to a} f(x) exists,
  3. they are equal: limxaf(x)=f(a)\lim_{x\to a} f(x) = f(a).

Continuous on an interval means continuous at every point of it. Informally: you can draw the graph without lifting the pen. All three conditions are needed — a function can satisfy any two and fail the third, which is why the definition is a list rather than a sentence.

f(a)  =  limh0f(a+h)f(a)hf'(a) \;=\; \lim_{h \to 0} \frac{f(a + h) - f(a)}{h}

ff is differentiable at aa when that limit exists. Because it is a two-sided limit, the slope approaching from the left must match the slope approaching from the right.

differentiable at a    continuous at a\text{differentiable at } a \;\Longrightarrow\; \text{continuous at } a

but not the other way round. The implication holds because the difference quotient can only have a finite limit if the numerator goes to zero, which is continuity. The converse fails at any corner.

Check the three continuity conditions and differentiability at x=0x = 0 for five functions.

f(x)f(x)f(0)f(0) defined?limit at 00 exists?equal?continuous?differentiable at 00?
x2x^2yes, 00yes, 00yesyesyes, f(0)=0f'(0) = 0
x\lvert x\rvertyes, 00yes, 00yesyesno: slopes 1-1 and +1+1
max(0,x)\max(0, x)yes, 00yes, 00yesyesno: slopes 00 and 11
sign(x)\operatorname{sign}(x)yes, 00no: 1-1 vs +1+1nono
sin(x)/x\sin(x)/xnoyes, 11no at 00no

Read the last two rows carefully — they fail for opposite reasons. sign\operatorname{sign} is defined at zero but has no limit there; sin(x)/x\sin(x)/x has a limit but is not defined there. The second is removably discontinuous: define f(0):=1f(0) := 1 and it becomes continuous. The first cannot be fixed by any choice of f(0)f(0), because there is no single value both sides approach.

Now the difference quotient for x\lvert x\rvert at 00, numerically:

hh0+h0h\dfrac{\lvert 0+h\rvert - \lvert 0\rvert}{h}
+0.1+0.1+1+1
+0.01+0.01+1+1
+0.001+0.001+1+1
0.001-0.0011-1
0.01-0.011-1
0.1-0.11-1

The quotient does not settle on one number as h0h \to 0; it settles on two, depending on the sign of hh. That is what “the limit does not exist” looks like when you compute it.

Drag the gap hh towards zero and watch the secant line become the tangent. Switch the function with the second knob: on the smooth ones the two secants converge; on the corner they converge to different lines, which is non-differentiability made visible.

sketch A secant line becomes a tangent — unless there is a corner p5.js
The blue line is the secant through x and x+h. Drag h towards zero and it rotates onto the tangent. Switch to the absolute value or ReLU and drag h through zero: the left and right secants settle on different slopes, so no tangent exists.

Set the function to |x|, put xx at 00, then drag hh all the way down. On the smooth functions the two slope readouts converge. On the corner they stay stubbornly at 1-1 and +1+1 no matter how small hh gets — and that is the limit failing to exist, watched rather than asserted.

figure Continuous and differentiable, continuous only, neither matplotlib
Three panels. Left: x squared, smooth, with a tangent line drawn at the origin. Middle: the absolute value function, continuous with a visible corner at the origin and two different one-sided slopes drawn. Right: the sign function, with a visible jump at the origin and open and filled circles marking the discontinuity. Three panels. Left: x squared, smooth, with a tangent line drawn at the origin. Middle: the absolute value function, continuous with a visible corner at the origin and two different one-sided slopes drawn. Right: the sign function, with a visible jump at the origin and open and filled circles marking the discontinuity.
The middle panel is the one to remember: the pen never lifts, so it is continuous, but the corner means there is no single tangent. ReLU has exactly this shape.
figure The difference quotient as h shrinks matplotlib
Two panels showing the difference quotient plotted against h on a logarithmic axis. For x squared both one-sided quotients converge to the same value. For the absolute value function they converge to minus one and plus one and never meet. Two panels showing the difference quotient plotted against h on a logarithmic axis. For x squared both one-sided quotients converge to the same value. For the absolute value function they converge to minus one and plus one and never meet.
Left: both sides settle on the same number, so the derivative exists. Right: they settle on two numbers, which is what a non-existent limit looks like numerically.

In the right-hand panel of the second figure, the gap between the two curves does not narrow. It is constant at 22 all the way down to h=108h = 10^{-8}, and it would stay 22 if you continued. That matters because it distinguishes a genuine non-differentiability from a numerical artefact: a real derivative shows the two branches converging as hh shrinks, until floating-point noise takes over somewhere around h108h \approx 10^{-8} and they start to diverge again. Noise-driven divergence gets worse as hh shrinks; a corner’s gap is flat.

That distinction is how §5.5’s gradient-checking recipe knows the difference between a bug and a kink.

propertymeansmatrix version (§2.7)why you care
injectiveno two inputs collideker(A)={0}\ker(\mathbf{A}) = \{\mathbf{0}\}; columns independentat most one solution to Ax=b\mathbf{A}\mathbf{x}=\mathbf{b}
surjectiveevery target is reachedIm(A)=Rm\operatorname{Im}(\mathbf{A}) = \mathbb{R}^m; full row rankat least one solution, for every b\mathbf{b}
bijectivebothsquare and invertible; det0\det \neq 0exactly one solution, always
continuousno jumpsthe function is well-behaved enough to optimise
differentiableone tangentgradient descent has something to follow
pch.quizTag Check yourself
  1. A function has an inverse exactly when it is which of these?

    pch.quizShowAnswer

    C — Bijective — Injective alone leaves some targets with no preimage; surjective alone leaves some targets with several. Only both together give a well-defined inverse — which is the condition Chapter 2 turns into matrix invertibility.

  2. ReLU is continuous everywhere but not differentiable at zero. Why not?

    pch.quizShowAnswer

    C — The slope approaching from the left is zero and from the right is one, so the two-sided limit does not exist — There is no jump, so it is continuous. But the difference quotient tends to zero from one side and one from the other, and a derivative is a two-sided limit. Frameworks return zero there by convention.

  3. Sine of x divided by x is undefined at zero, yet its limit there is one. What does that make the discontinuity?

    pch.quizShowAnswer

    A — Removable — defining the value at zero to be one makes it continuous — Both sides approach the same value, so filling in that value repairs it. Contrast the sign function, where the two sides approach different values and no choice of value at zero can help.

  4. For a linear mapping, checking injectivity reduces to what?

    pch.quizShowAnswer

    B — Checking that only the zero vector maps to zero — Linearity turns the all-pairs condition into a single homogeneous system: the kernel is trivial. That collapse is what makes linear algebra computationally tractable.

Exercise 1 – The image is smaller than the codomain

Section titled “Exercise 1 – The image is smaller than the codomain”

Exercise 2 – Injectivity fails when outputs collide

Section titled “Exercise 2 – Injectivity fails when outputs collide”

Exercise 3 – One-sided limits of the sign function

Section titled “Exercise 3 – One-sided limits of the sign function”

Exercise 4 – The difference quotient of ReLU at zero

Section titled “Exercise 4 – The difference quotient of ReLU at zero”

Exercise 5 – Convergence versus a constant gap

Section titled “Exercise 5 – Convergence versus a constant gap”
  • A function is three things — domain, codomain, and a rule giving exactly one output per input.
  • The image can be smaller than the codomain, and that gap is exactly what “no solution to Ax = b” means.
  • Injective — different inputs never collide, so at most one solution exists.
  • Surjective — every element of the codomain is reached, so at least one solution exists for every target.
  • An inverse exists exactly when the function is bijective — the sentence Chapter 2 turns into matrix invertibility.
  • For a linear map, injective means the kernel is trivial, which turns an all-pairs check into one homogeneous system.
  • A limit requires both sides to agree and says nothing about the value at the point.
  • Continuity needs all three conditions: defined, limit exists, and the two are equal.
  • Differentiable implies continuous, never the reverse — ReLU is continuous everywhere and non-differentiable at zero, where frameworks return zero by convention.
  • A corner’s one-sided gap stays constant as h shrinks, while floating-point noise grows — which is how gradient checking distinguishes a kink from a bug.

Next: the derivative rules themselves, derived rather than listed — Single-Variable Calculus Refresher.

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading