Mathematical Foundations

III.2 · Calculus

When does the value at a point agree with its neighbours?

Adjust two pieces until they meet, move a single value away, delete it, or meet a pole and an endpoint — and test the three conditions of continuity at each step.

Test the three conditions of continuity

Value assigned at x = 1

Continuity of f(x) = x² + c (x < 1), m·x (x > 1) at a = 1

Graph of f(x) = x² + c (x < 1), m·x (x > 1) with c = 0, m = 2. At a = 1: f(a) 2, left limit 1, right limit 2. Discontinuities in view at x = 1.

Point
1
Value at a
2
Left limit
1
Right limit
2
f(a) exists
yes
The two-sided limit exists
noThe one-sided limits are not one finite number.
The limit equals f(a)
noNeeds (i) and (ii).
Discontinuities in view
at 1 (jump)

Exact values use =; binary64 approximations use ≈. Undefined values state their reason.

Exceptional case: A jump: the one-sided limits 1 and 2 differ, so condition (ii) fails. Make 1 + c equal m to join the pieces.

(i) f(1)=2\text{(i) } f(1)=2
(ii) lim⁡x→1−f=1,lim⁡x→1+f=2\text{(ii) } \lim_{x\to 1^-}f=1,\quad \lim_{x\to 1^+}f=2
(iii) lim⁡x→1f(x) cannot be compared\text{(iii) }\lim_{x\to 1}f(x)\ \text{cannot be compared}
x2+c∣x=1=1+0=1x^2+c\big|_{x=1}=1+0=1
m x∣x=1=2m\,x\big|_{x=1}=2

(i) Is f(a) defined?

Yes: f(1) = 2.

(i) f(1)=2\text{(i) } f(1)=2

from −2 to 2, up to 2 decimal places

from −2 to 3, up to 2 decimal places

from −2.5 to 2.5, up to 2 decimal places

Change c and m until the pieces meet at x = 1, choose which value f(1) receives, or move the point a. The three conditions update with every change.

The opening function jumps at x=1x=1: the left piece arrives at 1+c=11+c=1 and the right piece leaves from m=2m=2. Raise cc to 11 and the pieces meet. Then choose v and drag the open value at x=1x=1: the limit stays 22 while f(1)f(1) moves, so the function is no longer continuous although its graph has only a single misplaced point.

Intuition: no break where you look

A continuous function can be drawn through the point x=ax=a without lifting the pen. That picture needs three separate things: there must be a point to draw, the curve must arrive at one height from both sides, and that height must be the point itself. Each can fail on its own, and the explorer lets you break each one.

Definition

A function ff is continuous at aa when

  1. f(a)f(a) is defined;
  2. lim⁡x→af(x)\lim_{x\to a}f(x) exists (both one-sided limits exist, are finite and agree);
  3. lim⁡x→af(x)=f(a)\lim_{x\to a}f(x)=f(a).

If aa is an endpoint of the domain, only the side inside the domain is used: ff is continuous from the right at aa when lim⁡x→a+f(x)=f(a)\lim_{x\to a^+}f(x)=f(a). A function is continuous on an interval when it is continuous at every point of it.

Mechanics: what the explorer checks

The opening function is x2+cx^2+c for x<1x<1 and m xm\,x for x>1x>1, with f(1)f(1) taken from the left piece, the right piece, a custom value vv, or left undefined. The inspector shows the three conditions as yes/no rows derived from the exact one-sided limits and the exact value; the verdict names the kind of discontinuity. The global row lists every discontinuity inside the view, so you can compare a statement at one point with a statement about the whole function.

Derivation: when the pieces join

At x=1x=1 the left piece approaches 12+c=1+c1^2+c=1+c and the right piece approaches m⋅1=mm\cdot1=m. Condition 2 holds exactly when

1+c=m.1+c=m.

Condition 3 then requires f(1)f(1) to equal this common value. With the right-piece value f(1)=mf(1)=m, continuity holds exactly when c=m−1c=m-1. With a custom value vv, it also needs v=mv=m.

Worked example

Take c=1c=1, m=2m=2 and set f(1)=0f(1)=0. The left limit is 1+1=21+1=2 and the right limit is 22, so the two-sided limit is 22. But f(1)=0≠2f(1)=0\ne2: condition 3 fails. This is a removable discontinuity: redefining f(1)=2f(1)=2 repairs it without changing any other value.

Replay the worked derivation

(i) Is f(a) defined?

Yes: f(1) = 0.

(i) f(1)=0\text{(i) } f(1)=0
Replay the three conditions for the removable case.

Kinds of discontinuity

  • Removable: the limit exists but f(a)f(a) is missing or different. Redefine one value to repair it.
  • Jump: both one-sided limits exist but differ. No single value can repair it.
  • Infinite: at least one side is unbounded, as for 1/(x−1)1/(x-1) at 11.
  • Oscillating: no one-sided limit exists, as for sin⁡(1/x)\sin(1/x) at 00 (III.1).

