Numbers, Inequalities and Absolute Values
This reference lesson covers the number line, interval notation, the rules for solving inequalities and how absolute values describe distance. They are the language of every - argument later in the course, and the same idea shows up in code as "close enough" checks with a tolerance.
The real number line
| Set |
Symbol |
Examples |
Notes |
| Natural numbers |
|
1, 2, 3, … |
counting |
| Integers |
|
…, −2, −1, 0, 1, 2, … |
closed under subtraction |
| Rationals |
|
|
with ; decimals end or repeat |
| Reals |
|
|
every point on the line |
The rationals have gaps: is not a fraction. The reals fill every gap. That is the completeness property: every non-empty set of reals that is bounded above has a least upper bound. Limits, the Intermediate Value Theorem and convergent series all depend on it.
Interval notation
| Notation |
Set |
Picture |
|
|
open: endpoints excluded |
|
|
closed: endpoints included |
|
|
half-open |
|
|
is never included |
|
|
|
|
all of |
|
Rules for inequalities
Rule 4 is the one people forget. To solve a quadratic or rational inequality, move everything to one side, factor, and use a sign chart: the expression can only change sign at its zeros (and at points where it is undefined).
SymPy solves inequalities and reports intervals:
python · try it yourselfimport sympy as sp
x = sp.symbols('x', real=True)
print(sp.solve_univariate_inequality(x**2 - x - 6 < 0, x, relational=False))
print(sp.solve_univariate_inequality((x - 1) / (x + 4) >= 0, x, relational=False))
print(sp.solve_univariate_inequality(sp.Abs(2*x - 5) <= 3, x, relational=False))
Interval.open(-2, 3)
Union(Interval.open(-oo, -4), Interval(1, oo))
Interval(1, 4)
Note the second answer: is excluded because the expression is undefined there, while is included because the fraction equals 0.
Absolute value as distance
| Property |
Statement |
| Product |
|
| Quotient |
() |
| Square root |
|
| Within |
() |
| Outside |
or |
| Triangle inequality |
|
The triangle inequality is the workhorse of limit proofs: if is within of and within of , then is within of . Proof: and ; add them to get , which is by the "within" rule.
python · try it yourselfimport numpy as np
rng = np.random.default_rng(7)
a, b = rng.uniform(-10, 10, 100_000), rng.uniform(-10, 10, 100_000)
gap = np.abs(a) + np.abs(b) - np.abs(a + b)
print("violations:", int(np.sum(gap < 0)))
print("equality cases (same sign) fraction:", round(float(np.mean(gap < 1e-12)), 3))
violations: 0
equality cases (same sign) fraction: 0.5
Equality holds exactly when and have the same sign (or one is 0), which happens for half of the random pairs.
In software
- Tolerance comparisons.
abs(a - b) <= tol is the statement : " lies in the interval ". Floating-point code needs it because exactly. Python's math.isclose combines a relative and an absolute tolerance.
- Bounds and clamping. Range checks (
0 <= i < n), clamp(x, lo, hi) and axis-aligned bounding boxes are interval membership tests, one per axis.
- Error budgets. Numerical code splits a total allowed error into pieces, exactly as the triangle inequality does in proofs.
python · try it yourselfimport math
a = 0.1 + 0.2
print(a == 0.3, abs(a - 0.3))
print(math.isclose(a, 0.3), math.isclose(1e-12, 0.0), math.isclose(1e-12, 0.0, abs_tol=1e-9))
False 5.551115123125783e-17
True False True
A purely relative tolerance never accepts anything as close to 0, so comparisons with 0 need abs_tol. See The Precise Definition of a Limit for how these intervals become and .
Exercises
Exercise 1: A rational inequality
Solve .
Answer
, the interval .
Solution
Do not multiply by (its sign is unknown). Move everything to one side:
Exercise 2: Absolute value inequality
Solve .
Answer
or , i.e. .
Solution
Exercise 3: A bound used in limit proofs
Show that if then , and hence .
Answer
From we get , so , and .
Solution
This is the standard trick for proving : choose .
Exercise 4: Check with code
Test the claim of Exercise 3 on 10 000 random in and print the largest ratio .
Answer
The ratio equals , so its largest value is just under 5 (about 5.0).
Solution
python · try it yourselfimport numpy as np
x = np.random.default_rng(1).uniform(1, 3, 10_000)
ratio = np.abs(x**2 - 4) / np.abs(x - 2)
print(round(float(ratio.max()), 4), bool(ratio.max() < 5))
4.9997 True
Test yourself
What is the solution set of ?
- or
If , which is always true?
Which statement is the triangle inequality?