Topic

ε, N and δ, with certificates

The definitions of a limit and of continuity ask for a number: an NN for each ε\varepsilon, or a δ\delta for each ε\varepsilon. nFor and deltaFor find one, say why it works for every later term or every nearby point, and hand back a certificate that verifyCertificate rechecks by a different route.

const a = sequence("(2n + 1)/(n + 3)");
const r = a.nFor("1/100");
r.N;        // 498, and r.least is true: 497 does not work
r.reason;   // "the terms rise to the limit for n ≥ 1, so |a(n) − L| never grows from there; …"
verifyCertificate(r.certificate).valid;   // true

const d = deltaFor("x^2", 2, "1/100");
d.delta;    // 249/100000, a δ that works
d.largest;  // [0.00249843…]: the largest one, √4.01 − 2
deltaFor("x^2", 2, "1/100", { delta: "0.003" }).holds;   // false

An N for ε

an→La_n \to L means: for every ε>0\varepsilon > 0 there is an NN with ∣an−L∣<ε|a_n - L| < \varepsilon for all n≥Nn \ge N. Checking terms one at a time can never finish, so the statement about all n≥Nn \ge N needs an argument. Two are used.

A monotone tail. If the terms are proven to rise (or fall) to LL from some index on, then ∣an−L∣|a_n - L| never grows from there, and the first index where it is below ε\varepsilon is the answer. It is found by doubling and bisection, and it is the least NN: the term before it is checked to fail.

A dominating sequence. Otherwise, as for sin⁡(n)/n\sin(n)/n, the asymptotic form of the sequences page gives a bound ∣an−L∣≤C np(log⁡n)mekn|a_n - L| \le C\,n^{p}(\log n)^m e^{kn} that decreases to 0. Past the index where the bound is below ε\varepsilon every term is within ε\varepsilon; the finitely many terms before that are examined one by one, walking back to the last one that fails. If the walk reaches it, the NN is again least.

Sequences with periodic factors, such as (−1)n/n2(-1)^n/n^2, are split into the subsequences n=pm+rn = pm + r first, and the answer is one past the last failing index over all of them.

A δ for ε

ff is continuous at x0x_0 when for every ε>0\varepsilon > 0 there is a δ>0\delta > 0 with ∣f(x)−f(x0)∣<ε|f(x) - f(x_0)| < \varepsilon whenever ∣x−x0∣≤δ|x - x_0| \le \delta. The quantity to control is

ω(δ)=sup⁡∣x−x0∣≤δ∣f(x)−f(x0)∣. \omega(\delta) = \sup_{|x - x_0| \le \delta} |f(x) - f(x_0)| .

Where f′f' is proven to keep one sign on each side of x0x_0, the supremum is at an end of the interval and is computed exactly. Otherwise it is bounded by the certified range of ff and by the mean value theorem, ω(δ)≤δ sup⁡∣f′∣\omega(\delta) \le \delta\,\sup|f'|, whichever is smaller. deltaFor halves δ\delta until ω(δ)<ε\omega(\delta) < \varepsilon.

The largest δ\delta is the distance from x0x_0 to the nearest solution of f(x)=f(x0)±εf(x) = f(x_0) \pm \varepsilon. Those are found with the certified zeros, which are complete on an interval: no solution is missed, so the nearest one really is nearest. For x2x^2 at 2 with ε=1/100\varepsilon = 1/100 it is 4.01−2≈0.0024984\sqrt{4.01} - 2 \approx 0.0024984, slightly less than the ε/4\varepsilon/4 a first estimate suggests.

What the certificate is for

A certificate is a plain record of the claim: the formula, the point or limit, ε\varepsilon, the number found and the argument used. verifyCertificate does not repeat the search. For an NN it recomputes the limit, checks that the certificate's parts are the subsequences of this very sequence (one for each residue class when there is a factor such as (−1)n(-1)^n), proves the monotone direction again or compares the dominating bound with the terms at sampled indices and with ε\varepsilon, finds the index where each tail argument takes over, and tests the inequality at every index from NN up to there, one by one. Only then does it test the failure at N−1N - 1 when NN is claimed least, and the inequality at a spread of later indices. So moving NN before a bump in the terms is caught: for 1/(1+(n−50)2)1/(1 + (n - 50)^2) and ε=12\varepsilon = \tfrac12 the least NN is 52, and a certificate edited to say N=1N = 1 fails at n=49n = 49. A monotone tail is proven; a dominating bound comes from the asymptotic form and the verifier only samples it against the terms, so for that method the replay is a strong check rather than a second proof. For a δ\delta it cuts the interval into cells and checks ∣f(x)−f(x0)∣<ε|f(x) - f(x_0)| < \varepsilon on each by plain interval evaluation, with no derivative and no root-finding. It returns the list of checks and whether all passed, so a wrong answer from either side shows up as a disagreement.

callreturns
a.nFor(ε, { limit, digits = 20 }){ N, least, limit, epsilon, method, reason, certificate }
deltaFor(f, x0, ε), fn(f).deltaFor(x0, ε){ delta, largest, attainedAt, worst, reason, certificate }
deltaFor(f, x0, ε, { delta }){ delta, holds, worst, reason, certificate }: whether that δ works
verifyCertificate(certificate){ valid, checks: [{ check, ok }] }
Try itEdit the code and run it with @ratmath/analytic and Core's R, Rational, RationalInterval in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.
Ctrl/⌘ + Enter runs