Rational Endpoint Intervals - Computable Taylor Series #
This file provides computable interval enclosures for transcendental functions using Taylor series with rational coefficients and rigorous remainder bounds.
Main definitions #
ratFactorial- Compute n! as a rationalpow- Compute interval powerabsInterval,maxAbs- Absolute value helpersevalTaylorSeries- Evaluate Taylor polynomial on an intervalexpComputable,sinComputable,cosComputable- Computable transcendental functionssinhComputable,coshComputable- Computable hyperbolic functions
Main theorems #
mem_pow- FTIA for interval powermem_evalTaylorSeries- General FTIA for Taylor seriesmem_expComputable,mem_sinComputable,mem_cosComputable- FTIA for computable functions
Design notes #
All definitions in this file use only rational arithmetic and are fully computable. The proofs connect these to the real-valued functions via Taylor's theorem.
Computable Taylor series helpers #
Compute n! as a Rational
Equations
Instances For
Compute the integer power of an interval using repeated multiplication. This is a simple but correct implementation.
Instances For
Compute the absolute value interval: |I| = [0, max(|lo|, |hi|)] if 0 ∈ I, or [min(|lo|,|hi|), max(|lo|,|hi|)] otherwise
Equations
Instances For
Evaluate Taylor series ∑_{i=0}^{n} c_i * x^i at interval I.
Uses direct interval arithmetic with incremental powers to avoid
recomputing I^i from scratch for each coefficient.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Computable exp via Taylor series #
Taylor coefficients for exp: 1/i! for i = 0, 1, ..., n. Implemented iteratively to avoid repeated factorial recomputation.
Equations
Instances For
Computable exp remainder bound using rational arithmetic. The Lagrange remainder is exp(ξ) * x^{n+1} / (n+1)! where ξ is between 0 and x. We use e < 3, so e^r ≤ 3^(⌈r⌉+1) as a conservative bound.
Returns an interval [-R, R] where R bounds the remainder.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Computable interval enclosure for exp at a single rational point.
Uses argument reduction: exp(q) = exp(q/2^k)^(2^k).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Hull of two intervals: smallest interval containing both.
Instances For
Membership in hull
Computable interval enclosure for exp using Taylor series with monotonicity optimization.
exp(x) = ∑_{i=0}^{n} x^i/i! + R where |R| ≤ exp(|x|) * |x|^{n+1} / (n+1)!
For intervals not crossing 0, we use endpoint evaluation and take the hull, which is tighter than direct Taylor evaluation due to interval widening.
This is fully computable using only rational arithmetic.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Computable sin via Taylor series #
Taylor coefficients for sin: 0, 1, 0, -1/6, 0, 1/120, ...
Equations
Instances For
Computable sin remainder bound. Since |sin^{(k)}(x)| ≤ 1 for all k, x, the remainder is bounded by |x|^{n+1}/(n+1)!
Equations
- One or more equations did not get rendered due to their size.
Instances For
Computable interval enclosure for sin using Taylor series.
sin(x) = ∑_{k=0}^{n/2} (-1)^k x^{2k+1}/(2k+1)! + R where |R| ≤ |x|^{n+1}/(n+1)! since all derivatives of sin are bounded by 1.
We intersect with [-1, 1] for tighter bounds on small intervals.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Computable cos via Taylor series #
Taylor coefficients for cos: 1, 0, -1/2, 0, 1/24, 0, ...
Equations
- LeanCert.Core.IntervalRat.cosTaylorCoeffs n = List.map (fun (i : ℕ) => if i % 2 = 0 then (-1) ^ (i / 2) / LeanCert.Core.IntervalRat.ratFactorial i else 0) (List.range (n + 1))
Instances For
Computable cos remainder bound. Since |cos^{(k)}(x)| ≤ 1 for all k, x, the remainder is bounded by |x|^{n+1}/(n+1)!
Equations
- One or more equations did not get rendered due to their size.
Instances For
Computable interval enclosure for cos using Taylor series.
cos(x) = ∑_{k=0}^{n/2} (-1)^k x^{2k}/(2k)! + R where |R| ≤ |x|^{n+1}/(n+1)! since all derivatives of cos are bounded by 1.
We intersect with [-1, 1] for tighter bounds on small intervals.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Computable sinh and cosh via exp #
Computable interval enclosure for sinh at a single rational point. Uses the definition sinh(q) = (exp(q) - exp(-q)) / 2.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Computable interval enclosure for cosh at a single rational point. Uses the definition cosh(q) = (exp(q) + exp(-q)) / 2.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The lower bound of coshPointComputable is always at least 1.
Computable interval enclosure for sinh using exp with endpoint evaluation.
sinh(x) = (exp(x) - exp(-x)) / 2 Since sinh is strictly monotone increasing, sinh([a,b]) = [sinh(a), sinh(b)]. We use endpoint evaluation for tight bounds.
Equations
Instances For
Computable interval enclosure for cosh using exp with endpoint evaluation.
cosh(x) = (exp(x) + exp(-x)) / 2 cosh has minimum 1 at x = 0, and is symmetric: cosh(-x) = cosh(x).
- cosh is decreasing on (-∞, 0]
- cosh is increasing on [0, ∞)
We use endpoint evaluation with monotonicity for tight bounds.
Equations
- One or more equations did not get rendered due to their size.
Instances For
FTIA for pow #
FTIA for interval power
Helper lemmas for Taylor series membership #
Any x in I has |x| ≤ maxAbs I
Coefficient matching lemmas #
For exp, all iterated derivatives at 0 equal 1.
Helper lemmas for Taylor series membership #
General FTIA for evalTaylorSeries: if coeffs has length n+1, then ∑_{i=0}^{n} coeffs[i] * x^i ∈ evalTaylorSeries coeffs I for x ∈ I.
The exp Taylor polynomial value matches our evalTaylorSeries. The proof shows that our list-based polynomial evaluation produces the same sum as the Finset.sum form used in Mathlib's Taylor theorem.
The sin Taylor polynomial value matches our evalTaylorSeries. Key: iteratedDeriv i sin 0 = 0, 1, 0, -1, 0, 1, ... matches sinTaylorCoeffs.
The cos Taylor polynomial value matches our evalTaylorSeries. Key: iteratedDeriv i cos 0 = 1, 0, -1, 0, 1, 0, ... matches cosTaylorCoeffs.
Taylor remainder micro-lemmas #
Unified Taylor remainder bound for exp: given x ∈ I with r = maxAbs I, the Taylor remainder |exp x - poly(x)| ≤ 3^(⌈r⌉+1) * r^(n+1) / (n+1)!. This encapsulates the domain setup and remainder calculation.
Unified Taylor remainder bound for sin: given x ∈ I with r = maxAbs I, the Taylor remainder |sin x - poly(x)| ≤ r^(n+1) / (n+1)!. Uses the fact that |sin^(k)(x)| ≤ 1 for all k, x.
Unified Taylor remainder bound for cos: given x ∈ I with r = maxAbs I, the Taylor remainder |cos x - poly(x)| ≤ r^(n+1) / (n+1)!. Uses the fact that |cos^(k)(x)| ≤ 1 for all k, x.
FTIA for computable functions #
FTIA for single-point exp: Real.exp q ∈ expPointComputable q n
FTIA for sinComputable: Real.sin x ∈ sinComputable I n for any x ∈ I.
The proof uses the Taylor remainder micro-lemma and the global bound sin ∈ [-1, 1].
FTIA for cosComputable: Real.cos x ∈ cosComputable I n for any x ∈ I.
The proof uses the Taylor remainder micro-lemma and the global bound cos ∈ [-1, 1].
FTIA for sinhPointComputable: Real.sinh q ∈ sinhPointComputable q n
FTIA for coshPointComputable: Real.cosh q ∈ coshPointComputable q n
FTIA for sinhComputable: Real.sinh x ∈ sinhComputable I n for any x ∈ I.
Uses endpoint evaluation and monotonicity of sinh.
FTIA for coshComputable: Real.cosh x ∈ coshComputable I n for any x ∈ I.
Uses endpoint evaluation and monotonicity properties of cosh.
Computable atanh via Taylor series #
For |y| < 1, atanh(y) = y + y³/3 + y⁵/5 + ... We compute this series for y ∈ [-1/3, 1/3] where it converges rapidly.
Taylor coefficients for atanh: 0, 1, 0, 1/3, 0, 1/5, ... atanh(y) = Σ y^(2k+1)/(2k+1) = y + y³/3 + y⁵/5 + ...
Equations
Instances For
Computable atanh remainder bound. For |y| ≤ r < 1, the remainder after n terms is bounded by r^(n+1)/(1 - r²). We use a conservative bound: r^(n+1) / ((n+1) * (1 - r)) for simplicity.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Computable interval enclosure for atanh at a single rational point. Requires |q| < 1 for convergence. For |q| ≤ 1/3, this is very accurate.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The atanh Taylor polynomial membership: the partial sum of atanh coefficients at q is in evalTaylorSeries (atanhTaylorCoeffs n) (singleton q).
Computable ln(2) via atanh #
ln(2) = 2 * atanh(1/3), since: 2 = (1 + 1/3) / (1 - 1/3) = (4/3) / (2/3) So atanh(1/3) = (1/2) * ln(2), giving ln(2) = 2 * atanh(1/3)
Compute ln(2) as an interval using 2 * atanh(1/3). This converges rapidly since atanh series at 1/3 has |y| = 1/3.
Equations
Instances For
FTIA for ln2Computable: Real.log 2 ∈ ln2Computable n. Uses the identity log(2) = 2 * atanh(1/3) from log_via_atanh.
Computable log via argument reduction #
For q > 0, we compute:
- Reduce q to m * 2^k where m ∈ [1/2, 2]
- Compute log(m) = 2 * atanh((m-1)/(m+1)), which has |arg| ≤ 1/3
- Result = log(m) + k * ln(2)
Reduced mantissa m = q * 2^(-k)
Equations
Instances For
Computable log at a single rational point q > 0. Returns log(q) = log(m) + k * ln(2) where m = q * 2^(-k).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Computable interval enclosure for log using endpoint evaluation. Since log is strictly increasing on (0, ∞), we evaluate at endpoints.
Equations
- One or more equations did not get rendered due to their size.
Instances For
FTIA for logPointComputable
FTIA for logComputable: if x ∈ I and I.lo > 0, then log(x) ∈ logComputable I n
Conditional version of mem_logComputable for use in correctness proofs. Requires I.lo > 0 so the log interval is well-defined and monotone.
Computable erf via Taylor series #
Interval containing 2/√π ≈ 1.128379... Used for erf calculations. 2/√π is in (1.128, 1.129).
Equations
- LeanCert.Core.IntervalRat.two_div_sqrt_pi = { lo := 1128 / 1000, hi := 1129 / 1000, le := LeanCert.Core.IntervalRat.two_div_sqrt_pi._proof_1 }
Instances For
Taylor coefficients for erf (without the 2/√π factor): erf(x) = (2/√π) * Σ_{n=0}^∞ (-1)^n * x^(2n+1) / (n! * (2n+1))
So the coefficient of x^k is:
- 0 if k is even
- (-1)^((k-1)/2) / (((k-1)/2)! * k) if k is odd
Equations
- One or more equations did not get rendered due to their size.
Instances For
Computable erf remainder bound. Since |erf^{(k)}(x)| ≤ (2/√π) * 2^k for all x (rough bound), and erf is bounded by 1, we use a combination.
For the Taylor remainder centered at 0, we use: |R_n(x)| ≤ sup|f^{(n+1)}(ξ)| * |x|^{n+1} / (n+1)!
A conservative bound: |erf^{(k)}(x)| ≤ (2/√π) * k! / (k/2)! ≤ 2 * k^{k/2} But since |erf| ≤ 1, we can intersect with [-1, 1].
We use: remainder ≤ 2 * |x|^{n+1} / (n+1)! (very conservative).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Computable interval enclosure for erf at a single rational point. Uses sign-aware global bounds:
q < 0 => erf(q) ∈ [-1, 0]q = 0 => erf(q) = 0q > 0 => erf(q) ∈ [0, 1]
Equations
- One or more equations did not get rendered due to their size.
Instances For
Computable interval enclosure for erf using Taylor series with monotonicity.
erf(x) = (2/√π) * Σ_{n=0}^∞ (-1)^n * x^(2n+1) / (n! * (2n+1))
Since erf is strictly monotone increasing (erf'(x) = (2/√π)e^{-x²} > 0), we use endpoint evaluation: erf([a,b]) ⊆ [erf(a), erf(b)].
We intersect with [-1, 1] for safety.
Instances For
2/√π is in the interval two_div_sqrt_pi. 2/√π ≈ 1.1283791670955126, which is in (1.128, 1.129).
This is a helper theorem for correctness proofs. The computation of erfComputable is independent of this theorem.
The "inner" erf function without the 2/√π factor: erfInner(x) = ∫₀ˣ exp(-t²) dt = (√π/2) * erf(x)
This is the function whose Taylor series coefficients are erfTaylorCoeffs.
Instances For
exp(-x²) is analytic everywhere.
exp(-x²) is analytic on ℝ.
Computable atanh interval via endpoint evaluation #
Computable interval enclosure for atanh using endpoint evaluation. Since atanh is strictly increasing on (-1, 1), we evaluate at endpoints. Requires the interval to be strictly inside (-1, 1); returns a wide fallback otherwise.
Equations
- One or more equations did not get rendered due to their size.
Instances For
FTIA for atanhComputable: if x ∈ I and I ⊂ (-1, 1), then atanh(x) ∈ atanhComputable I n.