At an endpoint, such as x\sqrt x at 00, the missing left side is not a failure: x\sqrt x is continuous from the right there.

Executable reference code

The reference checks the three conditions with exact Fraction limits of polynomial pieces. The NumPy version scans many values of cc at once and measures the jump size ∣1+c−m∣|1+c-m|, which is zero only on the continuous configuration.

code/python/calculus_continuity.py
"""The three conditions of continuity, decided exactly for two polynomial pieces meeting at x = 1 (III.2)."""
from fractions import Fraction as F


def check(c, m, value_at_1):
    """Left piece x**2 + c (x < 1), right piece m*x (x > 1), f(1) = value_at_1 (None = undefined)."""
    left_limit = 1 + c            # polynomial pieces: the one-sided limit is the piece evaluated at 1
    right_limit = m
    defined = value_at_1 is not None
    limit_exists = left_limit == right_limit
    agrees = defined and limit_exists and value_at_1 == left_limit
    return defined, limit_exists, agrees


assert check(F(1), F(2), F(2)) == (True, True, True)       # joined
assert check(F(0), F(2), F(2)) == (True, False, False)     # jump
assert check(F(1), F(2), F(0)) == (True, True, False)      # removable: limit 2, value 0
assert check(F(1), F(2), None) == (False, True, False)     # value missing
code/python/calculus_continuity_numpy.py
"""Scan many configurations at once: the jump |1 + c - m| vanishes only where the pieces join (III.2)."""
import numpy as np

c = np.linspace(-2, 2, 17)                  # steps of 0.25: exactly representable
m = 2.0
jump = np.abs(1 + c - m)
assert np.count_nonzero(jump == 0) == 1 and c[jump == 0][0] == 1.0

# Endpoint: sqrt is continuous from the right at 0; there is no left side in the real domain.
h = np.logspace(-1, -12, 12)
assert np.all(np.diff(np.sqrt(h)) < 0) and np.sqrt(h[-1]) < 1e-5
with np.errstate(invalid="ignore"):
    assert np.isnan(np.sqrt(-h)).all()

Explore

Choose Elsewhere: a = −1 while the pieces still jump: the function is continuous at −1-1 yet discontinuous at 11. Set m=1m=1 and find the cc that joins the pieces. On f(1) undefined, notice that only condition 1 fails. On the endpoint preset, move aa to a negative number and read why the function is not defined there.

Common mistakes

A graph that “looks connected” at screen resolution can hide a missing or moved point. Continuity is a property at a point; one break does not make a function discontinuous everywhere, and one continuous point does not make it continuous everywhere. A function is not discontinuous at points outside its domain — it is simply not defined there; 1/x1/x is continuous on its whole domain.

Numerical considerations

A floating-point test such as abs(f(a+h) - f(a)) < tol cannot certify continuity: a jump smaller than the tolerance passes, and steep continuous functions fail. The explorer uses exact one-sided limits of rational pieces; for sampled data, continuity is a modelling assumption, not something measurements prove.

Engineering and ML connections

Many algorithms assume continuity: bisection (finding a root between a sign change), interpolation, and gradient methods all rely on values that do not jump. Piecewise models — ReLU networks, decision thresholds, clipping — are continuous or discontinuous by design, and that choice affects whether small input changes can produce large output changes.

Exercises

construction

Make the pieces meet

f(x) = x² + c for x < 1 and f(x) = 3x for x ≥ 1. Which c makes f continuous at 1?

construction

Repair a removable discontinuity

h(x) = (x² − 9)/(x − 3) is undefined at 3. Which value h(3) makes h continuous there?

prediction

Which condition fails?

f(1) = 0, but both one-sided limits at 1 equal 2. Which continuity condition fails?

Choose one answer

prediction

An endpoint

Is √x continuous at 0, the left end of its domain?

Choose one answer

prediction

Local versus global

A function is continuous at x = −1 but jumps at x = 1. Is it "continuous"?

Choose one answer

Summary and checkpoints

Continuity at aa needs a value, a limit and their equality. Removable, jump, infinite and oscillating discontinuities fail in different ways. At an endpoint only one side counts. Next, III.3 asks a finer question about the same neighbourhood: how steeply does the function change there?

The map of the book

97 of 97 chapters written · eight Parts

demo Foundation demo Try the live vector example Open as a page

Part I

Mathematical Language

The notation and mental objects everything else uses.

9 of 9 chapters written

  1. I.1 Scalars, quantities, units, powers and roots available
  2. I.2 Coordinates and points available
  3. I.3 Vectors: components, magnitude, and direction reference chapter available
  4. I.4 Algebraic expressions, equations and inequalities available
  5. I.5 Functions as input → transformation → output available
  6. I.6 Essential function families available
  7. I.7 Sets, intervals, and relations available
  8. I.8 Indexed quantities and summation available
  9. I.9 The notation map for ML available

Part II

Linear Algebra

Matrices as transformations: the strongest foundation in the book.

19 of 19 chapters written

  1. II.1 Vector addition and subtraction available
  2. II.2 Scalar multiplication and vector scaling available
  3. II.3 Norms, magnitude, and normalization available
  4. II.4 Dot product, angle, and orthogonality available
  5. II.5 Projection and distance to a direction available
  6. II.6 Linear combinations and span available
  7. II.7 Linear independence, basis, and coordinates available
  8. II.8 Matrices as linear transformations available
  9. II.9 Matrix × vector available
  10. II.10 Matrix × matrix as composition available
  11. II.11 Transpose and orthogonality available
  12. II.12 Determinant: orientation and area/volume scaling available
  13. II.13 Linear systems as intersecting constraints available
  14. II.14 Gaussian elimination and row operations available
  15. II.15 Rank and invertibility available
  16. II.16 Inverse matrices available
  17. II.17 Eigenvalues and eigenvectors available
  18. II.18 Orthogonal bases and least-squares geometry available
  19. II.19 Singular Value Decomposition available

Part III

Calculus

Change, local approximation, and sensitivity made visible.

15 of 15 chapters written

  1. III.1 Limits through approach available
  2. III.2 Continuity and local behavior available
  3. III.3 Derivative as secant → tangent available
  4. III.4 Derivative as rate of change and local linear model available
  5. III.5 Derivative rules available
  6. III.6 Chain rule available
  7. III.7 Multivariable functions and partial derivatives available
  8. III.8 Gradient and directional derivatives available
  9. III.9 Jacobian available
  10. III.10 Computational graphs and automatic differentiation available
  11. III.11 Hessian and curvature available
  12. III.12 Integrals as accumulation available
  13. III.13 Fundamental derivative/integral connection available
  14. III.14 Numerical differentiation available
  15. III.15 Numerical integration available

Part IV

Probability

Uncertainty through sample spaces, evidence, and repetition.

16 of 16 chapters written

  1. IV.1 Random experiments, outcomes, and sample spaces available
  2. IV.2 Events and probability mass available
  3. IV.3 Counting and finite probability where needed available
  4. IV.4 Conditional probability as restricted sample space available
  5. IV.5 Independence available
  6. IV.6 Bayes' theorem as probability-mass update available
  7. IV.7 Random variables available
  8. IV.8 PMF, PDF, and CDF available
  9. IV.9 Bernoulli and Binomial distributions available
  10. IV.10 Uniform and Gaussian distributions available
  11. IV.11 Expectation available
  12. IV.12 Variance and standard deviation available
  13. IV.13 Joint, marginal, and conditional distributions available
  14. IV.14 Covariance and correlation available
  15. IV.15 Law of Large Numbers available
  16. IV.16 Central Limit Theorem available

Part V

Statistics

From observed data to estimates, intervals, and likelihood.

10 of 10 chapters written

  1. V.1 Data summaries: mean, median, mode available
  2. V.2 Spread: variance, standard deviation, robust interpretation available
  3. V.3 Population, sample, and sampling variability available
  4. V.4 Estimators and estimation available
  5. V.5 Confidence intervals through repeated sampling available
  6. V.6 Covariance matrices and multivariate spread available
  7. V.7 Regression fundamentals available
  8. V.8 Likelihood available
  9. V.9 Maximum Likelihood Estimation available
  10. V.10 Maximum A Posteriori estimation available

Part VI

Optimization

Learning as repeated parameter updates governed by an objective.

10 of 10 chapters written

  1. VI.1 Objective functions and optimization landscapes available
  2. VI.2 Local vs global optima and stationary points available
  3. VI.3 Convexity available
  4. VI.4 Gradient descent flagship chapter available
  5. VI.5 Learning rate and convergence behavior available
  6. VI.6 Momentum available
  7. VI.7 Stochastic and mini-batch gradient descent available
  8. VI.8 Adam intuition available
  9. VI.9 Constraints and projected/penalized intuition available
  10. VI.10 Numerical stopping and optimization diagnostics available

Part VII

Information Theory

Logarithms, entropy, and the loss behind token prediction.

8 of 8 chapters written

  1. VII.1 Logarithms and log probabilities in computation available
  2. VII.2 Self-information available
  3. VII.3 Entropy available
  4. VII.4 Cross entropy and negative log-likelihood available
  5. VII.5 KL divergence available
  6. VII.6 Logits and softmax available
  7. VII.7 Numerical stability: log-sum-exp and stable softmax available
  8. VII.8 From token logits to language-model loss available

Part VIII

Numerical Computing

Why equivalent expressions behave differently on real machines.

10 of 10 chapters written

  1. VIII.1 Floating-point representation available
  2. VIII.2 Rounding and representation error available
  3. VIII.3 Error propagation and conditioning available
  4. VIII.4 Catastrophic cancellation available
  5. VIII.5 Overflow and underflow available
  6. VIII.6 Stable algorithms available
  7. VIII.7 Numerical linear algebra realities available
  8. VIII.8 Sparse matrices and sparse structure available
  9. VIII.9 Vectorized computation available
  10. VIII.10 Reproducibility, random seeds, and nondeterminism available