PDEAtlas

10.8. Certified Integration🔗

10.8.1. Certified Quadrature🔗

A quadrature certificate bounds the difference between a proposed value and the integral. Exactness on polynomials and bounds on derivatives control the analytic error; interval evaluation controls the error in computing the finite weighted sum. These two errors add.

Definition10.83
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 13
Reverse dependency previews
Preview
Theorem 10.78
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

A quadrature certificate stores a proposed value of a Bochner interval integral, an explicit error budget, and a proof of the corresponding norm estimate. The certificate is indexed by the ordinary Lean integrand and endpoints, so no symbolic expression type appears in theorem statements.

Its trusted field is

q.\mathrm{sound}:\qquad \left\|\int_a^b f(x)\,dx-q.\mathrm{value}\right\| \leq q.\mathrm{error}.

Lean code for Definition10.83●1 definition
  • structure(3 fields)defined in CAS/Certificate/Quadrature.lean
    complete
    structure CAS.Continuum.QuadratureCert.{u_1} {E : Type u_1} [NormedAddCommGroup E]
      [NormedSpace ℝ E] (f : ℝ → E) (a b : ℝ) : Type u_1
    structure CAS.Continuum.QuadratureCert.{u_1}
      {E : Type u_1} [NormedAddCommGroup E]
      [NormedSpace ℝ E] (f : ℝ → E)
      (a b : ℝ) : Type u_1

    A checked approximation to Mathlib's totalized interval integral of f from a to b.

    The value is an element of E. A decoded floating-point result may be used as the value once its distance to an exact value is bounded, as in replaceValue.

    value : E

    Proposed value of the interval integral.

    error : ℝ

    Certified upper bound for the norm error.

    sound : ‖(∫ (x : ℝ) in a..b, f x) - self.value‖ ≤ self.error

    The error bound for Mathlib's total interval integral.

A complete certificate: Simpson on x^2.

Take f(x)=x^2 on [0,1]. One Simpson panel uses the values at 0, 1/2, and 1, so its exact-real value is

\frac16 f(0)+\frac46 f\left(\frac12\right)+\frac16 f(1) =\frac13.

Because Simpson's rule is exact for every polynomial of degree at most three, its quadrature certificate has:

  • the stored value is 1/3;

  • the stored error is 0;

  • soundness proves \left|\int_0^1x^2\,dx-\frac13\right|\leq0.

The third field is the mathematical content. The first two fields are data that later planners can inspect and combine. Since the integrand is a continuous polynomial, it is also interval integrable; that fact is separate because QuadratureCert itself is stated for Mathlib's totalized interval integral.

For a nonpolynomial integrand, the shape of the object is unchanged. A Simpson or Gauss–Legendre theorem supplies a positive analytic error, and a verified numerical backend may replace the exact-real weighted sum with a computed value by adding a separately proved roundoff error. The final sound field always states one inequality about the original integral.

The first polynomial beyond Simpson's exactness range shows what the error constant measures. For f(x)=x^4 on [0,1],

S(f)=\frac46\frac1{16}+\frac16=\frac5{24}, \qquad \int_0^1x^4\,dx=\frac15, \qquad S(f)-\int_0^1f=\frac1{120}.

Here f^{(4)}=24, so the sharp Simpson bound is 24/2880=1/120, exactly the observed error. The fourth derivative measures the first behavior that the degree-three exactness does not reproduce.

Theorem10.84
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Definition 10.36
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 1✓L∃∀N

If both functions are interval integrable, uniform approximation on [[a,b]] transports through interval integration with error \varepsilon |b-a|. Consequently a quadrature certificate for a finite or symbolic model becomes a certificate for the original integrand, with model and quadrature errors added explicitly.

Lean code for Theorem10.84●2 declarations
  • complete
    theorem CAS.Continuum.QuadratureCert.norm_intervalIntegral_sub_le.{u_1}
      {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {a b : ℝ}
      (c : CAS.Certificate.ApproxCert ℝ E (Set.uIcc a b))
      (hlhs : IntervalIntegrable c.lhs MeasureTheory.volume a b)
      (hrhs : IntervalIntegrable c.rhs MeasureTheory.volume a b) :
      ‖(∫ (x : ℝ) in a..b, c.lhs x) - ∫ (x : ℝ) in a..b, c.rhs x‖ ≤
        c.eps * |b - a|
    theorem CAS.Continuum.QuadratureCert.norm_intervalIntegral_sub_le.{u_1}
      {E : Type u_1} [NormedAddCommGroup E]
      [NormedSpace ℝ E] {a b : ℝ}
      (c :
        CAS.Certificate.ApproxCert ℝ E
          (Set.uIcc a b))
      (hlhs :
        IntervalIntegrable c.lhs
          MeasureTheory.volume a b)
      (hrhs :
        IntervalIntegrable c.rhs
          MeasureTheory.volume a b) :
      ‖(∫ (x : ℝ) in a..b, c.lhs x) -
            ∫ (x : ℝ) in a..b, c.rhs x‖ ≤
        c.eps * |b - a|

    Uniform approximation on the unoriented interval controls the difference of the corresponding interval integrals.

    The IntervalIntegrable hypotheses are needed only to rewrite the integral of the pointwise difference as the difference of the integrals. The estimate itself is the standard Bochner-integral norm bound.

  • complete
    def CAS.Continuum.QuadratureCert.transportApprox.{u_1} {E : Type u_1}
      [NormedAddCommGroup E] [NormedSpace ℝ E] {a b : ℝ}
      (c : CAS.Certificate.ApproxCert ℝ E (Set.uIcc a b))
      (q : CAS.Continuum.QuadratureCert c.rhs a b)
      (hlhs : IntervalIntegrable c.lhs MeasureTheory.volume a b)
      (hrhs : IntervalIntegrable c.rhs MeasureTheory.volume a b) :
      CAS.Continuum.QuadratureCert c.lhs a b
    def CAS.Continuum.QuadratureCert.transportApprox.{u_1}
      {E : Type u_1} [NormedAddCommGroup E]
      [NormedSpace ℝ E] {a b : ℝ}
      (c :
        CAS.Certificate.ApproxCert ℝ E
          (Set.uIcc a b))
      (q :
        CAS.Continuum.QuadratureCert c.rhs a
          b)
      (hlhs :
        IntervalIntegrable c.lhs
          MeasureTheory.volume a b)
      (hrhs :
        IntervalIntegrable c.rhs
          MeasureTheory.volume a b) :
      CAS.Continuum.QuadratureCert c.lhs a b

    Transport a quadrature certificate across a uniformly certified integrand approximation.

    If lhs is uniformly within ε of rhs on [[a,b]], and rhs has a quadrature certificate with error δ, then the same proposed value approximates the integral of lhs with error ε |b-a| + δ.

Proof for Theorem 10.84
uses 0

Integrate the pointwise difference and apply the norm bound for an interval integral. Uniform approximation bounds the integrand norm by \varepsilon, while the integral of that constant over the oriented interval contributes |b-a|. A final triangle inequality adds this model error to the existing quadrature error.

Theorem10.85
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Theorem 10.42
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 0✓L∃∀N

If the scalar integrand is interval integrable and one backend interval contains every value on [[a,b]], its midpoint defines a constant integral model and its radius gives the uniform pointwise error. The resulting certificate has value (b-a)c and error r|b-a|, with no endpoint-order assumption and no backend-specific integration theorem. Exact rational ranges, directed floating-point ranges, Taylor enclosures, and adaptive local ranges therefore share the same analytic bridge.

Lean code for Theorem10.85●2 declarations
  • complete
    theorem CAS.Continuum.QuadratureCert.integral_mem_Icc {f : ℝ → ℝ} {a b : ℝ}
      (q : CAS.Continuum.QuadratureCert f a b) :
      ∫ (x : ℝ) in a..b, f x ∈
        Set.Icc (q.value - q.error) (q.value + q.error)
    theorem CAS.Continuum.QuadratureCert.integral_mem_Icc
      {f : ℝ → ℝ} {a b : ℝ}
      (q :
        CAS.Continuum.QuadratureCert f a b) :
      ∫ (x : ℝ) in a..b, f x ∈
        Set.Icc (q.value - q.error)
          (q.value + q.error)

    For scalar integrands, enclose the totalized interval integral in a conventional closed interval around the proposed value.

  • def CAS.Continuum.QuadratureCert.ofIntervalRange.{u_1} {ι : Type u_1}
      [CAS.Continuum.RealIntervalBackend ι] {f : ℝ → ℝ} {a b : ℝ} (I : ι)
      (hf : IntervalIntegrable f MeasureTheory.volume a b)
      (hencloses :
        ∀ x ∈ Set.uIcc a b,
          CAS.Continuum.RealIntervalBackend.MemReal I (f x)) :
      CAS.Continuum.QuadratureCert f a b
    def CAS.Continuum.QuadratureCert.ofIntervalRange.{u_1}
      {ι : Type u_1}
      [CAS.Continuum.RealIntervalBackend ι]
      {f : ℝ → ℝ} {a b : ℝ} (I : ι)
      (hf :
        IntervalIntegrable f
          MeasureTheory.volume a b)
      (hencloses :
        ∀ x ∈ Set.uIcc a b,
          CAS.Continuum.RealIntervalBackend.MemReal
            I (f x)) :
      CAS.Continuum.QuadratureCert f a b

    Turn a uniform backend interval enclosure of an interval integrable scalar integrand into a quadrature certificate.

    The proposed value is the interval midpoint multiplied by the oriented interval length. The error uses the unoriented length, so the result is valid for either endpoint order.

Proof for Theorem 10.85
uses 0

Write the enclosure as center c and radius r. Interval membership gives |f(x)-c|\leq r uniformly, so integration stability compares f with the constant function c. The constant integral is (b-a)c, and its transported error is r|b-a|.

How the error budget is assembled.

A certificate constructor assembles the error budget in five steps:

  1. prove exactness on a polynomial model or prove a Peano-kernel remainder;

  2. obtain any required derivative bound as an ordinary theorem;

  3. sum local analytic errors when the interval is subdivided;

  4. enclose the finite weighted sum if it is evaluated numerically;

  5. add the proved roundoff radius to the analytic budget.

The quadrature rule chooses nodes and weights. The derivative theorem controls truncation. The numerical backend controls finite evaluation. Keeping those proofs separate makes it possible to replace one backend or one subdivision policy without changing the statement about the integral.

Quadrature rules implemented.

The certificate constructors use four normalized rules, each stored as an exact list of (weight, node) pairs on [0,1]. Each error formula assumes the stated derivative bound and the corresponding C^2 or C^4 regularity on an ordered interval [a,b].

  • Trapezoidal rule: two nodes at \{0, 1\} with weights \{1/2, 1/2\}. Exact for polynomials of degree at most 1. Error on [a,b]: \zeta(b-a)^3/12 where \zeta bounds |f''|.

  • Midpoint rule: one node at 1/2 with weight 1. Exact for polynomials of degree at most 1. Error on [a,b]: \zeta(b-a)^3/24, half the trapezoid constant.

  • Simpson's rule: three nodes at \{0, 1/2, 1\} with weights \{1/6, 4/6, 1/6\}. Exact for polynomials of degree at most 3. The sharp Peano-kernel error on [a,b]: C(b-a)^5/2880 where C bounds |f^{(4)}|.

  • Two-point Gauss–Legendre: two nodes at \{1/2 - 1/(2\sqrt{3}), 1/2 + 1/(2\sqrt{3})\} with weights \{1/2, 1/2\}. With only two nodes it is exact for polynomials of degree at most 3, like Simpson's three-node rule. The sharp Peano-kernel error: C(b-a)^5/4320, which is 2/3 of Simpson's error constant.

The Gauss–Legendre rule has irrational nodes (1/2 \pm \sqrt{3}/6), which are represented exactly in the real-valued QuadratureRule. Numerical evaluation encloses the exact weighted terms by proved intervals. A RationalQuadratureRule, by contrast, has rational nodes.

The Peano kernel approach.

The sharp error constants (1/2880 for Simpson, 1/4320 for Gauss–Legendre) come from the Peano kernel method. For a rule Q that is exact on polynomials of degree at most d and an integrand f \in C^{d+1}[a,b], the integration error equals

\int_a^b f(x)\,dx - Q(f) = \int_a^b K_{d+1}(t) f^{(d+1)}(t)\,dt,

where K_{d+1} is the Peano kernel of order d+1: the functional f \mapsto \int f - Q(f) applied to the truncated power (x-t)_+^d / d!. If K_{d+1} has constant sign, the integral is bounded by \|f^{(d+1)}\|_\infty \cdot \int |K_{d+1}|.

Example: composite Simpson on \int_0^1 e^x\,dx.

First plan the exact-real composite value to analytic tolerance \tau = 10^{-8}. A computed replacement must also fit its evaluation error within the remaining budget before claiming this same total tolerance.

  1. Derivative bound. On [0,1], f^{(4)}(x) = e^x \leq e < 3. Set C = 3.

  2. Error constant. B = C(b-a)^5/2880 = 3/2880 = 1/960.

  3. Panel planning. Solve B/N^4 \leq \tau: N \geq (B/\tau)^{1/4} = (10^8/960)^{1/4} \approx 17.97. The planner rounds up to N = 18: exactly, 960\cdot17^4<10^8\leq960\cdot18^4.

  4. Certificate construction. Build 18 Simpson panels of width 1/18. Summing their sharp errors gives 1/(960\cdot18^4)\approx9.923\times10^{-9}<10^{-8}.

  5. Value computation. The panel-major schedule contains 54 weighted samples, with 2\cdot18+1=37 distinct nodes because adjacent endpoints coincide. A numerical backend must provide enclosures for those samples and their weighted sum; the analytic panel count alone supplies no evaluation precision.

  6. Final certificate. The QuadratureCert stores:

    • value: the midpoint of the weighted-sum enclosure,

    • error: the analytic Simpson error plus the weighted-sum roundoff radius,

    • sound: the proof that |\int_0^1 e^x\,dx - \text{value}| \leq \text{error}.

This final error is at most 10^{-8} only if the certified evaluation radius is at most 10^{-8}-1/(960\cdot18^4). Otherwise, refine the evaluation or replan the analytic mesh with a smaller reserved budget.

Adaptive quadrature and the tree structure.

Composite rules use a fixed number of equal panels, which may be inefficient for integrands with localized difficulty (near-singularities, rapid oscillation). The adaptive framework addresses this with a binary QuadratureTree whose leaves are local certificates and whose branches split an interval at a point. Because soundness depends only on the leaf certificates and their composition, an adaptive algorithm may choose the subdivision by any heuristic, including Richardson extrapolation, derivative estimates, or a priori knowledge of integrand behavior.

Definition10.86
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 6
Reverse dependency previews
Preview
Theorem 10.87
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

A normalized quadrature rule is an ordered list of exact-real weights and nodes in [0,1]. The order remains explicit for verified finite-precision evaluation. Generic definitions transport the rule affinely to any oriented interval, while moment identities characterize exactness independently of a particular numerical backend.

Lean code for Definition10.86●1 definition
  • complete
    abbrev CAS.Continuum.QuadratureRule : Type
    abbrev CAS.Continuum.QuadratureRule : Type

    Exact-real normalized quadrature rule used by the analytic semantics.

Theorem10.87
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Theorem 10.42
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 1✓L∃∀N

The rational algebraic fragment of the shared expression language has a fail-closed exact evaluator. Every successful result is proved equal to the existing real expression semantics. A quadrature rule with rational weights and nodes can therefore sample a symbolic integrand exactly, preserve the ordered rule schedule, and cast term-for-term to the existing transported QuadratureRule. Transcendental nodes, malformed literals, and sampled zero denominators are rejected. Optional finite-precision backends consume the exact table through the same interval and weighted-sum interfaces.

At the expression boundary,

\operatorname{evalRat?}(e,\rho)=\operatorname{some}(q) \quad\Longrightarrow\quad \operatorname{eval}(e,\rho_{\mathbb R})=(q:\mathbb R).

For a successfully compiled rule, casting every rational term preserves the analytic schedule and value:

\operatorname{cast}\!\left(\sum_j w_j e(x_j)\right) =\sum_j (w_j:\mathbb R)\, \operatorname{eval}(e,(x_j:\mathbb R)).

Lean code for Theorem10.87●3 theorems
  • complete
    theorem CAS.Verified.Expr.evalRat?_sound.{u_1} {ι : Type u_1} (ρ : ι → ℚ)
      {expr : CAS.Verified.Expr ι} {q : ℚ}
      (h : CAS.Verified.Expr.evalRat? ρ expr = some q) :
      CAS.Verified.Expr.eval (fun i ↦ ↑(ρ i)) expr = ↑q
    theorem CAS.Verified.Expr.evalRat?_sound.{u_1}
      {ι : Type u_1} (ρ : ι → ℚ)
      {expr : CAS.Verified.Expr ι} {q : ℚ}
      (h :
        CAS.Verified.Expr.evalRat? ρ expr =
          some q) :
      CAS.Verified.Expr.eval (fun i ↦ ↑(ρ i))
          expr =
        ↑q

    If evalRat? ρ expr = some q, then expr evaluates to q in the real environment fun i ↦ (ρ i : ℝ).

  • theorem CAS.Continuum.RationalQuadratureRule.symbolicTermsOn?_sound.{u_1}
      {ι : Type u_1} [DecidableEq ι]
      (rule : CAS.Continuum.RationalQuadratureRule)
      (expr : CAS.Verified.Expr ι) (coordinate : ι) (ρ : ι → ℚ) (a b : ℚ)
      {terms : List (ℚ × ℚ)}
      (hterms : rule.symbolicTermsOn? expr coordinate ρ a b = some terms) :
      List.map CAS.Continuum.rationalPairToReal terms =
        rule.toQuadratureRule.termsOn
          (fun x ↦
            CAS.Verified.Expr.eval
              (Function.update (fun i ↦ ↑(ρ i)) coordinate x) expr)
          ↑a ↑b
    theorem CAS.Continuum.RationalQuadratureRule.symbolicTermsOn?_sound.{u_1}
      {ι : Type u_1} [DecidableEq ι]
      (rule :
        CAS.Continuum.RationalQuadratureRule)
      (expr : CAS.Verified.Expr ι)
      (coordinate : ι) (ρ : ι → ℚ) (a b : ℚ)
      {terms : List (ℚ × ℚ)}
      (hterms :
        rule.symbolicTermsOn? expr coordinate
            ρ a b =
          some terms) :
      List.map
          CAS.Continuum.rationalPairToReal
          terms =
        rule.toQuadratureRule.termsOn
          (fun x ↦
            CAS.Verified.Expr.eval
              (Function.update
                (fun i ↦ ↑(ρ i)) coordinate x)
              expr)
          ↑a ↑b

    Successful symbolic compilation produces exactly the real quadrature table for the expression's real denotation.

  • theorem CAS.Continuum.RationalQuadratureRule.cast_valueOn
      (rule : CAS.Continuum.RationalQuadratureRule) (f : ℚ → ℚ) (g : ℝ → ℝ)
      (a b : ℚ) (hf : ∀ (x : ℚ), g ↑x = ↑(f x)) :
      ↑(rule.valueOn f a b) = rule.toQuadratureRule.valueOn g ↑a ↑b
    theorem CAS.Continuum.RationalQuadratureRule.cast_valueOn
      (rule :
        CAS.Continuum.RationalQuadratureRule)
      (f : ℚ → ℚ) (g : ℝ → ℝ) (a b : ℚ)
      (hf : ∀ (x : ℚ), g ↑x = ↑(f x)) :
      ↑(rule.valueOn f a b) =
        rule.toQuadratureRule.valueOn g ↑a ↑b

    Exact rational rule evaluation casts to QuadratureRule.valueOn of a real function g that agrees with the rational callback f at every rational point.

Proof for Theorem 10.87
uses 0

Prove the rational evaluator correct by structural induction on the algebraic expression, rejecting precisely the division cases with zero denominator. Apply that equality at each rational quadrature node. Casting commutes with the finite products and sum, so the compiled ordered table has the same real weighted value as the analytic rule.

Theorem10.88
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 4
Reverse dependency previews
Preview
Theorem 10.91
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

If a normalized rule has the exact moments through degree d, it exactly integrates every real polynomial of degree at most d. Affine transport preserves this conclusion on arbitrary oriented intervals. Both the three-node Simpson rule and the two-point Gauss–Legendre rule have the exact moments through degree three, hence exactly integrate every cubic and generate zero-error QuadratureCerts.

Lean code for Theorem10.88●3 theorems
  • complete
    theorem CAS.Continuum.QuadratureRule.exactFor_polynomial
      {rule : CAS.Continuum.QuadratureRule} {d : ℕ}
      (hexact : rule.ExactUpTo d) (p : Polynomial ℝ)
      (hdegree : p.natDegree ≤ d) :
      rule.ExactFor fun x ↦ Polynomial.eval x p
    theorem CAS.Continuum.QuadratureRule.exactFor_polynomial
      {rule : CAS.Continuum.QuadratureRule}
      {d : ℕ} (hexact : rule.ExactUpTo d)
      (p : Polynomial ℝ)
      (hdegree : p.natDegree ≤ d) :
      rule.ExactFor fun x ↦
        Polynomial.eval x p

    Exact moments through d imply exactness for every polynomial of degree at most d.

  • complete
    theorem CAS.Continuum.simpsonRule.exactUpTo_three :
      CAS.Continuum.simpsonRule.ExactUpTo 3
    theorem CAS.Continuum.simpsonRule.exactUpTo_three :
      CAS.Continuum.simpsonRule.ExactUpTo 3

    Simpson's rule has the exact normalized moments of degrees zero through three.

  • theorem CAS.Continuum.gaussLegendreTwoRule.exactUpTo_three :
      CAS.Continuum.gaussLegendreTwoRule.ExactUpTo 3
    theorem CAS.Continuum.gaussLegendreTwoRule.exactUpTo_three :
      CAS.Continuum.gaussLegendreTwoRule.ExactUpTo
        3

    The two-point Gauss rule has the exact moments of degrees zero through three.

Proof for Theorem 10.88
uses 0

Expand a polynomial of degree at most d in the monomial basis. Linearity of both integration and the weighted rule reduces exactness to each monomial, where it is exactly the assumed moment identity. Affine substitution transports the normalized-interval result to any oriented interval.

Theorem10.89
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Theorem 10.84
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 1✓L∃∀N

If two scalar integrands differ uniformly by \varepsilon on [[a,b]], their values under a normalized rule differ by at most |b-a|\,V\varepsilon, where V is the sum of the absolute rule weights. This estimate lets a rule that is exact on a nearby model be evaluated on the original integrand while accounting separately for integral-model error and sample-value perturbation.

Lean code for Theorem10.89●2 declarations
  • theorem CAS.Continuum.QuadratureRule.abs_valueOn_sub_le
      (rule : CAS.Continuum.QuadratureRule) {f g : ℝ → ℝ} {a b eps : ℝ}
      (happrox : CAS.Certificate.ApproxOn f g (Set.uIcc a b) eps) :
      |rule.valueOn f a b - rule.valueOn g a b| ≤
        |b - a| * (rule.weightVariation * eps)
    theorem CAS.Continuum.QuadratureRule.abs_valueOn_sub_le
      (rule : CAS.Continuum.QuadratureRule)
      {f g : ℝ → ℝ} {a b eps : ℝ}
      (happrox :
        CAS.Certificate.ApproxOn f g
          (Set.uIcc a b) eps) :
      |rule.valueOn f a b -
            rule.valueOn g a b| ≤
        |b - a| * (rule.weightVariation * eps)

    On an arbitrary oriented interval, perturbing the integrand uniformly by eps perturbs the transported rule value by at most |b-a| * weightVariation * eps.

  • def CAS.Continuum.QuadratureRule.certOfApproxEvaluated
      (rule : CAS.Continuum.QuadratureRule) {a b : ℝ}
      (approx : CAS.Certificate.ApproxCert ℝ ℝ (Set.uIcc a b))
      (hexact : rule.ExactFor fun x ↦ approx.rhs (a + x * (b - a)))
      (hlhs : IntervalIntegrable approx.lhs MeasureTheory.volume a b)
      (hrhs : IntervalIntegrable approx.rhs MeasureTheory.volume a b) :
      CAS.Continuum.QuadratureCert approx.lhs a b
    def CAS.Continuum.QuadratureRule.certOfApproxEvaluated
      (rule : CAS.Continuum.QuadratureRule)
      {a b : ℝ}
      (approx :
        CAS.Certificate.ApproxCert ℝ ℝ
          (Set.uIcc a b))
      (hexact :
        rule.ExactFor fun x ↦
          approx.rhs (a + x * (b - a)))
      (hlhs :
        IntervalIntegrable approx.lhs
          MeasureTheory.volume a b)
      (hrhs :
        IntervalIntegrable approx.rhs
          MeasureTheory.volume a b) :
      CAS.Continuum.QuadratureCert approx.lhs
        a b

    Evaluate a quadrature rule on the original integrand while using an exactly integrated nearby model to prove the analytic error.

    The first error term controls the difference of the two interval integrals. The second controls the difference between rule evaluations at their sampled nodes. A backend may then replace this exact-real sampled value with the midpoint of an enclosing interval through QuadratureCert.replaceValue (or QuadratureCert.replaceValueOfInterval in Core).

Proof for Theorem 10.89
uses 0

At every node, the sample difference is at most \varepsilon. Apply the triangle inequality to the weighted sum, bound each term by |w_j|\varepsilon, and sum to obtain V\varepsilon on the normalized interval. Affine transport contributes the factor |b-a|.

10.8.1.1. Nodes, weights, and degree of exactness🔗

A normalized rule lives on [0,1] and is moved to [a,b] affinely. For the general theory it is simpler to let the nodes sit anywhere on the real line and to integrate against a weight function. A NodalRule is just that: m real nodes x_i and m real weights w_i, with value Q(f)=\sum_i w_i f(x_i). It carries no interval and no weight function of its own. Exactness is a property relative to an interval and a weight, which is what lets one rule be read against several weights, and it is stated with Mathlib's interval integral, so exactness does not assert integrability.

The central number attached to a rule is its degree of exactness, the largest d such that Q(p)=\int_a^b p\,w for every polynomial of degree at most d. The trapezoid and midpoint rules have degree one, Simpson's rule three, and a Gauss rule with n nodes 2n-1. A high degree of exactness is what turns smoothness of f into a small error: if f is close to some polynomial of degree d, a rule exact to degree d can only see the difference.

Definition10.90
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 3
Reverse dependency previews
Preview
Theorem 10.91
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

A nodal rule consists of a size m, nodes x_0,\dots,x_{m-1}\in\mathbb R, and weights w_0,\dots,w_{m-1}\in\mathbb R. It is exact to degree d for the weight w on a..b when

\sum_{i<m} w_i\,p(x_i)=\int_a^b p(x)\,w(x)\,dx \qquad\text{for every real polynomial }p\text{ with }\deg p\le d.

It is positive when every w_i\ge0, and its nodes lie in s when every x_i\in s. A normalized QuadratureRule becomes a nodal rule on [a,b] with nodes a+t_i(b-a) and weights (b-a)w_i.

Lean code for Definition10.90●6 definitions
  • structure(3 fields)defined in CAS/Continuum/Quadrature/NodalRule.lean
    complete
    structure CAS.Continuum.NodalRule : Type
    structure CAS.Continuum.NodalRule : Type

    A quadrature rule given by finitely many real nodes and weights.

    size : ℕ

    The number of nodes.

    node : Fin self.size → ℝ

    The nodes xᵢ.

    weight : Fin self.size → ℝ

    The weights wᵢ.

  • def CAS.Continuum.NodalRule.eval (Q : CAS.Continuum.NodalRule) (f : ℝ → ℝ) :
      ℝ
    def CAS.Continuum.NodalRule.eval
      (Q : CAS.Continuum.NodalRule)
      (f : ℝ → ℝ) : ℝ

    The value ∑ wᵢ f(xᵢ) of the rule on f.

  • def CAS.Continuum.NodalRule.ExactToDegree (Q : CAS.Continuum.NodalRule)
      (a b : ℝ) (w : ℝ → ℝ) (d : ℕ) : Prop
    def CAS.Continuum.NodalRule.ExactToDegree
      (Q : CAS.Continuum.NodalRule) (a b : ℝ)
      (w : ℝ → ℝ) (d : ℕ) : Prop

    The rule integrates every polynomial of degree at most d exactly against w on a..b.

  • def CAS.Continuum.NodalRule.Positive (Q : CAS.Continuum.NodalRule) : Prop
    def CAS.Continuum.NodalRule.Positive
      (Q : CAS.Continuum.NodalRule) : Prop

    All weights are nonnegative. Such rules are called positive quadrature rules.

  • def CAS.Continuum.NodalRule.NodesIn (Q : CAS.Continuum.NodalRule)
      (s : Set ℝ) : Prop
    def CAS.Continuum.NodalRule.NodesIn
      (Q : CAS.Continuum.NodalRule)
      (s : Set ℝ) : Prop

    All nodes lie in s.

  • def CAS.Continuum.QuadratureRule.toNodalRule
      (rule : CAS.Continuum.QuadratureRule) (a b : ℝ) :
      CAS.Continuum.NodalRule
    def CAS.Continuum.QuadratureRule.toNodalRule
      (rule : CAS.Continuum.QuadratureRule)
      (a b : ℝ) : CAS.Continuum.NodalRule

    The normalized rule transported to [a,b], as a nodal rule with nodes a + tᵢ (b - a) and weights (b - a) wᵢ.

Theorem10.91
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Theorem 10.88
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 1✓L∃∀N

For a weight continuous on [[a,b]], a nodal rule is exact to degree d exactly when it integrates the monomials 1,x,\dots,x^d. Exactness moves with the rule under the affine map sending a,b to c,d: if Q is exact to degree n on [a,b] for the pulled-back weight, the transported rule, with nodes mapped and weights scaled by (d-c)/(b-a), is exact to degree n on [c,d] for the original weight. A normalized rule with the moments through degree d is exact to degree d on every interval for the unit weight, and a normalized rule with nonnegative weights is positive on every ordered interval.

Lean code for Theorem10.91●4 theorems
  • complete
    theorem CAS.Continuum.NodalRule.exactToDegree_iff_monomial
      {Q : CAS.Continuum.NodalRule} {a b : ℝ} {w : ℝ → ℝ}
      (hw : ContinuousOn w (Set.uIcc a b)) (d : ℕ) :
      Q.ExactToDegree a b w d ↔ ∀ k ≤ d, Q.ExactFor a b w fun x ↦ x ^ k
    theorem CAS.Continuum.NodalRule.exactToDegree_iff_monomial
      {Q : CAS.Continuum.NodalRule} {a b : ℝ}
      {w : ℝ → ℝ}
      (hw : ContinuousOn w (Set.uIcc a b))
      (d : ℕ) :
      Q.ExactToDegree a b w d ↔
        ∀ k ≤ d,
          Q.ExactFor a b w fun x ↦ x ^ k

    For a continuous weight, exactness to degree d is exactness on the monomials 1, x, …, x^d.

  • complete
    theorem CAS.Continuum.NodalRule.ExactToDegree.transport
      {Q : CAS.Continuum.NodalRule} {a b c d : ℝ} (hab : a ≠ b) {v : ℝ → ℝ}
      {n : ℕ}
      (h :
        Q.ExactToDegree a b
          (fun x ↦ v (CAS.Continuum.NodalRule.transportMap a b c d x)) n) :
      (Q.transport a b c d).ExactToDegree c d v n
    theorem CAS.Continuum.NodalRule.ExactToDegree.transport
      {Q : CAS.Continuum.NodalRule}
      {a b c d : ℝ} (hab : a ≠ b) {v : ℝ → ℝ}
      {n : ℕ}
      (h :
        Q.ExactToDegree a b
          (fun x ↦
            v
              (CAS.Continuum.NodalRule.transportMap
                a b c d x))
          n) :
      (Q.transport a b c d).ExactToDegree c d
        v n

    For a ≠ b, affine transport preserves the degree of exactness, with the weight pulled back along the affine map.

  • complete
    theorem CAS.Continuum.QuadratureRule.toNodalRule_exactToDegree
      {rule : CAS.Continuum.QuadratureRule} {d : ℕ}
      (hexact : rule.ExactUpTo d) (a b : ℝ) :
      (rule.toNodalRule a b).ExactToDegree a b (fun x ↦ 1) d
    theorem CAS.Continuum.QuadratureRule.toNodalRule_exactToDegree
      {rule : CAS.Continuum.QuadratureRule}
      {d : ℕ} (hexact : rule.ExactUpTo d)
      (a b : ℝ) :
      (rule.toNodalRule a b).ExactToDegree a b
        (fun x ↦ 1) d

    Moment exactness through degree d is degree of exactness d of the transported rule for the unit weight.

  • complete
    theorem CAS.Continuum.QuadratureRule.toNodalRule_positive
      {rule : CAS.Continuum.QuadratureRule} {a b : ℝ} (hab : a ≤ b)
      (hpositive : ∀ term ∈ rule.terms, 0 ≤ term.1) :
      (rule.toNodalRule a b).Positive
    theorem CAS.Continuum.QuadratureRule.toNodalRule_positive
      {rule : CAS.Continuum.QuadratureRule}
      {a b : ℝ} (hab : a ≤ b)
      (hpositive :
        ∀ term ∈ rule.terms, 0 ≤ term.1) :
      (rule.toNodalRule a b).Positive

    A rule with nonnegative normalized weights is positive on an ordered interval.

Proof for Theorem 10.91
uses 0

Both sides of the exactness identity are linear in the integrand, so a polynomial written in the monomial basis reduces to its monomials. The continuity of w supplies the integrability that splitting the integral needs. For transport, substitute x=c+(t-a)(d-c)/(b-a): the change of variables formula turns \int_c^d f\,v into (d-c)/(b-a) times an integral over [a,b], and composing a polynomial with an affine map does not raise its degree.

The most direct way to obtain exactness is to integrate an interpolant. Given m distinct nodes, let \ell_i be the Lagrange basis polynomial that is 1 at x_i and 0 at the other nodes, and put w_i=\int_a^b\ell_i\,w. A polynomial p of degree below m equals its interpolant \sum_i p(x_i)\ell_i, so integrating gives Q(p)=\int_a^b p\,w. With equally spaced nodes including both endpoints this is the closed Newton–Cotes family: two points give the trapezoid rule and three give Simpson's rule.

Theorem10.92
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1used by 1✓L∃∀N

Let w be continuous on [[a,b]] and let x_0,\dots,x_{m-1} be m\ge1 distinct nodes. The interpolatory rule with weights w_i=\int_a^b\ell_i\,w is exact to degree m-1. For n\ge2 and a\ne b, the closed Newton–Cotes rule on the nodes a+i(b-a)/(n-1), i=0,\dots,n-1, is exact to degree n-1 for the unit weight; its nodes lie in [a,b] when a\le b, and for n=2 its value is \frac{b-a}2\bigl(f(a)+f(b)\bigr).

Lean code for Theorem10.92●6 declarations
  • theorem CAS.Continuum.NodalRule.interpolatory_exactToDegree {a b : ℝ}
      {w : ℝ → ℝ} (hw : ContinuousOn w (Set.uIcc a b)) {m : ℕ} (hm : 0 < m)
      {x : Fin m → ℝ} (hx : Function.Injective x) :
      (CAS.Continuum.NodalRule.interpolatory a b w hw x).ExactToDegree a b w
        (m - 1)
    theorem CAS.Continuum.NodalRule.interpolatory_exactToDegree
      {a b : ℝ} {w : ℝ → ℝ}
      (hw : ContinuousOn w (Set.uIcc a b))
      {m : ℕ} (hm : 0 < m) {x : Fin m → ℝ}
      (hx : Function.Injective x) :
      (CAS.Continuum.NodalRule.interpolatory a
            b w hw x).ExactToDegree
        a b w (m - 1)

    An interpolatory rule on m ≥ 1 distinct nodes has degree of exactness at least m - 1.

  • theorem CAS.Continuum.newtonCotes_exactToDegree {a b : ℝ} {n : ℕ} (hn : 2 ≤ n) :
      (CAS.Continuum.newtonCotes a b n).ExactToDegree a b (fun x ↦ 1)
        (n - 1)
    theorem CAS.Continuum.newtonCotes_exactToDegree
      {a b : ℝ} {n : ℕ} (hn : 2 ≤ n) :
      (CAS.Continuum.newtonCotes a b
            n).ExactToDegree
        a b (fun x ↦ 1) (n - 1)

    The n-point closed Newton-Cotes rule, n ≥ 2, integrates every polynomial of degree at most n - 1 exactly on [a,b]. On a degenerate interval a = b every weight and every integral is 0.

  • theorem CAS.Continuum.newtonCotes_two_eval {a b : ℝ} (f : ℝ → ℝ) :
      (CAS.Continuum.newtonCotes a b 2).eval f =
        CAS.Continuum.trapezoidRule.valueOn f a b
    theorem CAS.Continuum.newtonCotes_two_eval
      {a b : ℝ} (f : ℝ → ℝ) :
      (CAS.Continuum.newtonCotes a b 2).eval
          f =
        CAS.Continuum.trapezoidRule.valueOn f
          a b

    The two-point closed Newton-Cotes rule is the trapezoidal rule.

  • theorem CAS.Continuum.newtonCotes_nodesIn {a b : ℝ} (hab : a ≤ b) {n : ℕ}
      (hn : 2 ≤ n) : (CAS.Continuum.newtonCotes a b n).NodesIn (Set.Icc a b)
    theorem CAS.Continuum.newtonCotes_nodesIn
      {a b : ℝ} (hab : a ≤ b) {n : ℕ}
      (hn : 2 ≤ n) :
      (CAS.Continuum.newtonCotes a b
            n).NodesIn
        (Set.Icc a b)

    For a ≤ b and n ≥ 2 the equispaced nodes lie in [a,b].

  • def CAS.Continuum.NodalRule.interpolatory (a b : ℝ) (w : ℝ → ℝ)
      (hw : ContinuousOn w (Set.uIcc a b)) {m : ℕ} (x : Fin m → ℝ) :
      CAS.Continuum.NodalRule
    def CAS.Continuum.NodalRule.interpolatory
      (a b : ℝ) (w : ℝ → ℝ)
      (hw : ContinuousOn w (Set.uIcc a b))
      {m : ℕ} (x : Fin m → ℝ) :
      CAS.Continuum.NodalRule

    The interpolatory rule on the nodes x for the weight w on a..b: the weight at xᵢ is the integral of the i-th Lagrange basis polynomial against w.

  • def CAS.Continuum.newtonCotes (a b : ℝ) (n : ℕ) : CAS.Continuum.NodalRule
    def CAS.Continuum.newtonCotes (a b : ℝ)
      (n : ℕ) : CAS.Continuum.NodalRule

    The interpolatory rule on newtonCotesNodes for the unit weight; for n ≥ 2 these are the closed Newton-Cotes nodes on [a,b].

Proof for Theorem 10.92
uses 0

A polynomial of degree below m coincides with its Lagrange interpolant on the m nodes, and the rule applied to it is the integral of that interpolant against w. The Newton–Cotes nodes are distinct because the spacing (b-a)/(n-1) is nonzero. For two nodes the Lagrange basis polynomials are linear and each integrates to (b-a)/2.

Interpolation fixes m weights from m nodes, and the resulting degree m-1 is all that can be said for a general choice of nodes. Simpson's rule does better than its three nodes promise, reaching degree three, because its middle node sits at the symmetric point. Gaussian quadrature asks how far this can go when all the nodes are free.

10.8.1.2. Orthogonal polynomials🔗

Fix a weight w that is continuous and strictly positive on [a,b], a<b. The pairing

\langle p,q\rangle=\int_a^b p(x)\,q(x)\,w(x)\,dx

is an inner product on real polynomials: it is bilinear and symmetric, and \langle p,p\rangle>0 for p\ne0, because a nonzero polynomial has only finitely many zeros, so p^2w is positive on some open subinterval. Orthogonalizing 1,x,x^2,\dots gives one monic polynomial p_n of each degree, orthogonal to every polynomial of lower degree. For the unit weight on [-1,1] these are the monic Legendre polynomials

p_1=x,\qquad p_2=x^2-\tfrac13,\qquad p_3=x^3-\tfrac35x,\qquad p_4=x^4-\tfrac67x^2+\tfrac3{35}.

More generally, a linear functional L on \mathbb R[X] that is positive on nonzero squares defines the inner product \langle p,q\rangle=L(pq). Subtracting the orthogonal projection of X^n onto polynomials of degree below n constructs p_n. Integration against a positive weight is one instance.

Definition10.93
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 3
Reverse dependency previews
Preview
Theorem 10.94
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

Let L:\mathbb R[X]\to\mathbb R be linear with L(q^2)>0 for every q\ne0. The monic orthogonal polynomial p_n of L is monic of degree n and satisfies L(p_nq)=0 for every q with \deg q<n. It is unique: any monic polynomial of degree n with this property equals p_n. For a weight w continuous on [[a,b]] and strictly positive on [a,b], a<b, the functional p\mapsto\int_a^b p\,w is positive on nonzero squares, and its orthogonal polynomials are the ones used for Gaussian quadrature.

Lean code for Definition10.93●7 declarations
  • def CAS.Continuum.orthogonalPolynomial (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive : ∀ (p : Polynomial ℝ), p ≠ 0 → 0 < L (p ^ 2)) (n : ℕ) :
      Polynomial ℝ
    def CAS.Continuum.orthogonalPolynomial
      (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive :
        ∀ (p : Polynomial ℝ),
          p ≠ 0 → 0 < L (p ^ 2))
      (n : ℕ) : Polynomial ℝ

    The monic orthogonal polynomial p_n of L: the monic polynomial of degree n orthogonal to all polynomials of lower degree, chosen from exists_monic_orthogonal.

  • def CAS.Continuum.integralOrthogonalPolynomial (a b : ℝ) (hab : a < b)
      (w : ℝ → ℝ) (hw : ContinuousOn w (Set.uIcc a b))
      (hpositive : ∀ x ∈ Set.Icc a b, 0 < w x) (n : ℕ) : Polynomial ℝ
    def CAS.Continuum.integralOrthogonalPolynomial
      (a b : ℝ) (hab : a < b) (w : ℝ → ℝ)
      (hw : ContinuousOn w (Set.uIcc a b))
      (hpositive : ∀ x ∈ Set.Icc a b, 0 < w x)
      (n : ℕ) : Polynomial ℝ

    The monic orthogonal polynomial of degree n for the functional p ↦ ∫_a^b p w, with w continuous and strictly positive on [a, b] and a < b. For w = 1 on [-1, 1] this is the monic Legendre polynomial.

  • theorem CAS.Continuum.orthogonalPolynomial_orthogonal (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive : ∀ (p : Polynomial ℝ), p ≠ 0 → 0 < L (p ^ 2)) (n : ℕ)
      (q : Polynomial ℝ) (hq : q.degree < ↑n) :
      L (CAS.Continuum.orthogonalPolynomial L hpositive n * q) = 0
    theorem CAS.Continuum.orthogonalPolynomial_orthogonal
      (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive :
        ∀ (p : Polynomial ℝ),
          p ≠ 0 → 0 < L (p ^ 2))
      (n : ℕ) (q : Polynomial ℝ)
      (hq : q.degree < ↑n) :
      L
          (CAS.Continuum.orthogonalPolynomial
              L hpositive n *
            q) =
        0

    L (p_n * q) = 0 for every polynomial q of degree below n.

  • theorem CAS.Continuum.orthogonalPolynomial_unique (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive : ∀ (p : Polynomial ℝ), p ≠ 0 → 0 < L (p ^ 2)) (n : ℕ)
      (p : Polynomial ℝ) (hp : p.Monic) (hdegree : p.degree = ↑n)
      (horth : ∀ (q : Polynomial ℝ), q.degree < ↑n → L (p * q) = 0) :
      p = CAS.Continuum.orthogonalPolynomial L hpositive n
    theorem CAS.Continuum.orthogonalPolynomial_unique
      (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive :
        ∀ (p : Polynomial ℝ),
          p ≠ 0 → 0 < L (p ^ 2))
      (n : ℕ) (p : Polynomial ℝ)
      (hp : p.Monic) (hdegree : p.degree = ↑n)
      (horth :
        ∀ (q : Polynomial ℝ),
          q.degree < ↑n → L (p * q) = 0) :
      p =
        CAS.Continuum.orthogonalPolynomial L
          hpositive n

    A monic polynomial of degree n orthogonal to every polynomial of degree below n equals p_n. The difference has degree below n and is orthogonal to itself, so its square has L-value zero and it vanishes by positivity.

  • theorem CAS.Continuum.exists_monic_orthogonal (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive : ∀ (p : Polynomial ℝ), p ≠ 0 → 0 < L (p ^ 2)) (n : ℕ) :
      ∃ p,
        p.Monic ∧
          p.degree = ↑n ∧
            ∀ (q : Polynomial ℝ), q.degree < ↑n → L (p * q) = 0
    theorem CAS.Continuum.exists_monic_orthogonal
      (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive :
        ∀ (p : Polynomial ℝ),
          p ≠ 0 → 0 < L (p ^ 2))
      (n : ℕ) :
      ∃ p,
        p.Monic ∧
          p.degree = ↑n ∧
            ∀ (q : Polynomial ℝ),
              q.degree < ↑n → L (p * q) = 0

    For every n there is a monic polynomial of degree n with L (p * q) = 0 for every q of degree below n. Take X ^ n minus its orthogonal projection onto the polynomials of degree below n: the difference is monic and orthogonal to every polynomial of degree below n.

  • theorem CAS.Continuum.polynomialIntegral_square_pos {a b : ℝ} (hab : a < b)
      (w : ℝ → ℝ) (hw : ContinuousOn w (Set.uIcc a b))
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x) (p : Polynomial ℝ) (hp : p ≠ 0) :
      0 < (CAS.Continuum.polynomialIntegral a b w hw) (p ^ 2)
    theorem CAS.Continuum.polynomialIntegral_square_pos
      {a b : ℝ} (hab : a < b) (w : ℝ → ℝ)
      (hw : ContinuousOn w (Set.uIcc a b))
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x)
      (p : Polynomial ℝ) (hp : p ≠ 0) :
      0 <
        (CAS.Continuum.polynomialIntegral a b
            w hw)
          (p ^ 2)

    The integral of p ^ 2 against w over [a, b] is strictly positive when a < b, w is continuous and strictly positive on [a, b], and p ≠ 0.

  • def CAS.Continuum.momentInnerCore (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive : ∀ (p : Polynomial ℝ), p ≠ 0 → 0 < L (p ^ 2)) :
      InnerProductSpace.Core ℝ (Polynomial ℝ)
    def CAS.Continuum.momentInnerCore
      (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive :
        ∀ (p : Polynomial ℝ),
          p ≠ 0 → 0 < L (p ^ 2)) :
      InnerProductSpace.Core ℝ (Polynomial ℝ)

    The pairing ⟪p, q⟫ = L (p * q) is an inner product on ℝ[X] when L is positive on nonzero squares.

Uniqueness is short and gets used repeatedly. If p and p_n are both monic of degree n and orthogonal to lower degrees, their difference r has degree below n, so L(r^2)=L(pr)-L(p_nr)=0, and positivity forces r=0. Every identification of a concrete polynomial with p_n goes through this argument.

Orthogonal polynomials satisfy a three-term recurrence. Since xp_{n+1} is monic of degree n+2, the difference xp_{n+1}-p_{n+2} has degree at most n+1, and its expansion in p_0,\dots,p_{n+1} has only two nonzero coefficients: for k<n the coefficient of p_k is proportional to L(xp_{n+1}p_k)=L(p_{n+1}\cdot xp_k), which vanishes because xp_k has degree below n+1.

Theorem10.94
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1used by 0✓L∃∀N

With \alpha_n=L(xp_n^2)/L(p_n^2) and \beta_n=L(xp_{n+1}p_n)/L(p_n^2), the monic orthogonal polynomials of L satisfy p_0=1, p_1=x-\alpha_0, and

p_{n+2}=(x-\alpha_{n+1})\,p_{n+1}-\beta_n\,p_n\qquad(n\ge0).

Moreover \beta_n=L(p_{n+1}^2)/L(p_n^2), so \beta_n>0.

Lean code for Theorem10.94●7 declarations
  • theorem CAS.Continuum.orthogonalPolynomial_recurrence (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive : ∀ (q : Polynomial ℝ), q ≠ 0 → 0 < L (q ^ 2)) (n : ℕ) :
      CAS.Continuum.orthogonalPolynomial L hpositive (n + 2) =
        Polynomial.X *
              CAS.Continuum.orthogonalPolynomial L hpositive (n + 1) -
            Polynomial.C
                (CAS.Continuum.recurrenceAlpha L hpositive (n + 1)) *
              CAS.Continuum.orthogonalPolynomial L hpositive (n + 1) -
          Polynomial.C (CAS.Continuum.recurrenceBeta L hpositive n) *
            CAS.Continuum.orthogonalPolynomial L hpositive n
    theorem CAS.Continuum.orthogonalPolynomial_recurrence
      (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive :
        ∀ (q : Polynomial ℝ),
          q ≠ 0 → 0 < L (q ^ 2))
      (n : ℕ) :
      CAS.Continuum.orthogonalPolynomial L
          hpositive (n + 2) =
        Polynomial.X *
              CAS.Continuum.orthogonalPolynomial
                L hpositive (n + 1) -
            Polynomial.C
                (CAS.Continuum.recurrenceAlpha
                  L hpositive (n + 1)) *
              CAS.Continuum.orthogonalPolynomial
                L hpositive (n + 1) -
          Polynomial.C
              (CAS.Continuum.recurrenceBeta L
                hpositive n) *
            CAS.Continuum.orthogonalPolynomial
              L hpositive n

    p_{n+2} = (X - α_{n+1}) p_{n+1} - β_n p_n. The right side is monic of degree n + 2 and orthogonal to p_{n+1}, to p_n and to every polynomial of degree below n, so orthogonalPolynomial_unique applies.

  • theorem CAS.Continuum.recurrenceBeta_eq_norm_ratio (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive : ∀ (q : Polynomial ℝ), q ≠ 0 → 0 < L (q ^ 2)) (n : ℕ) :
      CAS.Continuum.recurrenceBeta L hpositive n =
        L (CAS.Continuum.orthogonalPolynomial L hpositive (n + 1) ^ 2) /
          L (CAS.Continuum.orthogonalPolynomial L hpositive n ^ 2)
    theorem CAS.Continuum.recurrenceBeta_eq_norm_ratio
      (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive :
        ∀ (q : Polynomial ℝ),
          q ≠ 0 → 0 < L (q ^ 2))
      (n : ℕ) :
      CAS.Continuum.recurrenceBeta L hpositive
          n =
        L
            (CAS.Continuum.orthogonalPolynomial
                L hpositive (n + 1) ^
              2) /
          L
            (CAS.Continuum.orthogonalPolynomial
                L hpositive n ^
              2)

    β_n = L (p_{n+1} ^ 2) / L (p_n ^ 2). Since X p_n - p_{n+1} has degree below n + 1, orthogonality of p_{n+1} gives L (X p_{n+1} p_n) = L (p_{n+1} ^ 2).

  • theorem CAS.Continuum.recurrenceBeta_pos (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive : ∀ (q : Polynomial ℝ), q ≠ 0 → 0 < L (q ^ 2)) (n : ℕ) :
      0 < CAS.Continuum.recurrenceBeta L hpositive n
    theorem CAS.Continuum.recurrenceBeta_pos
      (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive :
        ∀ (q : Polynomial ℝ),
          q ≠ 0 → 0 < L (q ^ 2))
      (n : ℕ) :
      0 <
        CAS.Continuum.recurrenceBeta L
          hpositive n

    β_n > 0, being a ratio of values of L on two nonzero squares.

  • theorem CAS.Continuum.orthogonalPolynomial_zero (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive : ∀ (q : Polynomial ℝ), q ≠ 0 → 0 < L (q ^ 2)) :
      CAS.Continuum.orthogonalPolynomial L hpositive 0 = 1
    theorem CAS.Continuum.orthogonalPolynomial_zero
      (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive :
        ∀ (q : Polynomial ℝ),
          q ≠ 0 → 0 < L (q ^ 2)) :
      CAS.Continuum.orthogonalPolynomial L
          hpositive 0 =
        1

    The monic orthogonal polynomial of degree zero is the constant 1.

  • theorem CAS.Continuum.orthogonalPolynomial_one (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive : ∀ (q : Polynomial ℝ), q ≠ 0 → 0 < L (q ^ 2)) :
      CAS.Continuum.orthogonalPolynomial L hpositive 1 =
        Polynomial.X -
          Polynomial.C (CAS.Continuum.recurrenceAlpha L hpositive 0)
    theorem CAS.Continuum.orthogonalPolynomial_one
      (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive :
        ∀ (q : Polynomial ℝ),
          q ≠ 0 → 0 < L (q ^ 2)) :
      CAS.Continuum.orthogonalPolynomial L
          hpositive 1 =
        Polynomial.X -
          Polynomial.C
            (CAS.Continuum.recurrenceAlpha L
              hpositive 0)

    p_1 = X - α_0, where α_0 = L X / L 1 is the mean of X for the functional L.

  • def CAS.Continuum.recurrenceAlpha (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive : ∀ (q : Polynomial ℝ), q ≠ 0 → 0 < L (q ^ 2)) (n : ℕ) : ℝ
    def CAS.Continuum.recurrenceAlpha
      (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive :
        ∀ (q : Polynomial ℝ),
          q ≠ 0 → 0 < L (q ^ 2))
      (n : ℕ) : ℝ

    The diagonal recurrence coefficient α_n = L (X p_n ^ 2) / L (p_n ^ 2).

  • def CAS.Continuum.recurrenceBeta (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive : ∀ (q : Polynomial ℝ), q ≠ 0 → 0 < L (q ^ 2)) (n : ℕ) : ℝ
    def CAS.Continuum.recurrenceBeta
      (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive :
        ∀ (q : Polynomial ℝ),
          q ≠ 0 → 0 < L (q ^ 2))
      (n : ℕ) : ℝ

    The off-diagonal recurrence coefficient β_n = L (X p_{n+1} p_n) / L (p_n ^ 2).

Proof for Theorem 10.94
uses 0

The right side is monic of degree n+2. It is orthogonal to p_{n+1} by the choice of \alpha_{n+1}, to p_n by the choice of \beta_n, and to every polynomial of degree below n because L(xp_{n+1}p_k)=0 for k<n. Uniqueness identifies it with p_{n+2}. For the second formula, xp_n-p_{n+1} has degree at most n, so orthogonality of p_{n+1} gives L(xp_{n+1}p_n)=L(p_{n+1}^2).

For the unit weight on [-1,1] the symmetry x\mapsto-x makes every \alpha_n vanish. From L(1)=2 and L(p_1^2)=\tfrac23 one gets \beta_0=\tfrac13 and p_2=x^2-\tfrac13; then L(p_2^2)=\tfrac8{45}, \beta_1=\tfrac4{15}, and p_3=x\,p_2-\tfrac4{15}x=x^3-\tfrac35x, as in the Legendre list.

The roots of p_n are the nodes of the Gauss rule, and three facts about them are needed: they are real, simple, and inside (a,b). All three come from one observation. Suppose q divides p_n, say p_n=qr with \deg r<n. Orthogonality gives \int_a^b q\,r^2w=\int_a^b p_n\,r\,w=0. If q had no zero on [a,b] it would have constant sign there, and so would qr^2w, which is not identically zero; the integral could not vanish. So every nonconstant factor of p_n has a root in [a,b].

Theorem10.95
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1used by 1✓L∃∀N

Let w be continuous on [[a,b]] and strictly positive on [a,b], a<b, and let p\ne0 be orthogonal against w to every polynomial of lower degree. Then every nonconstant divisor of p has a root in [a,b], p is squarefree and splits over \mathbb R, and every root of p lies in the open interval (a,b). Consequently the monic orthogonal polynomial p_n has exactly n distinct real roots, all in (a,b), and they can be listed as x_0,\dots,x_{n-1} so that the nodal polynomial \prod_i(x-x_i) equals p_n.

Lean code for Theorem10.95●5 theorems
  • theorem CAS.Continuum.orthogonal_root_mem_Ioo {a b : ℝ} (hab : a < b)
      (w : ℝ → ℝ) (hw : ContinuousOn w (Set.uIcc a b))
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x) (p : Polynomial ℝ) (hp : p ≠ 0)
      (horth :
        ∀ (r : Polynomial ℝ),
          r.degree < p.degree →
            (CAS.Continuum.polynomialIntegral a b w hw) (p * r) = 0)
      {x : ℝ} (hx : p.IsRoot x) : x ∈ Set.Ioo a b
    theorem CAS.Continuum.orthogonal_root_mem_Ioo
      {a b : ℝ} (hab : a < b) (w : ℝ → ℝ)
      (hw : ContinuousOn w (Set.uIcc a b))
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x)
      (p : Polynomial ℝ) (hp : p ≠ 0)
      (horth :
        ∀ (r : Polynomial ℝ),
          r.degree < p.degree →
            (CAS.Continuum.polynomialIntegral
                  a b w hw)
                (p * r) =
              0)
      {x : ℝ} (hx : p.IsRoot x) :
      x ∈ Set.Ioo a b

    Every root of an orthogonal polynomial for a continuous positive weight lies in the open interval (a, b). A root at a would give p = (X - a) * r with ∫ (x - a) r² w = 0, but (x - a) w x is a weight positive on the interior, so this integral is positive. The endpoint b is symmetric.

  • theorem CAS.Continuum.orthogonal_factor_has_root {a b : ℝ} (hab : a < b)
      (w : ℝ → ℝ) (hw : ContinuousOn w (Set.uIcc a b))
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x) (p : Polynomial ℝ) (hp : p ≠ 0)
      (horth :
        ∀ (r : Polynomial ℝ),
          r.degree < p.degree →
            (CAS.Continuum.polynomialIntegral a b w hw) (p * r) = 0)
      (q : Polynomial ℝ) (hq : 0 < q.natDegree) (hqp : q ∣ p) :
      ∃ x ∈ Set.Icc a b, Polynomial.eval x q = 0
    theorem CAS.Continuum.orthogonal_factor_has_root
      {a b : ℝ} (hab : a < b) (w : ℝ → ℝ)
      (hw : ContinuousOn w (Set.uIcc a b))
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x)
      (p : Polynomial ℝ) (hp : p ≠ 0)
      (horth :
        ∀ (r : Polynomial ℝ),
          r.degree < p.degree →
            (CAS.Continuum.polynomialIntegral
                  a b w hw)
                (p * r) =
              0)
      (q : Polynomial ℝ)
      (hq : 0 < q.natDegree) (hqp : q ∣ p) :
      ∃ x ∈ Set.Icc a b,
        Polynomial.eval x q = 0

    Every nonconstant divisor q of an orthogonal polynomial p has a root in [a, b]. Write p = q * r, so deg r < deg p and orthogonality gives ∫ p r w = ∫ q r² w = 0, which polynomialIntegral_mul_square_ne_zero forbids if q has no zero.

  • theorem CAS.Continuum.orthogonal_squarefree (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive : ∀ (q : Polynomial ℝ), q ≠ 0 → 0 < L (q ^ 2))
      (p : Polynomial ℝ) (hp : p ≠ 0)
      (horth : ∀ (r : Polynomial ℝ), r.degree < p.degree → L (p * r) = 0) :
      Squarefree p
    theorem CAS.Continuum.orthogonal_squarefree
      (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (hpositive :
        ∀ (q : Polynomial ℝ),
          q ≠ 0 → 0 < L (q ^ 2))
      (p : Polynomial ℝ) (hp : p ≠ 0)
      (horth :
        ∀ (r : Polynomial ℝ),
          r.degree < p.degree →
            L (p * r) = 0) :
      Squarefree p

    A polynomial p ≠ 0 orthogonal to all polynomials of lower degree, for a functional positive on nonzero squares, is squarefree. If p = q ^ 2 * r with q nonconstant then L ((q * r) ^ 2) = L (p * r) = 0, contradicting positivity.

  • theorem CAS.Continuum.orthogonal_splits {a b : ℝ} (hab : a < b) (w : ℝ → ℝ)
      (hw : ContinuousOn w (Set.uIcc a b))
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x) (p : Polynomial ℝ) (hp : p ≠ 0)
      (horth :
        ∀ (r : Polynomial ℝ),
          r.degree < p.degree →
            (CAS.Continuum.polynomialIntegral a b w hw) (p * r) = 0) :
      p.Splits
    theorem CAS.Continuum.orthogonal_splits {a b : ℝ}
      (hab : a < b) (w : ℝ → ℝ)
      (hw : ContinuousOn w (Set.uIcc a b))
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x)
      (p : Polynomial ℝ) (hp : p ≠ 0)
      (horth :
        ∀ (r : Polynomial ℝ),
          r.degree < p.degree →
            (CAS.Continuum.polynomialIntegral
                  a b w hw)
                (p * r) =
              0) :
      p.Splits

    An orthogonal polynomial for a continuous positive weight on [a, b] splits over ℝ. Every irreducible factor has a root in [a, b] by orthogonal_factor_has_root, hence has degree one.

  • theorem CAS.Continuum.exists_nodes_of_monic_splits_squarefree (p : Polynomial ℝ)
      (hp : p.Monic) (hsplit : p.Splits) (hsquare : Squarefree p) (n : ℕ)
      (hdegree : p.natDegree = n) :
      ∃ nodes,
        Function.Injective nodes ∧
          (∀ (i : Fin n), p.IsRoot (nodes i)) ∧
            Lagrange.nodal Finset.univ nodes = p
    theorem CAS.Continuum.exists_nodes_of_monic_splits_squarefree
      (p : Polynomial ℝ) (hp : p.Monic)
      (hsplit : p.Splits)
      (hsquare : Squarefree p) (n : ℕ)
      (hdegree : p.natDegree = n) :
      ∃ nodes,
        Function.Injective nodes ∧
          (∀ (i : Fin n),
              p.IsRoot (nodes i)) ∧
            Lagrange.nodal Finset.univ nodes =
              p

    A monic polynomial p of degree n that splits over ℝ and is squarefree has n distinct roots: some injective nodes : Fin n → ℝ consists of roots of p and has nodal polynomial equal to p itself.

Proof for Theorem 10.95
uses 0

The divisor statement is the sign argument for \int_a^b q\,r^2w. An irreducible real factor of degree two has no real root, so it cannot divide p, and p splits. If q^2 divides p with q nonconstant, write p=q^2r; then L((qr)^2)=L(p\,r)=0, contradicting positivity, so p is squarefree. A root at the endpoint a would give p=(x-a)r with \int_a^b(x-a)\,r^2w=0, but (x-a)w is a weight that is positive on the interior; the endpoint b is symmetric. A monic squarefree polynomial that splits is the product of x-x_i over its distinct roots.

nodes and weightsn = 1n = 2n = 3n = 4n = 5n = 6n = 7n = 8-101the Legendre polynomialx-11P1P2P3P4P5P6P7P8-101
Gauss-Legendre nodes as the number of points grows. Left: the nodes of the \(n\)-point Gauss-Legendre rule on \([-1,1]\) for \(n=1,\dots,8\). The area of each disc is proportional to its weight; the weights of a row are positive and add up to \(2\). The nodes crowd toward the endpoints, where the weights are smallest, and the nodes of consecutive rows interlace. Right: the Legendre polynomial \(P_n\), normalized by \(P_n(1)=1\), for the highlighted row. Its roots are that row's nodes. The animation steps through \(n=1,\dots,8\); the still frame is \(n=5\).

The figure lists the roots of p_n for the Legendre weight, n=1 to 8, and draws P_n, the Legendre polynomial rescaled so that P_n(1)=1, for the highlighted row. The roots stay strictly inside (-1,1), as the theorem requires, and they crowd toward the endpoints as n grows. The disc areas are the Gauss weights constructed next.

10.8.1.3. Gaussian quadrature🔗

The degree of exactness of a rule with n nodes can never reach 2n. The nodal polynomial \omega(x)=\prod_i(x-x_i) has degree n, so \omega^2 has degree 2n; the rule returns \sum_iw_i\omega(x_i)^2=0, while \int_a^b\omega^2w>0. Gauss's theorem says that degree 2n-1 is reached, for one choice of nodes only.

Why must the nodes be the roots of p_n? Suppose a rule with nodes x_i is exact to degree 2n-1. For any q of degree below n the product \omega q has degree below 2n, and it vanishes at every node, so

\int_a^b\omega\,q\,w=Q(\omega q)=\sum_i w_i\,\omega(x_i)\,q(x_i)=0.

Thus \omega is monic of degree n and orthogonal to all lower degrees, and uniqueness forces \omega=p_n. Conversely, take the nodes to be the roots of p_n and the weights interpolatory. Any p of degree below 2n divides as p=p_nq+r with \deg q,\deg r<n. The rule sees only r, since p_n vanishes at the nodes, and it integrates r exactly; the integral sees only r as well, since \int p_nq\,w=0. So Q(p)=\int_a^b p\,w.

Theorem10.96
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Theorem 10.92
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
Used by 2
Reverse dependency previews
Preview
Definition 10.97
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

Let w be continuous on [[a,b]] and strictly positive on [a,b], a<b, and let n\ge1. There are n distinct nodes in (a,b) whose interpolatory weights w_i=\int_a^b\ell_i\,w are all strictly positive and for which

\sum_{i<n}w_i\,p(x_i)=\int_a^b p(x)\,w(x)\,dx\qquad\text{whenever }\deg p<2n.

As a NodalRule, the rule is positive, has its nodes in [a,b], and is exact to degree 2n-1.

Lean code for Theorem10.96●5 theorems
  • theorem CAS.Continuum.exists_gaussian_quadrature {a b : ℝ} (hab : a < b)
      (w : ℝ → ℝ) (hw : ContinuousOn w (Set.uIcc a b))
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x) (n : ℕ) (hn : 0 < n) :
      ∃ nodes,
        Function.Injective nodes ∧
          (∀ (i : Fin n), nodes i ∈ Set.Ioo a b) ∧
            (∀ (i : Fin n),
                0 <
                  CAS.Continuum.interpolatoryWeight
                    (CAS.Continuum.polynomialIntegral a b w hw) nodes i) ∧
              ∀ (p : Polynomial ℝ),
                p.natDegree < 2 * n →
                  CAS.Continuum.interpolatoryValue
                      (CAS.Continuum.polynomialIntegral a b w hw) nodes p =
                    (CAS.Continuum.polynomialIntegral a b w hw) p
    theorem CAS.Continuum.exists_gaussian_quadrature
      {a b : ℝ} (hab : a < b) (w : ℝ → ℝ)
      (hw : ContinuousOn w (Set.uIcc a b))
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x)
      (n : ℕ) (hn : 0 < n) :
      ∃ nodes,
        Function.Injective nodes ∧
          (∀ (i : Fin n),
              nodes i ∈ Set.Ioo a b) ∧
            (∀ (i : Fin n),
                0 <
                  CAS.Continuum.interpolatoryWeight
                    (CAS.Continuum.polynomialIntegral
                      a b w hw)
                    nodes i) ∧
              ∀ (p : Polynomial ℝ),
                p.natDegree < 2 * n →
                  CAS.Continuum.interpolatoryValue
                      (CAS.Continuum.polynomialIntegral
                        a b w hw)
                      nodes p =
                    (CAS.Continuum.polynomialIntegral
                        a b w hw)
                      p

    Gaussian quadrature with n > 0 nodes exists for every continuous strictly positive weight on [a, b], a < b: n distinct nodes in (a, b), positive weights, and exactness against w for every polynomial of degree below 2n. The nodes are the roots of the monic orthogonal polynomial p_n and the weights the Christoffel numbers.

  • theorem CAS.Continuum.exists_nodalRule_gaussian {a b : ℝ} (hab : a < b)
      {w : ℝ → ℝ} (hw : ContinuousOn w (Set.uIcc a b))
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x) {n : ℕ} (hn : 0 < n) :
      ∃ Q,
        Q.size = n ∧
          Q.Positive ∧
            Q.NodesIn (Set.Ioo a b) ∧ Q.ExactToDegree a b w (2 * n - 1)
    theorem CAS.Continuum.exists_nodalRule_gaussian
      {a b : ℝ} (hab : a < b) {w : ℝ → ℝ}
      (hw : ContinuousOn w (Set.uIcc a b))
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x)
      {n : ℕ} (hn : 0 < n) :
      ∃ Q,
        Q.size = n ∧
          Q.Positive ∧
            Q.NodesIn (Set.Ioo a b) ∧
              Q.ExactToDegree a b w
                (2 * n - 1)

    Gaussian quadrature. For a continuous positive weight w on [a,b], a < b, and n ≥ 1, there is a positive rule with n nodes, all in (a,b), that integrates every polynomial of degree at most 2n - 1 exactly against w.

  • theorem CAS.Continuum.gaussian_exact {n : ℕ} (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (nodes : Fin n → ℝ) (hnodes : Function.Injective nodes)
      (horth :
        ∀ (q : Polynomial ℝ),
          q.natDegree < n → L (Lagrange.nodal Finset.univ nodes * q) = 0)
      (p : Polynomial ℝ) (hp : p.natDegree < 2 * n) :
      CAS.Continuum.interpolatoryValue L nodes p = L p
    theorem CAS.Continuum.gaussian_exact {n : ℕ}
      (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (nodes : Fin n → ℝ)
      (hnodes : Function.Injective nodes)
      (horth :
        ∀ (q : Polynomial ℝ),
          q.natDegree < n →
            L
                (Lagrange.nodal Finset.univ
                    nodes *
                  q) =
              0)
      (p : Polynomial ℝ)
      (hp : p.natDegree < 2 * n) :
      CAS.Continuum.interpolatoryValue L nodes
          p =
        L p

    If L vanishes on the nodal polynomial times every polynomial of degree below n, the interpolatory rule is exact for p.natDegree < 2n (through degree 2n - 1 when n > 0). Divide p by the nodal polynomial: the quotient term is killed by L and by the rule, and interpolatory_exact handles the remainder.

  • theorem CAS.Continuum.gaussian_weight_pos {n : ℕ} (hn : 0 < n)
      (L : Polynomial ℝ →ₗ[ℝ] ℝ) (nodes : Fin n → ℝ)
      (hnodes : Function.Injective nodes)
      (horth :
        ∀ (q : Polynomial ℝ),
          q.natDegree < n → L (Lagrange.nodal Finset.univ nodes * q) = 0)
      (hpositive : ∀ (p : Polynomial ℝ), p ≠ 0 → 0 < L (p ^ 2))
      (i : Fin n) : 0 < CAS.Continuum.interpolatoryWeight L nodes i
    theorem CAS.Continuum.gaussian_weight_pos {n : ℕ}
      (hn : 0 < n) (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (nodes : Fin n → ℝ)
      (hnodes : Function.Injective nodes)
      (horth :
        ∀ (q : Polynomial ℝ),
          q.natDegree < n →
            L
                (Lagrange.nodal Finset.univ
                    nodes *
                  q) =
              0)
      (hpositive :
        ∀ (p : Polynomial ℝ),
          p ≠ 0 → 0 < L (p ^ 2))
      (i : Fin n) :
      0 <
        CAS.Continuum.interpolatoryWeight L
          nodes i

    Under the orthogonality hypothesis of gaussian_exact, if L (p ^ 2) > 0 for every p ≠ 0 then every interpolatory weight is strictly positive. Apply exactness to the square of the ith cardinal polynomial, which has degree 2n - 2 and picks out the weight i.

  • theorem CAS.Continuum.interpolatory_exact {n : ℕ} (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (nodes : Fin n → ℝ) (hnodes : Function.Injective nodes)
      (p : Polynomial ℝ) (hp : p.degree < ↑n) :
      CAS.Continuum.interpolatoryValue L nodes p = L p
    theorem CAS.Continuum.interpolatory_exact {n : ℕ}
      (L : Polynomial ℝ →ₗ[ℝ] ℝ)
      (nodes : Fin n → ℝ)
      (hnodes : Function.Injective nodes)
      (p : Polynomial ℝ)
      (hp : p.degree < ↑n) :
      CAS.Continuum.interpolatoryValue L nodes
          p =
        L p

    For n distinct nodes the interpolatory rule reproduces L p whenever deg p < n. Such a p equals its own Lagrange interpolant.

Proof for Theorem 10.96
uses 0

Take the nodes to be the roots of p_n. The interpolatory rule on n distinct nodes reproduces every polynomial of degree below n. For \deg p<2n, divide by the monic nodal polynomial: the quotient term is annihilated by the rule, because the nodal polynomial vanishes at the nodes, and by the integral, by orthogonality; the remainder has degree below n. For the weights, apply exactness to \ell_i^2, which has degree 2n-2: the rule returns w_i, and the integral \int_a^b\ell_i^2w is positive.

The nodes determine the weights, and the weights are positive. This positivity will give convergence for continuous integrands.

Definition10.97
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1used by 1✓L∃∀N

A Gaussian rule with n nodes for the weight w on [a,b] is a structure GaussianRule a b w hw n, where hw records that w is continuous on [[a,b]]. It holds nodes x_0,\dots,x_{n-1}, weights w_0,\dots,w_{n-1}, and four facts: the nodes are pairwise distinct, they lie in the open interval (a,b), the weights are strictly positive, and

\sum_{i<n}w_i\,p(x_i)=\int_a^b p(x)\,w(x)\,dx\qquad\text{whenever }\deg p<2n.

Its value on a function f is \sum_iw_if(x_i). For n=0 the rule is empty and the exactness field says nothing, so the theorems about Gaussian rules assume n>0.

Lean code for Definition10.97●2 definitions
  • complete
    structure CAS.Continuum.GaussianRule (a b : ℝ) (w : ℝ → ℝ)
      (hw : ContinuousOn w (Set.uIcc a b)) (n : ℕ) : Type
    structure CAS.Continuum.GaussianRule (a b : ℝ)
      (w : ℝ → ℝ)
      (hw : ContinuousOn w (Set.uIcc a b))
      (n : ℕ) : Type

    A Gaussian rule on [a, b] for the weight w: n distinct nodes in (a, b), positive weights, and exactness against w for every polynomial of degree below 2n.

    nodes : Fin n → ℝ

    The points where the rule evaluates its integrand.

    weights : Fin n → ℝ

    The coefficient multiplying the integrand at each node.

    injective : Function.Injective self.nodes

    The nodes are pairwise distinct, so the Lagrange basis and the Hermite interpolant on them exist.

    interior : ∀ (i : Fin n), self.nodes i ∈ Set.Ioo a b

    Every node lies in the open interval (a, b), where the integrand is sampled.

    positive : ∀ (i : Fin n), 0 < self.weights i

    Every weight is strictly positive, which makes the rule stable under uniform perturbation of the integrand.

    exact : ∀ (p : Polynomial ℝ),
      p.natDegree < 2 * n →
        ∑ i, self.weights i * Polynomial.eval (self.nodes i) p = (CAS.Continuum.polynomialIntegral a b w hw) p

    The rule integrates every polynomial of degree below 2n exactly against w: ∑ i, weights i * p (nodes i) = ∫_a^b p w.

  • def CAS.Continuum.GaussianRule.value {a b : ℝ} {w : ℝ → ℝ}
      {hw : ContinuousOn w (Set.uIcc a b)} {n : ℕ}
      (rule : CAS.Continuum.GaussianRule a b w hw n) (f : ℝ → ℝ) : ℝ
    def CAS.Continuum.GaussianRule.value {a b : ℝ}
      {w : ℝ → ℝ}
      {hw : ContinuousOn w (Set.uIcc a b)}
      {n : ℕ}
      (rule :
        CAS.Continuum.GaussianRule a b w hw n)
      (f : ℝ → ℝ) : ℝ

    The rule applied to a real function f: the sum over the nodes of the weight times the value of f at that node.

Distinct nodes give the Lagrange and Hermite interpolants behind the characterization and the remainder formula. Interior nodes let a bound that holds on [a,b] be applied at every node, and positive weights turn such a bound into the stability and convergence estimates.

Definition10.98
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Theorem 10.96
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
Used by 3
Reverse dependency previews
Preview
Theorem 10.99
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

For a<b, a weight that is strictly positive on [a,b], and n>0, gaussianRule is the Gaussian rule of the existence theorem, with nodes at the roots of p_n and interpolatory weights. Every Gaussian rule with n>0 is a positive NodalRule exact to degree 2n-1. Exactness on the constant 1 makes its weights add up to \int_a^b w, so each weight is at most \int_a^b w.

Lean code for Definition10.98●4 declarations
  • def CAS.Continuum.gaussianRule {a b : ℝ} (hab : a < b) (w : ℝ → ℝ)
      (hw : ContinuousOn w (Set.uIcc a b))
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x) (n : ℕ) (hn : 0 < n) :
      CAS.Continuum.GaussianRule a b w hw n
    def CAS.Continuum.gaussianRule {a b : ℝ}
      (hab : a < b) (w : ℝ → ℝ)
      (hw : ContinuousOn w (Set.uIcc a b))
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x)
      (n : ℕ) (hn : 0 < n) :
      CAS.Continuum.GaussianRule a b w hw n

    The Gaussian rule supplied by exists_gaussian_quadrature: nodes at the roots of the monic orthogonal polynomial p_n, weights the Christoffel numbers.

  • def CAS.Continuum.GaussianRule.toNodalRule {a b : ℝ} {w : ℝ → ℝ}
      {hw : ContinuousOn w (Set.uIcc a b)} {n : ℕ}
      (rule : CAS.Continuum.GaussianRule a b w hw n) :
      CAS.Continuum.NodalRule
    def CAS.Continuum.GaussianRule.toNodalRule
      {a b : ℝ} {w : ℝ → ℝ}
      {hw : ContinuousOn w (Set.uIcc a b)}
      {n : ℕ}
      (rule :
        CAS.Continuum.GaussianRule a b w hw
          n) :
      CAS.Continuum.NodalRule

    A Gaussian rule as a nodal rule.

  • theorem CAS.Continuum.GaussianRule.sum_weights {a b : ℝ} {w : ℝ → ℝ}
      {hw : ContinuousOn w (Set.uIcc a b)} {n : ℕ}
      (rule : CAS.Continuum.GaussianRule a b w hw n) (hn : 0 < n) :
      ∑ i, rule.weights i = (CAS.Continuum.polynomialIntegral a b w hw) 1
    theorem CAS.Continuum.GaussianRule.sum_weights
      {a b : ℝ} {w : ℝ → ℝ}
      {hw : ContinuousOn w (Set.uIcc a b)}
      {n : ℕ}
      (rule :
        CAS.Continuum.GaussianRule a b w hw n)
      (hn : 0 < n) :
      ∑ i, rule.weights i =
        (CAS.Continuum.polynomialIntegral a b
            w hw)
          1

    The weights of a Gaussian rule with n > 0 nodes sum to ∫_a^b w, since the rule is exact on the constant 1.

  • theorem CAS.Continuum.GaussianRule.weight_le_mass {a b : ℝ} {w : ℝ → ℝ}
      {hw : ContinuousOn w (Set.uIcc a b)} {n : ℕ}
      (rule : CAS.Continuum.GaussianRule a b w hw n) (i : Fin n) :
      rule.weights i ≤ (CAS.Continuum.polynomialIntegral a b w hw) 1
    theorem CAS.Continuum.GaussianRule.weight_le_mass
      {a b : ℝ} {w : ℝ → ℝ}
      {hw : ContinuousOn w (Set.uIcc a b)}
      {n : ℕ}
      (rule :
        CAS.Continuum.GaussianRule a b w hw n)
      (i : Fin n) :
      rule.weights i ≤
        (CAS.Continuum.polynomialIntegral a b
            w hw)
          1

    Each weight of a Gaussian rule is at most ∫_a^b w, the sum of all the positive weights.

Theorem10.99
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Definition 10.93
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
Used by 3
Reverse dependency previews
Preview
Theorem 10.100
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

For every Gaussian rule with n nodes for a continuous weight that is strictly positive on [a,b], the nodal polynomial \prod_i(x-x_i) is the monic orthogonal polynomial p_n of w, and the weight at x_i is the interpolatory weight \int_a^b\ell_i\,w, the Christoffel number. A Gaussian rule is therefore unique up to the order of its nodes.

Lean code for Theorem10.99●3 theorems
  • theorem CAS.Continuum.GaussianRule.nodal_eq_integralOrthogonalPolynomial
      {a b : ℝ} {w : ℝ → ℝ} {hw : ContinuousOn w (Set.uIcc a b)} {n : ℕ}
      (rule : CAS.Continuum.GaussianRule a b w hw n) (hab : a < b)
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x) :
      Lagrange.nodal Finset.univ rule.nodes =
        CAS.Continuum.integralOrthogonalPolynomial a b hab w hw hwpos n
    theorem CAS.Continuum.GaussianRule.nodal_eq_integralOrthogonalPolynomial
      {a b : ℝ} {w : ℝ → ℝ}
      {hw : ContinuousOn w (Set.uIcc a b)}
      {n : ℕ}
      (rule :
        CAS.Continuum.GaussianRule a b w hw n)
      (hab : a < b)
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x) :
      Lagrange.nodal Finset.univ rule.nodes =
        CAS.Continuum.integralOrthogonalPolynomial
          a b hab w hw hwpos n

    The nodal polynomial of any Gaussian rule with n nodes for a continuous positive weight is the monic orthogonal polynomial of degree n, by orthogonalPolynomial_unique.

  • theorem CAS.Continuum.GaussianRule.nodal_orthogonal {a b : ℝ} {w : ℝ → ℝ}
      {hw : ContinuousOn w (Set.uIcc a b)} {n : ℕ}
      (rule : CAS.Continuum.GaussianRule a b w hw n) (q : Polynomial ℝ)
      (hq : q.degree < ↑n) :
      (CAS.Continuum.polynomialIntegral a b w hw)
          (Lagrange.nodal Finset.univ rule.nodes * q) =
        0
    theorem CAS.Continuum.GaussianRule.nodal_orthogonal
      {a b : ℝ} {w : ℝ → ℝ}
      {hw : ContinuousOn w (Set.uIcc a b)}
      {n : ℕ}
      (rule :
        CAS.Continuum.GaussianRule a b w hw n)
      (q : Polynomial ℝ)
      (hq : q.degree < ↑n) :
      (CAS.Continuum.polynomialIntegral a b w
            hw)
          (Lagrange.nodal Finset.univ
              rule.nodes *
            q) =
        0

    The nodal polynomial of a Gaussian rule is orthogonal to every polynomial q of degree below n. The product has degree below 2n and vanishes at every node, so its rule value, and hence its integral, is zero.

  • theorem CAS.Continuum.GaussianRule.weights_eq_interpolatoryWeight {a b : ℝ}
      {w : ℝ → ℝ} {hw : ContinuousOn w (Set.uIcc a b)} {n : ℕ}
      (rule : CAS.Continuum.GaussianRule a b w hw n) (hn : 0 < n)
      (i : Fin n) :
      rule.weights i =
        CAS.Continuum.interpolatoryWeight
          (CAS.Continuum.polynomialIntegral a b w hw) rule.nodes i
    theorem CAS.Continuum.GaussianRule.weights_eq_interpolatoryWeight
      {a b : ℝ} {w : ℝ → ℝ}
      {hw : ContinuousOn w (Set.uIcc a b)}
      {n : ℕ}
      (rule :
        CAS.Continuum.GaussianRule a b w hw n)
      (hn : 0 < n) (i : Fin n) :
      rule.weights i =
        CAS.Continuum.interpolatoryWeight
          (CAS.Continuum.polynomialIntegral a
            b w hw)
          rule.nodes i

    The weight of a Gaussian rule at node i is the Christoffel number, the integral of the ith cardinal polynomial. Apply exactness to that cardinal polynomial, of degree n - 1.

Proof for Theorem 10.99
uses 0

The nodal polynomial times any q of degree below n has degree below 2n and vanishes at every node, so its integral is its rule value, zero. Uniqueness of the monic orthogonal polynomial identifies the nodal polynomial. For the weights, apply exactness to \ell_i, which has degree n-1 and takes the value 1 at x_i and 0 at the other nodes.

a degree four integrandx-101integral of p_3 x = 0the degree six squarex-101integral of p_3 squared = 8/175dots: the nodes; the rule value is 0 in both panels
Degree five is exact, degree six is not. The three-point Gauss-Legendre nodes are the roots \(0,\pm\sqrt{3/5}\) of the monic Legendre polynomial \(p_3(x)=x^3-\tfrac35x\). Left: \(p_3(x)\,x\) has degree four and vanishes at every node, so the rule returns zero; orthogonality makes the signed area zero as well, and the rule is right. Every polynomial of degree at most five splits as \(p_3q+r\) with \(q,r\) of degree at most two, so this is the whole argument for exactness. Right: \(p_3^2\) has degree six and also vanishes at the nodes, but its area is \(8/175>0\). No rule with three nodes integrates it, and the same area is the constant in the error formula.

The figure shows both halves of the argument for n=3 and the Legendre weight. On the left, p_3(x)\,x has degree four; the rule returns zero, and orthogonality makes the integral zero too. On the right, p_3^2 has degree six; the rule still returns zero, but the integral is \tfrac8{175}. That positive number reappears as the constant in the error formula.

The error of a Gauss rule is found by comparing f with its Hermite interpolant H, the polynomial of degree below 2n that matches f and f' at the n nodes. The rule is exact on H and cannot tell f from H, so the error is \int_a^b(f-H)\,w. The pointwise remainder is the familiar one for interpolation, with every node counted twice:

f(x)-H(x)=\frac{f^{(2n)}(\eta_x)}{(2n)!}\,\omega(x)^2 \qquad\text{for some }\eta_x\in[a,b].

Because \omega^2w\ge0, a mean-value argument for the integral pulls the derivative out at a single point.

Theorem10.100
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1used by 0✓L∃∀N

Let w be continuous on [[a,b]] and strictly positive on [a,b], a<b, let Q be a Gaussian rule with n\ge1 nodes, and let f\in C^{2n} on [a,b]. There is \xi\in[a,b] with

\int_a^b f(x)\,w(x)\,dx-Q(f) =\frac{f^{(2n)}(\xi)}{(2n)!}\int_a^b \omega(x)^2\,w(x)\,dx,

where \omega=\prod_i(x-x_i) is the nodal polynomial, equal to p_n by the characterization. Here f^{(2n)} is the iterated derivative within [a,b], so smoothness is needed only on the closed interval. If |f^{(2n)}|\le M on [a,b], the error is at most M/(2n)!\,\int_a^bp_n^2w.

Lean code for Theorem10.100●7 declarations
  • theorem CAS.Continuum.GaussianRule.remainder_orthogonal {a b : ℝ} {w : ℝ → ℝ}
      {hw : ContinuousOn w (Set.uIcc a b)} (hab : a < b)
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x) {n : ℕ} (hn : 0 < n)
      (rule : CAS.Continuum.GaussianRule a b w hw n) {f : ℝ → ℝ}
      (hf : ContDiffOn ℝ (2 * ↑n) f (Set.Icc a b)) :
      ∃ ξ ∈ Set.Icc a b,
        (∫ (x : ℝ) in a..b, f x * w x) - rule.value f =
          iteratedDerivWithin (2 * n) f (Set.Icc a b) ξ /
              ↑(2 * n).factorial *
            (CAS.Continuum.polynomialIntegral a b w hw)
              (CAS.Continuum.integralOrthogonalPolynomial a b hab w hw hwpos
                  n ^
                2)
    theorem CAS.Continuum.GaussianRule.remainder_orthogonal
      {a b : ℝ} {w : ℝ → ℝ}
      {hw : ContinuousOn w (Set.uIcc a b)}
      (hab : a < b)
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x)
      {n : ℕ} (hn : 0 < n)
      (rule :
        CAS.Continuum.GaussianRule a b w hw n)
      {f : ℝ → ℝ}
      (hf :
        ContDiffOn ℝ (2 * ↑n) f
          (Set.Icc a b)) :
      ∃ ξ ∈ Set.Icc a b,
        (∫ (x : ℝ) in a..b, f x * w x) -
            rule.value f =
          iteratedDerivWithin (2 * n) f
                (Set.Icc a b) ξ /
              ↑(2 * n).factorial *
            (CAS.Continuum.polynomialIntegral
                a b w hw)
              (CAS.Continuum.integralOrthogonalPolynomial
                  a b hab w hw hwpos n ^
                2)

    The Gaussian remainder with the monic orthogonal polynomial pₙ of w: for a < b, w strictly positive on [a,b], a Gaussian rule Q with n > 0 nodes and f ∈ C^{2n}[a,b] there is ξ ∈ [a,b] with ∫ f w - Q f = f^(2n)(ξ) / (2n)! * ∫ pₙ² w. This is GaussianRule.remainder with the nodal polynomial rewritten as pₙ by GaussianRule.nodal_eq_integralOrthogonalPolynomial.

  • theorem CAS.Continuum.GaussianRule.remainder {a b : ℝ} {w : ℝ → ℝ}
      {hw : ContinuousOn w (Set.uIcc a b)}
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x) {n : ℕ} (hn : 0 < n)
      (rule : CAS.Continuum.GaussianRule a b w hw n) {f : ℝ → ℝ}
      (hf : ContDiffOn ℝ (2 * ↑n) f (Set.Icc a b)) :
      ∃ ξ ∈ Set.Icc a b,
        (∫ (x : ℝ) in a..b, f x * w x) - rule.value f =
          iteratedDerivWithin (2 * n) f (Set.Icc a b) ξ /
              ↑(2 * n).factorial *
            (CAS.Continuum.polynomialIntegral a b w hw)
              (Lagrange.nodal Finset.univ rule.nodes ^ 2)
    theorem CAS.Continuum.GaussianRule.remainder
      {a b : ℝ} {w : ℝ → ℝ}
      {hw : ContinuousOn w (Set.uIcc a b)}
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x)
      {n : ℕ} (hn : 0 < n)
      (rule :
        CAS.Continuum.GaussianRule a b w hw n)
      {f : ℝ → ℝ}
      (hf :
        ContDiffOn ℝ (2 * ↑n) f
          (Set.Icc a b)) :
      ∃ ξ ∈ Set.Icc a b,
        (∫ (x : ℝ) in a..b, f x * w x) -
            rule.value f =
          iteratedDerivWithin (2 * n) f
                (Set.Icc a b) ξ /
              ↑(2 * n).factorial *
            (CAS.Continuum.polynomialIntegral
                a b w hw)
              (Lagrange.nodal Finset.univ
                  rule.nodes ^
                2)

    The Gaussian error formula: for a weight strictly positive on [a, b], a Gaussian rule Q with n > 0 nodes and f ∈ C^{2n}[a, b] there is ξ ∈ [a, b] with ∫ f w - Q f = f^(2n)(ξ) / (2n)! * ∫ P ^ 2 w, where f^(2n) is iteratedDerivWithin (2n) f (Icc a b) and P the nodal polynomial. Only smoothness on the closed interval is needed.

  • theorem CAS.Continuum.GaussianRule.abs_error_le {a b : ℝ} (hab : a < b)
      {w : ℝ → ℝ} {hw : ContinuousOn w (Set.uIcc a b)}
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x) {n : ℕ} (hn : 0 < n)
      (rule : CAS.Continuum.GaussianRule a b w hw n) {f : ℝ → ℝ}
      (hf : ContDiffOn ℝ (2 * ↑n) f (Set.Icc a b)) {M : ℝ}
      (hM :
        ∀ x ∈ Set.Icc a b,
          |iteratedDerivWithin (2 * n) f (Set.Icc a b) x| ≤ M) :
      |(∫ (x : ℝ) in a..b, f x * w x) - rule.value f| ≤
        M / ↑(2 * n).factorial *
          (CAS.Continuum.polynomialIntegral a b w hw)
            (Lagrange.nodal Finset.univ rule.nodes ^ 2)
    theorem CAS.Continuum.GaussianRule.abs_error_le
      {a b : ℝ} (hab : a < b) {w : ℝ → ℝ}
      {hw : ContinuousOn w (Set.uIcc a b)}
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x)
      {n : ℕ} (hn : 0 < n)
      (rule :
        CAS.Continuum.GaussianRule a b w hw n)
      {f : ℝ → ℝ}
      (hf :
        ContDiffOn ℝ (2 * ↑n) f (Set.Icc a b))
      {M : ℝ}
      (hM :
        ∀ x ∈ Set.Icc a b,
          |iteratedDerivWithin (2 * n) f
                (Set.Icc a b) x| ≤
            M) :
      |(∫ (x : ℝ) in a..b, f x * w x) -
            rule.value f| ≤
        M / ↑(2 * n).factorial *
          (CAS.Continuum.polynomialIntegral a
              b w hw)
            (Lagrange.nodal Finset.univ
                rule.nodes ^
              2)

    If |f^(2n)| ≤ M on [a, b] then |∫ f w - Q f| ≤ M / (2n)! * ∫ P ^ 2 w, immediately from remainder.

  • theorem CAS.Continuum.hermite_remainder {a b : ℝ} (hab : a < b) {n : ℕ}
      (hn : 0 < n) (F : ℕ → ℝ → ℝ)
      (hcontinuous : ∀ k < 2 * n, ContinuousOn (F k) (Set.Icc a b))
      (hderiv :
        ∀ k < 2 * n, ∀ z ∈ Set.Ioo a b, HasDerivAt (F k) (F (k + 1) z) z)
      (nodes : Fin n → ℝ) (hnodes : Function.Injective nodes)
      (hmem : ∀ (i : Fin n), nodes i ∈ Set.Icc a b) (x : ℝ)
      (hx : x ∈ Set.Icc a b) :
      ∃ ξ ∈ Set.Icc a b,
        F 0 x -
            Polynomial.eval x
              (CAS.Continuum.hermiteInterpolant nodes
                (fun i ↦ F 0 (nodes i)) fun i ↦ F 1 (nodes i)) =
          F (2 * n) ξ / ↑(2 * n).factorial *
            Polynomial.eval x (Lagrange.nodal Finset.univ nodes) ^ 2
    theorem CAS.Continuum.hermite_remainder {a b : ℝ}
      (hab : a < b) {n : ℕ} (hn : 0 < n)
      (F : ℕ → ℝ → ℝ)
      (hcontinuous :
        ∀ k < 2 * n,
          ContinuousOn (F k) (Set.Icc a b))
      (hderiv :
        ∀ k < 2 * n,
          ∀ z ∈ Set.Ioo a b,
            HasDerivAt (F k) (F (k + 1) z) z)
      (nodes : Fin n → ℝ)
      (hnodes : Function.Injective nodes)
      (hmem :
        ∀ (i : Fin n), nodes i ∈ Set.Icc a b)
      (x : ℝ) (hx : x ∈ Set.Icc a b) :
      ∃ ξ ∈ Set.Icc a b,
        F 0 x -
            Polynomial.eval x
              (CAS.Continuum.hermiteInterpolant
                nodes (fun i ↦ F 0 (nodes i))
                fun i ↦ F 1 (nodes i)) =
          F (2 * n) ξ / ↑(2 * n).factorial *
            Polynomial.eval x
                (Lagrange.nodal Finset.univ
                  nodes) ^
              2

    Pointwise Hermite remainder for a derivative chain F on [a, b] and n distinct nodes there. At every x ∈ [a, b] some ξ ∈ [a, b] satisfies F 0 x - H x = F (2n) ξ / (2n)! * P x ^ 2, with H the Hermite interpolant of F 0, F 1 at the nodes and P the nodal polynomial. At a node both sides vanish. Otherwise G = F 0 - H - c P ^ 2 with c = (F 0 x - H x) / P x ^ 2 has double zeros at the nodes and a zero at x, so exists_derivative_chain_zero_of_double_zeros gives ξ with G^(2n) ξ = 0, and H^(2n) = 0, (P ^ 2)^(2n) = (2n)! unwind this to the claim.

  • def CAS.Continuum.hermiteInterpolant {n : ℕ}
      (nodes values slopes : Fin n → ℝ) : Polynomial ℝ
    def CAS.Continuum.hermiteInterpolant {n : ℕ}
      (nodes values slopes : Fin n → ℝ) :
      Polynomial ℝ

    The Hermite interpolant: the polynomial of degree below 2n with prescribed values and first derivatives at n distinct nodes.

  • theorem CAS.Continuum.exists_derivative_chain_zero_of_double_zeros {a b : ℝ}
      (n : ℕ) (F : ℕ → ℝ → ℝ)
      (hcontinuous : ∀ k < 2 * n, ContinuousOn (F k) (Set.Icc a b))
      (hderiv :
        ∀ k < 2 * n, ∀ z ∈ Set.Ioo a b, HasDerivAt (F k) (F (k + 1) z) z)
      (nodes : Fin n → ℝ) (hnodes : Function.Injective nodes)
      (hmem : ∀ (i : Fin n), nodes i ∈ Set.Icc a b)
      (hzero : ∀ (i : Fin n), F 0 (nodes i) = 0 ∧ F 1 (nodes i) = 0) (x : ℝ)
      (hx : x ∈ Set.Icc a b) (hxne : ∀ (i : Fin n), x ≠ nodes i)
      (hxzero : F 0 x = 0) : ∃ z ∈ Set.Icc a b, F (2 * n) z = 0
    theorem CAS.Continuum.exists_derivative_chain_zero_of_double_zeros
      {a b : ℝ} (n : ℕ) (F : ℕ → ℝ → ℝ)
      (hcontinuous :
        ∀ k < 2 * n,
          ContinuousOn (F k) (Set.Icc a b))
      (hderiv :
        ∀ k < 2 * n,
          ∀ z ∈ Set.Ioo a b,
            HasDerivAt (F k) (F (k + 1) z) z)
      (nodes : Fin n → ℝ)
      (hnodes : Function.Injective nodes)
      (hmem :
        ∀ (i : Fin n), nodes i ∈ Set.Icc a b)
      (hzero :
        ∀ (i : Fin n),
          F 0 (nodes i) = 0 ∧
            F 1 (nodes i) = 0)
      (x : ℝ) (hx : x ∈ Set.Icc a b)
      (hxne : ∀ (i : Fin n), x ≠ nodes i)
      (hxzero : F 0 x = 0) :
      ∃ z ∈ Set.Icc a b, F (2 * n) z = 0

    If F 0 and F 1 vanish at n distinct nodes in [a, b] and F 0 vanishes at one further point x, then F (2n) has a zero in [a, b]. This is the multiset case with each node of multiplicity two and x of multiplicity one, 2n + 1 zeros in all. It is the form used for the Gaussian remainder.

  • theorem CAS.Continuum.integral_eq_value_mul_of_pointwise_image {a b : ℝ}
      (hab : a < b) {r φ d : ℝ → ℝ}
      (hr : IntervalIntegrable r MeasureTheory.volume a b)
      (hφ : IntervalIntegrable φ MeasureTheory.volume a b)
      (hd : ContinuousOn d (Set.Icc a b))
      (hφnonneg : ∀ x ∈ Set.Icc a b, 0 ≤ φ x)
      (hφpos : 0 < ∫ (x : ℝ) in a..b, φ x)
      (himage : ∀ x ∈ Set.Icc a b, ∃ y ∈ Set.Icc a b, r x = d y * φ x) :
      ∃ ξ ∈ Set.Icc a b,
        ∫ (x : ℝ) in a..b, r x = d ξ * ∫ (x : ℝ) in a..b, φ x
    theorem CAS.Continuum.integral_eq_value_mul_of_pointwise_image
      {a b : ℝ} (hab : a < b) {r φ d : ℝ → ℝ}
      (hr :
        IntervalIntegrable r
          MeasureTheory.volume a b)
      (hφ :
        IntervalIntegrable φ
          MeasureTheory.volume a b)
      (hd : ContinuousOn d (Set.Icc a b))
      (hφnonneg : ∀ x ∈ Set.Icc a b, 0 ≤ φ x)
      (hφpos : 0 < ∫ (x : ℝ) in a..b, φ x)
      (himage :
        ∀ x ∈ Set.Icc a b,
          ∃ y ∈ Set.Icc a b,
            r x = d y * φ x) :
      ∃ ξ ∈ Set.Icc a b,
        ∫ (x : ℝ) in a..b, r x =
          d ξ * ∫ (x : ℝ) in a..b, φ x

    If at each x ∈ [a, b] there is y ∈ [a, b] with r x = d y * φ x, then ∫ r = d ξ * ∫ φ for a single ξ ∈ [a, b]. Requires a < b, r and φ integrable on [a, b], d continuous on [a, b], φ ≥ 0 there and ∫ φ > 0. The extrema of d bound ∫ r / ∫ φ, and the intermediate value theorem picks ξ.

Proof for Theorem 10.100
uses 0

Fix x away from the nodes and choose c so that G=f-H-c\,\omega^2 vanishes at x. Then G has double zeros at the n nodes and a simple zero at x, 2n+1 zeros counted with multiplicity. A generalized Rolle theorem, proved for a chain of functions each the derivative of the previous one on the open interval, gives a zero \eta_x of G^{(2n)}. Since H^{(2n)}=0 and (\omega^2)^{(2n)}=(2n)!, this is the pointwise remainder. Multiply by w and integrate. The continuous function f^{(2n)} takes values between its minimum and maximum on [a,b], so the integral of (f-H)w lies between those extremes times \int\omega^2w, and the intermediate value theorem produces \xi. Finally \omega=p_n by the characterization.

For n=2 and the Legendre weight the constant is \int_{-1}^1p_2^2=\tfrac8{45}. Rescaled to an interval of length h, where \int p_2^2 scales by (h/2)^5, the formula gives error f^{(4)}(\xi)\,h^5/4320, the same constant as the sharp two-point Gauss–Legendre certificate, which is proved by a Peano kernel. For n=3 the constant on [-1,1] is \tfrac8{175}/6!=\tfrac1{15750}.

The first four Gauss–Legendre rules have closed forms in radicals. On [-1,1] the one-point rule is the midpoint rule with weight 2, the two-point rule has nodes \pm1/\sqrt3 and weights 1, the three-point rule has nodes 0,\pm\sqrt{3/5} and weights \tfrac89,\tfrac59, and the four-point rule has nodes \pm\sqrt{(15\mp2\sqrt{30})/35} with weights (18\pm\sqrt{30})/36, the larger weight at the inner pair. The library stores them in the normalized convention on [0,1], checks the moments degree by degree, and then identifies each with the orthogonal-polynomial construction.

Theorem10.101
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Theorem 10.88
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 0✓L∃∀N

The normalized three- and four-point Gauss–Legendre rules, written in radicals, are exact through degrees five and seven. Transported to [-1,1], the midpoint rule, the two-point rule, and these two rules are Gaussian rules for the unit weight, and the nodal polynomial of the n-point rule is the monic Legendre polynomial of degree n, defined as the monic orthogonal polynomial of that weight, for n=1,2,3,4. For n=2 and any a<b, every Gaussian rule for the unit weight on [a,b] has the transported two-point nodes and weights and the same value as the two-point QuadratureRule.

Lean code for Theorem10.101●11 declarations
  • theorem CAS.Continuum.Legendre.four_nodal_eq :
      Lagrange.nodal Finset.univ CAS.Continuum.Legendre.fourGaussian.nodes =
        CAS.Continuum.Legendre.monicPolynomial 4
    theorem CAS.Continuum.Legendre.four_nodal_eq :
      Lagrange.nodal Finset.univ
          CAS.Continuum.Legendre.fourGaussian.nodes =
        CAS.Continuum.Legendre.monicPolynomial
          4

    The nodal polynomial of fourGaussian is the monic Legendre polynomial of degree four.

  • theorem CAS.Continuum.Legendre.three_nodal_eq :
      Lagrange.nodal Finset.univ
          CAS.Continuum.Legendre.threeGaussian.nodes =
        CAS.Continuum.Legendre.monicPolynomial 3
    theorem CAS.Continuum.Legendre.three_nodal_eq :
      Lagrange.nodal Finset.univ
          CAS.Continuum.Legendre.threeGaussian.nodes =
        CAS.Continuum.Legendre.monicPolynomial
          3

    The nodal polynomial of threeGaussian is the monic Legendre polynomial of degree three.

  • theorem CAS.Continuum.Legendre.two_nodal_eq :
      Lagrange.nodal Finset.univ CAS.Continuum.Legendre.twoGaussian.nodes =
        CAS.Continuum.Legendre.monicPolynomial 2
    theorem CAS.Continuum.Legendre.two_nodal_eq :
      Lagrange.nodal Finset.univ
          CAS.Continuum.Legendre.twoGaussian.nodes =
        CAS.Continuum.Legendre.monicPolynomial
          2

    The nodal polynomial of twoGaussian is the monic Legendre polynomial of degree two.

  • theorem CAS.Continuum.Legendre.one_nodal_eq :
      Lagrange.nodal Finset.univ CAS.Continuum.Legendre.oneGaussian.nodes =
        CAS.Continuum.Legendre.monicPolynomial 1
    theorem CAS.Continuum.Legendre.one_nodal_eq :
      Lagrange.nodal Finset.univ
          CAS.Continuum.Legendre.oneGaussian.nodes =
        CAS.Continuum.Legendre.monicPolynomial
          1

    The nodal polynomial of oneGaussian is the monic Legendre polynomial of degree one.

  • theorem CAS.Continuum.Legendre.three_exact :
      CAS.Continuum.Legendre.three.ExactUpTo 5
    theorem CAS.Continuum.Legendre.three_exact :
      CAS.Continuum.Legendre.three.ExactUpTo 5

    The three-point rule is exact through degree five.

  • theorem CAS.Continuum.Legendre.four_exact :
      CAS.Continuum.Legendre.four.ExactUpTo 7
    theorem CAS.Continuum.Legendre.four_exact :
      CAS.Continuum.Legendre.four.ExactUpTo 7

    The four-point rule is exact through degree seven.

  • def CAS.Continuum.Legendre.monicPolynomial (n : ℕ) : Polynomial ℝ
    def CAS.Continuum.Legendre.monicPolynomial
      (n : ℕ) : Polynomial ℝ

    The monic Legendre polynomial of degree n, defined as the monic orthogonal polynomial for the constant weight on [-1, 1].

  • def CAS.Continuum.Legendre.threeGaussian : CAS.Continuum.Legendre.Rule 3
    def CAS.Continuum.Legendre.threeGaussian :
      CAS.Continuum.Legendre.Rule 3

    The three-point Gauss-Legendre rule on [-1, 1]: nodes -√(3/5), 0, √(3/5) with weights 5/9, 8/9, 5/9.

  • def CAS.Continuum.Legendre.fourGaussian : CAS.Continuum.Legendre.Rule 4
    def CAS.Continuum.Legendre.fourGaussian :
      CAS.Continuum.Legendre.Rule 4

    The four-point Gauss-Legendre rule on [-1, 1]: nodes ±fourOuter, ±fourInner with weights (18 - √30)/36 on the outer pair and (18 + √30)/36 on the inner pair.

  • theorem CAS.Continuum.GaussianRule.value_eq_gaussLegendreTwoRule_valueOn
      {a b : ℝ} {hw : ContinuousOn (fun x ↦ 1) (Set.uIcc a b)}
      (rule : CAS.Continuum.GaussianRule a b (fun x ↦ 1) hw 2) (f : ℝ → ℝ) :
      rule.value f = CAS.Continuum.gaussLegendreTwoRule.valueOn f a b
    theorem CAS.Continuum.GaussianRule.value_eq_gaussLegendreTwoRule_valueOn
      {a b : ℝ}
      {hw :
        ContinuousOn (fun x ↦ 1)
          (Set.uIcc a b)}
      (rule :
        CAS.Continuum.GaussianRule a b
          (fun x ↦ 1) hw 2)
      (f : ℝ → ℝ) :
      rule.value f =
        CAS.Continuum.gaussLegendreTwoRule.valueOn
          f a b

    A two-node Gaussian rule for the unit weight on [a,b] is the transported two-point Gauss-Legendre rule.

  • theorem CAS.Continuum.GaussianRule.nodes_eq_gaussLegendreTwo {a b : ℝ}
      {hw : ContinuousOn (fun x ↦ 1) (Set.uIcc a b)}
      (rule : CAS.Continuum.GaussianRule a b (fun x ↦ 1) hw 2) (i : Fin 2) :
      rule.nodes i = CAS.Continuum.gaussLegendreTwoLeftPoint a b ∨
        rule.nodes i = CAS.Continuum.gaussLegendreTwoRightPoint a b
    theorem CAS.Continuum.GaussianRule.nodes_eq_gaussLegendreTwo
      {a b : ℝ}
      {hw :
        ContinuousOn (fun x ↦ 1)
          (Set.uIcc a b)}
      (rule :
        CAS.Continuum.GaussianRule a b
          (fun x ↦ 1) hw 2)
      (i : Fin 2) :
      rule.nodes i =
          CAS.Continuum.gaussLegendreTwoLeftPoint
            a b ∨
        rule.nodes i =
          CAS.Continuum.gaussLegendreTwoRightPoint
            a b

    Every node of a two-node Gaussian rule for the unit weight on [a,b] is one of the two Gauss-Legendre points a + (3 ∓ √3)(b - a)/6.

Proof for Theorem 10.101
uses 0

Exactness through degree 2n-1 is a finite list of moment identities, each checked by normal-form arithmetic using (\sqrt{3/5})^2=\tfrac35 or the squares of the four-point radicals. Positivity of the weights and the ordering of the nodes are inequalities between radicals. The characterization theorem then identifies each nodal polynomial with the monic Legendre polynomial, and for n=2 it pins down the nodes, whose weights are then fixed by exactness.

Beyond four points the nodes are no longer convenient radicals, and the library certifies them instead. A sparse rational polynomial p with \int_{-1}^1p\,x^k\,dx=0 for k<n, a condition checked in rational arithmetic from the moments of x^k, is the monic Legendre polynomial of degree n as soon as it is monic of degree n. Its roots are isolated by certified brackets (root brackets): a rational interval with a sign change at the ends and a derivative enclosure of fixed sign, so exactly one root lies inside. Ordered disjoint brackets inside (-1,1) then define a Gaussian rule at any order n, with no stored table of nodes.

Theorem10.102
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 3
Statement dependency previews
Preview
Theorem 10.8
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 1✓L∃∀N

Let p be a sparse rational polynomial and let n valid root brackets for p be ordered, each strictly to the left of the next. The bracketed roots are strictly increasing and lie in their brackets. If p is monic of degree n over \mathbb R, its nodal polynomial on these roots is p itself. If moreover the brackets lie inside (-1,1) and the rational moments \int_{-1}^1p(x)x^k\,dx vanish for k<n, the roots are the nodes of a Gaussian rule for the unit weight on [-1,1], with the interpolatory weights.

Lean code for Theorem10.102●6 declarations
  • theorem CAS.Continuum.Legendre.RootCertificates.nodal_eq {n : ℕ}
      (p : CAS.Polynomial.Sparse.Univariate)
      (brackets : Fin n → CAS.Polynomial.RealRoot.RootBracket)
      (hvalid :
        ∀ (i : Fin n),
          CAS.Polynomial.RealRoot.RootBracket.valid p (brackets i) = true)
      (hordered :
        ∀ (i j : Fin n),
          i < j → (brackets i).interval.hi < (brackets j).interval.lo)
      (hmonic :
        (CAS.Continuum.Legendre.RootCertificates.realPolynomial p).Monic)
      (hdegree :
        (CAS.Continuum.Legendre.RootCertificates.realPolynomial
              p).natDegree =
          n) :
      Lagrange.nodal Finset.univ
          (CAS.Continuum.Legendre.RootCertificates.nodes p brackets
            hvalid) =
        CAS.Continuum.Legendre.RootCertificates.realPolynomial p
    theorem CAS.Continuum.Legendre.RootCertificates.nodal_eq
      {n : ℕ}
      (p : CAS.Polynomial.Sparse.Univariate)
      (brackets :
        Fin n →
          CAS.Polynomial.RealRoot.RootBracket)
      (hvalid :
        ∀ (i : Fin n),
          CAS.Polynomial.RealRoot.RootBracket.valid
              p (brackets i) =
            true)
      (hordered :
        ∀ (i j : Fin n),
          i < j →
            (brackets i).interval.hi <
              (brackets j).interval.lo)
      (hmonic :
        (CAS.Continuum.Legendre.RootCertificates.realPolynomial
            p).Monic)
      (hdegree :
        (CAS.Continuum.Legendre.RootCertificates.realPolynomial
              p).natDegree =
          n) :
      Lagrange.nodal Finset.univ
          (CAS.Continuum.Legendre.RootCertificates.nodes
            p brackets hvalid) =
        CAS.Continuum.Legendre.RootCertificates.realPolynomial
          p

    For n disjoint ordered certified brackets of a monic p of degree n, the nodal polynomial of the nodes is realPolynomial p. Both are monic of degree n and agree at the n distinct nodes.

  • theorem CAS.Continuum.Legendre.RootCertificates.orthogonal_of_shiftedMoments
      (p : CAS.Polynomial.Sparse.Univariate) (n : ℕ)
      (hmoments :
        ∀ k < n,
          CAS.Continuum.Legendre.RootCertificates.shiftedMoment p k = 0)
      (q : Polynomial ℝ) (hq : q.natDegree < n) :
      (CAS.Continuum.polynomialIntegral (-1) 1 (fun x ↦ 1) ⋯)
          (CAS.Continuum.Legendre.RootCertificates.realPolynomial p * q) =
        0
    theorem CAS.Continuum.Legendre.RootCertificates.orthogonal_of_shiftedMoments
      (p : CAS.Polynomial.Sparse.Univariate)
      (n : ℕ)
      (hmoments :
        ∀ k < n,
          CAS.Continuum.Legendre.RootCertificates.shiftedMoment
              p k =
            0)
      (q : Polynomial ℝ)
      (hq : q.natDegree < n) :
      (CAS.Continuum.polynomialIntegral (-1) 1
            (fun x ↦ 1) ⋯)
          (CAS.Continuum.Legendre.RootCertificates.realPolynomial
              p *
            q) =
        0

    If shiftedMoment p k = 0 for all k < n then realPolynomial p is orthogonal on [-1, 1] to every polynomial of degree below n. Expand q in monomials.

  • theorem CAS.Continuum.Legendre.RootCertificates.nodes_mem {n : ℕ}
      (p : CAS.Polynomial.Sparse.Univariate)
      (brackets : Fin n → CAS.Polynomial.RealRoot.RootBracket)
      (hvalid :
        ∀ (i : Fin n),
          CAS.Polynomial.RealRoot.RootBracket.valid p (brackets i) = true)
      (i : Fin n) :
      (brackets i).interval.MemReal
        (CAS.Continuum.Legendre.RootCertificates.nodes p brackets hvalid i)
    theorem CAS.Continuum.Legendre.RootCertificates.nodes_mem
      {n : ℕ}
      (p : CAS.Polynomial.Sparse.Univariate)
      (brackets :
        Fin n →
          CAS.Polynomial.RealRoot.RootBracket)
      (hvalid :
        ∀ (i : Fin n),
          CAS.Polynomial.RealRoot.RootBracket.valid
              p (brackets i) =
            true)
      (i : Fin n) :
      (brackets i).interval.MemReal
        (CAS.Continuum.Legendre.RootCertificates.nodes
          p brackets hvalid i)

    Each node lies in its bracket.

  • theorem CAS.Continuum.Legendre.RootCertificates.nodes_strictMono {n : ℕ}
      (p : CAS.Polynomial.Sparse.Univariate)
      (brackets : Fin n → CAS.Polynomial.RealRoot.RootBracket)
      (hvalid :
        ∀ (i : Fin n),
          CAS.Polynomial.RealRoot.RootBracket.valid p (brackets i) = true)
      (hordered :
        ∀ (i j : Fin n),
          i < j → (brackets i).interval.hi < (brackets j).interval.lo) :
      StrictMono
        (CAS.Continuum.Legendre.RootCertificates.nodes p brackets hvalid)
    theorem CAS.Continuum.Legendre.RootCertificates.nodes_strictMono
      {n : ℕ}
      (p : CAS.Polynomial.Sparse.Univariate)
      (brackets :
        Fin n →
          CAS.Polynomial.RealRoot.RootBracket)
      (hvalid :
        ∀ (i : Fin n),
          CAS.Polynomial.RealRoot.RootBracket.valid
              p (brackets i) =
            true)
      (hordered :
        ∀ (i j : Fin n),
          i < j →
            (brackets i).interval.hi <
              (brackets j).interval.lo) :
      StrictMono
        (CAS.Continuum.Legendre.RootCertificates.nodes
          p brackets hvalid)

    If the brackets are pairwise disjoint and listed in increasing order, the nodes are strictly increasing.

  • def CAS.Continuum.Legendre.RootCertificates.rule {n : ℕ} (hn : 0 < n)
      (p : CAS.Polynomial.Sparse.Univariate)
      (brackets : Fin n → CAS.Polynomial.RealRoot.RootBracket)
      (hvalid :
        ∀ (i : Fin n),
          CAS.Polynomial.RealRoot.RootBracket.valid p (brackets i) = true)
      (hordered :
        ∀ (i j : Fin n),
          i < j → (brackets i).interval.hi < (brackets j).interval.lo)
      (hinterior :
        ∀ (i : Fin n),
          -1 < (brackets i).interval.lo ∧ (brackets i).interval.hi < 1)
      (hmonic :
        (CAS.Continuum.Legendre.RootCertificates.realPolynomial p).Monic)
      (hdegree :
        (CAS.Continuum.Legendre.RootCertificates.realPolynomial
              p).natDegree =
          n)
      (hmoments :
        ∀ k < n,
          CAS.Continuum.Legendre.RootCertificates.shiftedMoment p k = 0) :
      CAS.Continuum.Legendre.Rule n
    def CAS.Continuum.Legendre.RootCertificates.rule
      {n : ℕ} (hn : 0 < n)
      (p : CAS.Polynomial.Sparse.Univariate)
      (brackets :
        Fin n →
          CAS.Polynomial.RealRoot.RootBracket)
      (hvalid :
        ∀ (i : Fin n),
          CAS.Polynomial.RealRoot.RootBracket.valid
              p (brackets i) =
            true)
      (hordered :
        ∀ (i j : Fin n),
          i < j →
            (brackets i).interval.hi <
              (brackets j).interval.lo)
      (hinterior :
        ∀ (i : Fin n),
          -1 < (brackets i).interval.lo ∧
            (brackets i).interval.hi < 1)
      (hmonic :
        (CAS.Continuum.Legendre.RootCertificates.realPolynomial
            p).Monic)
      (hdegree :
        (CAS.Continuum.Legendre.RootCertificates.realPolynomial
              p).natDegree =
          n)
      (hmoments :
        ∀ k < n,
          CAS.Continuum.Legendre.RootCertificates.shiftedMoment
              p k =
            0) :
      CAS.Continuum.Legendre.Rule n

    The Gaussian rule on [-1, 1] with nodes at the certified roots and weights the Christoffel numbers. Needs n > 0, valid brackets that are disjoint, listed in increasing order and inside (-1, 1), p monic of degree n, and the vanishing moments shiftedMoment p k = 0 for k < n, which give orthogonality of the nodal polynomial and hence positivity of the weights and exactness through degree 2n - 1.

  • def CAS.Continuum.Legendre.RootCertificates.shiftedMoment :
      CAS.Polynomial.Sparse.Univariate → ℕ → ℚ
    def CAS.Continuum.Legendre.RootCertificates.shiftedMoment :
      CAS.Polynomial.Sparse.Univariate → ℕ → ℚ

    The rational value of ∫_{-1}^1 p x * x^k for a sparse polynomial p, computed term by term from moment.

Proof for Theorem 10.102
uses 0

Each valid bracket contains a unique root, and the ordering of the brackets orders the roots. A monic polynomial of degree n with n distinct roots is the product of the corresponding linear factors. The vanishing moments, extended linearly to every q of degree below n, make the nodal polynomial orthogonal to lower degrees; the Gaussian exactness and weight positivity arguments then apply without change.

The weights of a certified rule are enclosed from the same brackets. At a simple root r of p the Lagrange basis polynomial is p(x)/\bigl((x-r)\,p'(r)\bigr), so the Christoffel number is

w_r=\frac{1}{p'(r)}\int_{-1}^1\frac{p(x)}{x-r}\,dx.

Synthetic division writes the integral as a polynomial in r with rational coefficients, so the weight is a rational function of the single root r, and interval evaluation over the bracket encloses it.

Theorem10.103
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Theorem 10.42
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 0✓L∃∀N

If the nodal polynomial of a family of nodes is p and r_i is a root, the interpolatory weight at r_i is \tilde p(r_i)/p'(r_i), where \tilde p is the rational polynomial integratedQuotient p with \tilde p(r)=\int_{-1}^1p(x)/(x-r)\,dx. For a valid bracket the rational interval weightInterval p bracket contains this quotient at the bracketed root, and each Christoffel number of the certified rule lies in the interval computed from its own bracket.

Lean code for Theorem10.103●5 declarations
  • theorem CAS.Continuum.Legendre.RootCertificates.weight_mem {n : ℕ}
      (p : CAS.Polynomial.Sparse.Univariate)
      (brackets : Fin n → CAS.Polynomial.RealRoot.RootBracket)
      (hvalid :
        ∀ (i : Fin n),
          CAS.Polynomial.RealRoot.RootBracket.valid p (brackets i) = true)
      (hordered :
        ∀ (i j : Fin n),
          i < j → (brackets i).interval.hi < (brackets j).interval.lo)
      (hdegree :
        (CAS.Continuum.Legendre.RootCertificates.realPolynomial
              p).natDegree =
          n)
      (i : Fin n) :
      (CAS.Continuum.Legendre.RootCertificates.weightInterval p
            (brackets i)).MemReal
        (CAS.Continuum.interpolatoryWeight
          (CAS.Continuum.polynomialIntegral (-1) 1 (fun x ↦ 1) ⋯)
          (CAS.Continuum.Legendre.RootCertificates.nodes p brackets hvalid)
          i)
    theorem CAS.Continuum.Legendre.RootCertificates.weight_mem
      {n : ℕ}
      (p : CAS.Polynomial.Sparse.Univariate)
      (brackets :
        Fin n →
          CAS.Polynomial.RealRoot.RootBracket)
      (hvalid :
        ∀ (i : Fin n),
          CAS.Polynomial.RealRoot.RootBracket.valid
              p (brackets i) =
            true)
      (hordered :
        ∀ (i j : Fin n),
          i < j →
            (brackets i).interval.hi <
              (brackets j).interval.lo)
      (hdegree :
        (CAS.Continuum.Legendre.RootCertificates.realPolynomial
              p).natDegree =
          n)
      (i : Fin n) :
      (CAS.Continuum.Legendre.RootCertificates.weightInterval
            p (brackets i)).MemReal
        (CAS.Continuum.interpolatoryWeight
          (CAS.Continuum.polynomialIntegral
            (-1) 1 (fun x ↦ 1) ⋯)
          (CAS.Continuum.Legendre.RootCertificates.nodes
            p brackets hvalid)
          i)

    Each Christoffel number of the rule built from certified brackets lies in weightInterval p (brackets i).

  • theorem CAS.Continuum.Legendre.RootCertificates.interpolatoryWeight_eq_quotient
      {n : ℕ} (p : CAS.Polynomial.Sparse.Univariate) (r : Fin n → ℝ)
      (hnodal :
        Lagrange.nodal Finset.univ r =
          CAS.Continuum.Legendre.RootCertificates.realPolynomial p)
      (i : Fin n) :
      CAS.Continuum.interpolatoryWeight
          (CAS.Continuum.polynomialIntegral (-1) 1 (fun x ↦ 1) ⋯) r i =
        CAS.Polynomial.Sparse.evalReal
            (CAS.Continuum.Legendre.RootCertificates.integratedQuotient p)
            (r i) /
          CAS.Polynomial.Sparse.evalReal
            (CAS.Polynomial.Sparse.derivativeRaw p) (r i)
    theorem CAS.Continuum.Legendre.RootCertificates.interpolatoryWeight_eq_quotient
      {n : ℕ}
      (p : CAS.Polynomial.Sparse.Univariate)
      (r : Fin n → ℝ)
      (hnodal :
        Lagrange.nodal Finset.univ r =
          CAS.Continuum.Legendre.RootCertificates.realPolynomial
            p)
      (i : Fin n) :
      CAS.Continuum.interpolatoryWeight
          (CAS.Continuum.polynomialIntegral
            (-1) 1 (fun x ↦ 1) ⋯)
          r i =
        CAS.Polynomial.Sparse.evalReal
            (CAS.Continuum.Legendre.RootCertificates.integratedQuotient
              p)
            (r i) /
          CAS.Polynomial.Sparse.evalReal
            (CAS.Polynomial.Sparse.derivativeRaw
              p)
            (r i)

    When the nodal polynomial is realPolynomial p, the Christoffel number at node i is (integratedQuotient p)(rᵢ) / p'(rᵢ), a rational function of the single node rᵢ.

  • theorem CAS.Continuum.Legendre.RootCertificates.weightInterval_sound
      (p : CAS.Polynomial.Sparse.Univariate)
      (bracket : CAS.Polynomial.RealRoot.RootBracket)
      (hvalid : CAS.Polynomial.RealRoot.RootBracket.valid p bracket = true)
      {r : ℝ} (hr : bracket.interval.MemReal r) :
      (CAS.Continuum.Legendre.RootCertificates.weightInterval p
            bracket).MemReal
        (CAS.Polynomial.Sparse.evalReal
            (CAS.Continuum.Legendre.RootCertificates.integratedQuotient p)
            r /
          CAS.Polynomial.Sparse.evalReal
            (CAS.Polynomial.Sparse.derivativeRaw p) r)
    theorem CAS.Continuum.Legendre.RootCertificates.weightInterval_sound
      (p : CAS.Polynomial.Sparse.Univariate)
      (bracket :
        CAS.Polynomial.RealRoot.RootBracket)
      (hvalid :
        CAS.Polynomial.RealRoot.RootBracket.valid
            p bracket =
          true)
      {r : ℝ}
      (hr : bracket.interval.MemReal r) :
      (CAS.Continuum.Legendre.RootCertificates.weightInterval
            p bracket).MemReal
        (CAS.Polynomial.Sparse.evalReal
            (CAS.Continuum.Legendre.RootCertificates.integratedQuotient
              p)
            r /
          CAS.Polynomial.Sparse.evalReal
            (CAS.Polynomial.Sparse.derivativeRaw
              p)
            r)

    For a valid bracket containing r, weightInterval p bracket contains (integratedQuotient p)(r) / p'(r).

  • theorem CAS.Continuum.Legendre.RootCertificates.integral_quotient
      (p : CAS.Polynomial.Sparse.Univariate) (r : ℝ) :
      (CAS.Continuum.polynomialIntegral (-1) 1 (fun x ↦ 1) ⋯)
          (CAS.Continuum.Legendre.RootCertificates.quotient p r) =
        CAS.Polynomial.Sparse.evalReal
          (CAS.Continuum.Legendre.RootCertificates.integratedQuotient p) r
    theorem CAS.Continuum.Legendre.RootCertificates.integral_quotient
      (p : CAS.Polynomial.Sparse.Univariate)
      (r : ℝ) :
      (CAS.Continuum.polynomialIntegral (-1) 1
            (fun x ↦ 1) ⋯)
          (CAS.Continuum.Legendre.RootCertificates.quotient
            p r) =
        CAS.Polynomial.Sparse.evalReal
          (CAS.Continuum.Legendre.RootCertificates.integratedQuotient
            p)
          r

    ∫_{-1}^1 quotient p r equals integratedQuotient p evaluated at r.

  • def CAS.Continuum.Legendre.RootCertificates.weightInterval
      (p : CAS.Polynomial.Sparse.Univariate)
      (bracket : CAS.Polynomial.RealRoot.RootBracket) :
      CAS.Continuum.RationalInterval
    def CAS.Continuum.Legendre.RootCertificates.weightInterval
      (p : CAS.Polynomial.Sparse.Univariate)
      (bracket :
        CAS.Polynomial.RealRoot.RootBracket) :
      CAS.Continuum.RationalInterval

    A rational interval enclosing the weight: the interval quotient of the enclosures of integratedQuotient p and of p' over the bracket, with the sign of p' read from the bracket's direction. The fallback RationalInterval.const 0 is never reached for a valid bracket.

Proof for Theorem 10.103
uses 0

The Lagrange basis polynomial at a node is the nodal polynomial divided by x-r_i and by the nodal weight, which equals p'(r_i) for a simple root. The division by x-r is carried out monomial by monomial through (x^k-r^k)/(x-r)=\sum_{j<k}x^jr^{k-1-j}, and integrating the result term by term gives \tilde p. The bracket's direction fixes the sign of p' on it, so dividing the numerator enclosure by the derivative enclosure is sound.

10.8.1.4. Convergence of positive rules🔗

The error formula needs 2n derivatives, and the constant M_{2n}/(2n)! need not stay small for a function that is merely continuous. A different argument gives convergence for every continuous f, and it uses exactly one property beyond exactness: positive weights.

Theorem10.104
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Theorem 10.89
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 1✓L∃∀N

Let w be continuous on [a,b] and let Q_n be rules with nonnegative weights and nodes in [a,b], where Q_n integrates every polynomial of degree at most d_n exactly against w and d_n\to\infty. Then Q_n(f)\to\int_a^b f\,w for every f continuous on [a,b]. This is the theorem of Pólya and Steklov. The same statement holds for normalized rules with nonnegative weights transported to [a,b].

Lean code for Theorem10.104●3 theorems
  • theorem CAS.Continuum.NodalRule.tendsto_eval_of_positive
      {Q : ℕ → CAS.Continuum.NodalRule} {deg : ℕ → ℕ} {a b : ℝ}
      {w f : ℝ → ℝ} (hab : a ≤ b) (hw : ContinuousOn w (Set.Icc a b))
      (hpos : ∀ (n : ℕ), (Q n).Positive)
      (hnodes : ∀ (n : ℕ), (Q n).NodesIn (Set.Icc a b))
      (hexact : ∀ (n : ℕ), (Q n).ExactToDegree a b w (deg n))
      (hdeg : Filter.Tendsto deg Filter.atTop Filter.atTop)
      (hf : ContinuousOn f (Set.Icc a b)) :
      Filter.Tendsto (fun n ↦ (Q n).eval f) Filter.atTop
        (nhds (∫ (x : ℝ) in a..b, f x * w x))
    theorem CAS.Continuum.NodalRule.tendsto_eval_of_positive
      {Q : ℕ → CAS.Continuum.NodalRule}
      {deg : ℕ → ℕ} {a b : ℝ} {w f : ℝ → ℝ}
      (hab : a ≤ b)
      (hw : ContinuousOn w (Set.Icc a b))
      (hpos : ∀ (n : ℕ), (Q n).Positive)
      (hnodes :
        ∀ (n : ℕ),
          (Q n).NodesIn (Set.Icc a b))
      (hexact :
        ∀ (n : ℕ),
          (Q n).ExactToDegree a b w (deg n))
      (hdeg :
        Filter.Tendsto deg Filter.atTop
          Filter.atTop)
      (hf : ContinuousOn f (Set.Icc a b)) :
      Filter.Tendsto (fun n ↦ (Q n).eval f)
        Filter.atTop
        (nhds (∫ (x : ℝ) in a..b, f x * w x))

    Pólya-Steklov theorem. Let w be continuous on [a,b] and let Qₙ be positive rules with nodes in [a,b], the n-th exact to degree dₙ against w, with dₙ → ∞. Then Qₙ(f) → ∫ₐᵇ f w for every f continuous on [a,b].

  • theorem CAS.Continuum.NodalRule.abs_eval_sub_integral_le_of_polynomial_approx
      {Q : CAS.Continuum.NodalRule} {a b : ℝ} (hab : a ≤ b) {w : ℝ → ℝ}
      (hw : ContinuousOn w (Set.Icc a b)) (hpos : Q.Positive)
      (hnodes : Q.NodesIn (Set.Icc a b)) {d : ℕ}
      (hexact : Q.ExactToDegree a b w d) {f : ℝ → ℝ}
      (hf : ContinuousOn f (Set.Icc a b)) (p : Polynomial ℝ)
      (hp : p.natDegree ≤ d) {δ : ℝ}
      (happrox : ∀ x ∈ Set.Icc a b, |Polynomial.eval x p - f x| ≤ δ) :
      |Q.eval f - ∫ (x : ℝ) in a..b, f x * w x| ≤
        δ * ((∫ (x : ℝ) in a..b, w x) + ∫ (x : ℝ) in a..b, |w x|)
    theorem CAS.Continuum.NodalRule.abs_eval_sub_integral_le_of_polynomial_approx
      {Q : CAS.Continuum.NodalRule} {a b : ℝ}
      (hab : a ≤ b) {w : ℝ → ℝ}
      (hw : ContinuousOn w (Set.Icc a b))
      (hpos : Q.Positive)
      (hnodes : Q.NodesIn (Set.Icc a b))
      {d : ℕ}
      (hexact : Q.ExactToDegree a b w d)
      {f : ℝ → ℝ}
      (hf : ContinuousOn f (Set.Icc a b))
      (p : Polynomial ℝ)
      (hp : p.natDegree ≤ d) {δ : ℝ}
      (happrox :
        ∀ x ∈ Set.Icc a b,
          |Polynomial.eval x p - f x| ≤ δ) :
      |Q.eval f -
            ∫ (x : ℝ) in a..b, f x * w x| ≤
        δ *
          ((∫ (x : ℝ) in a..b, w x) +
            ∫ (x : ℝ) in a..b, |w x|)

    Error of a positive rule from uniform polynomial approximation.

    If the rule is exact to degree d against a continuous weight w, its nodes lie in [a,b], f is continuous on [a,b], and a polynomial of degree at most d is within δ of f on [a,b], then the error on f is at most δ (∫ₐᵇ w + ∫ₐᵇ |w|).

  • theorem CAS.Continuum.QuadratureRule.tendsto_valueOn_of_nonneg
      (rules : ℕ → CAS.Continuum.QuadratureRule) {deg : ℕ → ℕ}
      (hpositive : ∀ (n : ℕ), ∀ term ∈ (rules n).terms, 0 ≤ term.1)
      (hexact : ∀ (n : ℕ), (rules n).ExactUpTo (deg n))
      (hdeg : Filter.Tendsto deg Filter.atTop Filter.atTop) {a b : ℝ}
      (hab : a ≤ b) {f : ℝ → ℝ} (hf : ContinuousOn f (Set.Icc a b)) :
      Filter.Tendsto (fun n ↦ (rules n).valueOn f a b) Filter.atTop
        (nhds (∫ (x : ℝ) in a..b, f x))
    theorem CAS.Continuum.QuadratureRule.tendsto_valueOn_of_nonneg
      (rules :
        ℕ → CAS.Continuum.QuadratureRule)
      {deg : ℕ → ℕ}
      (hpositive :
        ∀ (n : ℕ),
          ∀ term ∈ (rules n).terms,
            0 ≤ term.1)
      (hexact :
        ∀ (n : ℕ),
          (rules n).ExactUpTo (deg n))
      (hdeg :
        Filter.Tendsto deg Filter.atTop
          Filter.atTop)
      {a b : ℝ} (hab : a ≤ b) {f : ℝ → ℝ}
      (hf : ContinuousOn f (Set.Icc a b)) :
      Filter.Tendsto
        (fun n ↦ (rules n).valueOn f a b)
        Filter.atTop
        (nhds (∫ (x : ℝ) in a..b, f x))

    Pólya-Steklov theorem for normalized rules. Rules with nonnegative weights on [0,1], the n-th exact through degree dₙ with dₙ → ∞, converge on every ordered interval to ∫ₐᵇ f for every continuous f. This is NodalRule.tendsto_eval_of_positive for the unit weight.

Proof for Theorem 10.104
uses 0

Exactness on constants makes the weights of Q_n sum to \int_a^b w. If a polynomial p of degree at most d_n is within \delta of f on [a,b], positivity bounds |Q_n(f)-Q_n(p)| by \delta\int_a^b w, and |\int_a^b (p-f)w| is at most \delta\int_a^b|w|. Since Q_n(p) is the integral of p w, the error on f is at most \delta(\int_a^b w+\int_a^b|w|), a bound independent of n. The Weierstrass theorem supplies p for every \delta>0, and d_n\to\infty makes p admissible for all large n.

A Gauss rule with n+1 nodes is positive, has its nodes in [a,b], and has degree 2n+1, so the theorem applies directly.

Theorem10.105
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Definition 10.98
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 0✓L∃∀N

Let w be continuous on [[a,b]] with a\le b, and for each n let Q_n be a Gaussian rule with n+1 nodes for w. Then Q_n(f)\to\int_a^b f\,w for every f continuous on [a,b]. In particular the rules of the existence theorem converge whenever w is strictly positive and a<b.

Lean code for Theorem10.105●2 theorems
  • theorem CAS.Continuum.gaussian_rules_converge {a b : ℝ} (hab : a < b)
      (w : ℝ → ℝ) (hw : ContinuousOn w (Set.uIcc a b))
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x) {f : ℝ → ℝ}
      (hf : ContinuousOn f (Set.Icc a b)) :
      Filter.Tendsto
        (fun n ↦
          (CAS.Continuum.gaussianRule hab w hw hwpos (n + 1) ⋯).value f)
        Filter.atTop (nhds (∫ (x : ℝ) in a..b, f x * w x))
    theorem CAS.Continuum.gaussian_rules_converge
      {a b : ℝ} (hab : a < b) (w : ℝ → ℝ)
      (hw : ContinuousOn w (Set.uIcc a b))
      (hwpos : ∀ x ∈ Set.Icc a b, 0 < w x)
      {f : ℝ → ℝ}
      (hf : ContinuousOn f (Set.Icc a b)) :
      Filter.Tendsto
        (fun n ↦
          (CAS.Continuum.gaussianRule hab w hw
                hwpos (n + 1) ⋯).value
            f)
        Filter.atTop
        (nhds (∫ (x : ℝ) in a..b, f x * w x))

    For continuous f and a continuous strictly positive weight on [a, b], a < b, the Gaussian rules gaussianRule with n + 1 nodes converge to ∫ f w as n → ∞.

  • theorem CAS.Continuum.GaussianRule.tendsto_value {a b : ℝ} {w : ℝ → ℝ}
      {hw : ContinuousOn w (Set.uIcc a b)} (hab : a ≤ b)
      (rules : (n : ℕ) → CAS.Continuum.GaussianRule a b w hw (n + 1))
      {f : ℝ → ℝ} (hf : ContinuousOn f (Set.Icc a b)) :
      Filter.Tendsto (fun n ↦ (rules n).value f) Filter.atTop
        (nhds (∫ (x : ℝ) in a..b, f x * w x))
    theorem CAS.Continuum.GaussianRule.tendsto_value
      {a b : ℝ} {w : ℝ → ℝ}
      {hw : ContinuousOn w (Set.uIcc a b)}
      (hab : a ≤ b)
      (rules :
        (n : ℕ) →
          CAS.Continuum.GaussianRule a b w hw
            (n + 1))
      {f : ℝ → ℝ}
      (hf : ContinuousOn f (Set.Icc a b)) :
      Filter.Tendsto
        (fun n ↦ (rules n).value f)
        Filter.atTop
        (nhds (∫ (x : ℝ) in a..b, f x * w x))

    Every sequence of Gaussian rules for a continuous weight on [a,b], the n-th with n + 1 nodes, converges to ∫ₐᵇ f w for f continuous on [a,b]. The rules are positive and the n-th is exact to degree 2n + 1, so this is the Pólya-Steklov theorem NodalRule.tendsto_eval_of_positive.

Proof for Theorem 10.105
uses 0

The rules are positive with nodes in [a,b] and are exact to degree 2(n+1)-1, which tends to infinity. Apply the Pólya–Steklov theorem.

errorn2816241e-41e-21e01e2Newton-CotesGausssum of absolute weightsn2816241e01e11e21e31e4sum of |w| = 2n = 9exact value (2/5) arctan 5, rational Newton-Cotes weights, floating-point Gauss nodes
Positive weights converge, Newton-Cotes need not. Left: the error of the closed Newton-Cotes rule and of the Gauss-Legendre rule with \(n\) points for \(\int_{-1}^1 dx/(1+25x^2)=\tfrac25\arctan 5\), on a logarithmic scale. The Newton-Cotes values are exact rational numbers, so their growth is not rounding. Right: the sum of the absolute weights. For a rule exact on constants with nonnegative weights this sum is the length \(2\), which is what the Polya-Steklov bound uses. Newton-Cotes weights turn negative at \(n=9\) and from \(n=11\) on, and their absolute sum grows without bound.

Positivity is not a technicality. The figure integrates the Runge function 1/(1+25x^2) over [-1,1] with the closed Newton–Cotes rule and the Gauss–Legendre rule, n=2,\dots,24 points. Both are exact to degree at least n-1, so both would converge if only exactness mattered. Newton–Cotes weights become negative at nine points and from eleven points on, the sum \sum_i|w_i| grows geometrically, and the error grows with it. The Gauss weights stay positive, their absolute sum is always 2, and the error decreases steadily. The divergence of Newton–Cotes is a classical computation shown here for contrast; the library proves the positive side.

10.8.1.5. Panel rules of any order🔗

For a smooth integrand the practical way to reduce error is to cut the interval into N equal panels and apply a low-order rule on each. The only information the composite construction needs about the local rule is a one-panel bound of the form

\left\|\int_a^b f-Q(f)\right\|\le\frac{M\,(b-a)^{m+1}}{D} \qquad\text{whenever }\|f^{(m)}\|\le M\text{ on }[a,b].

Summing N such bounds over panels of length (b-a)/N gives C(b-a)^{m+1}/(DN^m). The library records the pair (rule, D) with the proof of the one-panel bound as a PanelRule m, and builds composite certificates, tolerance planning, and adaptive bisection once for every order m.

Definition10.106
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Definition 10.83
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
Used by 2
Reverse dependency previews
Preview
Theorem 10.107
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

A panel rule of order m is a normalized rule Q with a positive constant D and a proof that, on every ordered interval [a,b], every f\in C^m[a,b] with \|f^{(m)}\|\le M there satisfies \|\int_a^b f-Q(f)\|\le M(b-a)^{m+1}/D. Its composite certificate on N>0 equal panels, given a panelwise derivative bounder with common bound C, has error budget C(b-a)^{m+1}/(DN^m). Simpson's rule and the two-point Gauss–Legendre rule are panel rules of order four.

Lean code for Definition10.106●6 declarations
  • structure(4 fields)defined in CAS/Continuum/Quadrature/PanelRule.lean
    complete
    structure CAS.Continuum.PanelRule (m : ℕ) : Type
    structure CAS.Continuum.PanelRule (m : ℕ) : Type

    A normalized quadrature rule with a one-panel error estimate of order m: the error on [a,b] is at most M (b-a)^(m+1) / D whenever ‖f⁽ᵐ⁾‖ ≤ M there.

    rule : CAS.Continuum.QuadratureRule

    The rule on the reference interval [0,1].

    denominator : ℝ

    The denominator D in the one-panel error M (b-a)^(m+1) / D.

    denominator_pos : 0 < self.denominator

    The denominator is positive.

    norm_integral_sub_valueOn_le : ∀ {f : ℝ → ℝ} {a b M : ℝ},
      a < b →
        ContDiffOn ℝ (↑m) f (Set.Icc a b) →
          (∀ x ∈ Set.Icc a b, ‖iteratedDerivWithin m f (Set.Icc a b) x‖ ≤ M) →
            ‖(∫ (x : ℝ) in a..b, f x) - self.rule.valueOn f a b‖ ≤ M * (b - a) ^ (m + 1) / self.denominator

    The one-panel estimate on every ordered interval.

  • def CAS.Continuum.PanelRule.composite {m : ℕ}
      (R : CAS.Continuum.PanelRule m) {f : ℝ → ℝ} {a b C : ℝ} {N : ℕ}
      (hab : a < b) (hN : 0 < N) (hf : ContDiffOn ℝ (↑m) f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn m f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r) (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C) :
      CAS.Continuum.QuadratureCert f a b
    def CAS.Continuum.PanelRule.composite {m : ℕ}
      (R : CAS.Continuum.PanelRule m)
      {f : ℝ → ℝ} {a b C : ℝ} {N : ℕ}
      (hab : a < b) (hN : 0 < N)
      (hf : ContDiffOn ℝ (↑m) f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn
          m f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r)
          (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C) :
      CAS.Continuum.QuadratureCert f a b

    Composite certificate on N equal panels, with error C (b-a)^(m+1) / (D N^m) when C dominates every per-panel bound for ‖f⁽ᵐ⁾‖.

  • complete
    theorem CAS.Continuum.PanelRule.composite_error {m : ℕ}
      (R : CAS.Continuum.PanelRule m) {f : ℝ → ℝ} {a b C : ℝ} {N : ℕ}
      (hab : a < b) (hN : 0 < N) (hf : ContDiffOn ℝ (↑m) f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn m f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r) (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C) :
      (R.composite hab hN hf bounder ⋯).error =
        C * (b - a) ^ (m + 1) / (R.denominator * ↑N ^ m)
    theorem CAS.Continuum.PanelRule.composite_error
      {m : ℕ} (R : CAS.Continuum.PanelRule m)
      {f : ℝ → ℝ} {a b C : ℝ} {N : ℕ}
      (hab : a < b) (hN : 0 < N)
      (hf : ContDiffOn ℝ (↑m) f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn
          m f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r)
          (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C) :
      (R.composite hab hN hf bounder
            ⋯).error =
        C * (b - a) ^ (m + 1) /
          (R.denominator * ↑N ^ m)

    The composite error budget is C (b-a)^(m+1) / (D N^m).

  • def CAS.Continuum.simpsonRule.fourthOrder : CAS.Continuum.PanelRule 4
    def CAS.Continuum.simpsonRule.fourthOrder :
      CAS.Continuum.PanelRule 4

    Simpson's rule as a panel rule of order 4, with its sharp one-panel constant 2880.

  • def CAS.Continuum.gaussLegendreTwoRule.fourthOrder :
      CAS.Continuum.PanelRule 4
    def CAS.Continuum.gaussLegendreTwoRule.fourthOrder :
      CAS.Continuum.PanelRule 4

    The two-point Gauss-Legendre rule as a panel rule of order 4, with its sharp one-panel constant 4320.

Theorem10.107
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1used by 0✓L∃∀N

On an ordered interval, for f\in C^2[a,b] with \|f''\|\le C there,

\left\|\int_a^bf-\frac{b-a}2\bigl(f(a)+f(b)\bigr)\right\| \le\frac{C(b-a)^3}{12},\qquad \left\|\int_a^bf-(b-a)f\!\left(\tfrac{a+b}2\right)\right\| \le\frac{C(b-a)^3}{24}.

Both rules are exact through degree one, and they are panel rules of order two with D=12 and D=24.

Lean code for Theorem10.107●6 declarations
  • theorem CAS.Continuum.norm_integral_sub_trapezoidRule_valueOn_le {f : ℝ → ℝ}
      {a b C : ℝ} (hab : a < b) (hf : ContDiffOn ℝ 2 f (Set.Icc a b))
      (hsecond :
        ∀ x ∈ Set.Icc a b, ‖iteratedDerivWithin 2 f (Set.Icc a b) x‖ ≤ C) :
      ‖(∫ (x : ℝ) in a..b, f x) -
            CAS.Continuum.trapezoidRule.valueOn f a b‖ ≤
        C * (b - a) ^ 3 / 12
    theorem CAS.Continuum.norm_integral_sub_trapezoidRule_valueOn_le
      {f : ℝ → ℝ} {a b C : ℝ} (hab : a < b)
      (hf : ContDiffOn ℝ 2 f (Set.Icc a b))
      (hsecond :
        ∀ x ∈ Set.Icc a b,
          ‖iteratedDerivWithin 2 f
                (Set.Icc a b) x‖ ≤
            C) :
      ‖(∫ (x : ℝ) in a..b, f x) -
            CAS.Continuum.trapezoidRule.valueOn
              f a b‖ ≤
        C * (b - a) ^ 3 / 12

    Sharp one-panel trapezoid estimate on an ordered interval.

    A bound C for the second within-derivative yields the classical error C (b-a)³ / 12.

  • theorem CAS.Continuum.norm_integral_sub_midpointRule_valueOn_le {f : ℝ → ℝ}
      {a b C : ℝ} (hab : a < b) (hf : ContDiffOn ℝ 2 f (Set.Icc a b))
      (hsecond :
        ∀ x ∈ Set.Icc a b, ‖iteratedDerivWithin 2 f (Set.Icc a b) x‖ ≤ C) :
      ‖(∫ (x : ℝ) in a..b, f x) -
            CAS.Continuum.midpointRule.valueOn f a b‖ ≤
        C * (b - a) ^ 3 / 24
    theorem CAS.Continuum.norm_integral_sub_midpointRule_valueOn_le
      {f : ℝ → ℝ} {a b C : ℝ} (hab : a < b)
      (hf : ContDiffOn ℝ 2 f (Set.Icc a b))
      (hsecond :
        ∀ x ∈ Set.Icc a b,
          ‖iteratedDerivWithin 2 f
                (Set.Icc a b) x‖ ≤
            C) :
      ‖(∫ (x : ℝ) in a..b, f x) -
            CAS.Continuum.midpointRule.valueOn
              f a b‖ ≤
        C * (b - a) ^ 3 / 24

    Sharp one-panel midpoint estimate on an ordered interval.

    A bound C for the second within-derivative yields the classical error C (b-a)³ / 24.

  • def CAS.Continuum.trapezoidRule.secondOrder : CAS.Continuum.PanelRule 2
    def CAS.Continuum.trapezoidRule.secondOrder :
      CAS.Continuum.PanelRule 2

    The trapezoidal rule with its sharp one-panel constant 12.

  • def CAS.Continuum.midpointRule.secondOrder : CAS.Continuum.PanelRule 2
    def CAS.Continuum.midpointRule.secondOrder :
      CAS.Continuum.PanelRule 2

    The midpoint rule with its sharp one-panel constant 24.

  • theorem CAS.Continuum.trapezoidRule.exactUpTo_one :
      CAS.Continuum.trapezoidRule.ExactUpTo 1
    theorem CAS.Continuum.trapezoidRule.exactUpTo_one :
      CAS.Continuum.trapezoidRule.ExactUpTo 1

    The trapezoid rule has the exact normalized moments of degrees zero and one.

  • theorem CAS.Continuum.midpointRule.exactUpTo_one :
      CAS.Continuum.midpointRule.ExactUpTo 1
    theorem CAS.Continuum.midpointRule.exactUpTo_one :
      CAS.Continuum.midpointRule.ExactUpTo 1

    The midpoint rule has the exact normalized moments of degrees zero and one.

Proof for Theorem 10.107
uses 0

Two integrations by parts write each error as \int_a^bK(t)f''(t)\,dt. For the trapezoid rule the kernel is (t-a)(b-t)/2\ge0, of mass (b-a)^3/12. For the midpoint rule it is (t-a)^2/2 on the left half and (b-t)^2/2 on the right, of mass (b-a)^3/24. Bound f'' by C.

second orderN124816321e01e-11e-21e-31e-4trapezoidmidpointfourth orderN124816321e-31e-51e-71e-9SimpsonGauss-Legendre 2proved bound; marks are measured errors
Composite rules on N panels: measured error and proved bound. The error of four composite rules for \(\int_0^1e^x\,dx=e-1\) against the number of equal panels \(N\), both axes logarithmic. Marks are measured errors; each dashed line is the proved panel-rule bound \(C(b-a)^{m+1}/(DN^m)\) with \(C=e\). Left, order \(m=2\): \(D=12\) for the trapezoid rule and \(D=24\) for the midpoint rule. Right, order \(m=4\): \(D=2880\) for Simpson and \(D=4320\) for two-point Gauss-Legendre. The slopes are \(-2\) and \(-4\), and the marks sit a constant factor near \((e-1)/e\) below their bounds because \(|f^{(m)}|=e^x\) ranges from \(1\) to \(e\) while the bound uses its maximum.

The figure measures the composite error for \int_0^1e^x\,dx against the panel count on logarithmic axes. On the left are the two second-order rules, on the right Simpson's rule and the two-point Gauss rule. Each measured error sits below its dashed proved bound e/(DN^m), and each curve has slope -m, so halving the panel width divides the error by 4 or by 16. The constants fall in the order the denominators 12, 24, 2880, 4320 predict: at every panel count the midpoint error is about half the trapezoid error, and the Gauss error about two thirds of Simpson's.

Because the budget is an explicit function of N, the number of panels needed for a tolerance \varepsilon can be computed in advance. The planner never evaluates the integrand; it needs only the derivative bound C.

Theorem10.108
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1used by 0✓L∃∀N

Let m\ne0, D>0, a\le b, C\ge0 and \varepsilon>0, put B=C(b-a)^{m+1}/D, and let N=\max(1,\lceil(B/\varepsilon)^{1/m}\rceil). Then B/N^m\le\varepsilon. Consequently, for a panel rule of order m, an integrand in C^m[a,b], a<b, and a derivative bounder whose bound on every subinterval is at most C, the composite certificate on the planned mesh has error budget at most \varepsilon, and its value is within \varepsilon of \int_a^bf.

Lean code for Theorem10.108●6 declarations
  • complete
    theorem CAS.Continuum.PanelRule.compositeToTolerance_sound_le {m : ℕ}
      (R : CAS.Continuum.PanelRule m) (hm : m ≠ 0) {f : ℝ → ℝ}
      {a b C tolerance : ℝ} (hab : a < b)
      (hf : ContDiffOn ℝ (↑m) f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn m f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r) (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C)
      (htolerance : 0 < tolerance) :
      ‖(∫ (x : ℝ) in a..b, f x) -
            (R.compositeToTolerance hab hf bounder ⋯).value‖ ≤
        tolerance
    theorem CAS.Continuum.PanelRule.compositeToTolerance_sound_le
      {m : ℕ} (R : CAS.Continuum.PanelRule m)
      (hm : m ≠ 0) {f : ℝ → ℝ}
      {a b C tolerance : ℝ} (hab : a < b)
      (hf : ContDiffOn ℝ (↑m) f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn
          m f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r)
          (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C)
      (htolerance : 0 < tolerance) :
      ‖(∫ (x : ℝ) in a..b, f x) -
            (R.compositeToTolerance hab hf
                bounder ⋯).value‖ ≤
        tolerance

    For a positive order and a positive tolerance, the planned composite value approximates the integral within the tolerance.

  • complete
    theorem CAS.Continuum.PanelRule.compositeToTolerance_error_le {m : ℕ}
      (R : CAS.Continuum.PanelRule m) (hm : m ≠ 0) {f : ℝ → ℝ}
      {a b C tolerance : ℝ} (hab : a < b)
      (hf : ContDiffOn ℝ (↑m) f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn m f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r) (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C)
      (htolerance : 0 < tolerance) :
      (R.compositeToTolerance hab hf bounder ⋯).error ≤ tolerance
    theorem CAS.Continuum.PanelRule.compositeToTolerance_error_le
      {m : ℕ} (R : CAS.Continuum.PanelRule m)
      (hm : m ≠ 0) {f : ℝ → ℝ}
      {a b C tolerance : ℝ} (hab : a < b)
      (hf : ContDiffOn ℝ (↑m) f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn
          m f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r)
          (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C)
      (htolerance : 0 < tolerance) :
      (R.compositeToTolerance hab hf bounder
            ⋯).error ≤
        tolerance

    For a positive order and a positive tolerance, the planned composite certificate has error budget at most the tolerance.

  • complete
    theorem CAS.Continuum.PanelPlan.uniformCompositeError_le {m : ℕ} (hm : m ≠ 0)
      {denominator a b C tolerance : ℝ} (htolerance : 0 < tolerance) :
      C * (b - a) ^ (m + 1) /
          (denominator *
            ↑(CAS.Continuum.PanelPlan.requiredPanels m denominator a b C
                  tolerance) ^
              m) ≤
        tolerance
    theorem CAS.Continuum.PanelPlan.uniformCompositeError_le
      {m : ℕ} (hm : m ≠ 0)
      {denominator a b C tolerance : ℝ}
      (htolerance : 0 < tolerance) :
      C * (b - a) ^ (m + 1) /
          (denominator *
            ↑(CAS.Continuum.PanelPlan.requiredPanels
                  m denominator a b C
                  tolerance) ^
              m) ≤
        tolerance

    For m > 0 and ε > 0, the planned mesh meets the tolerance in the unfolded form produced by QuadratureCert.uniformCompositeOfOrder: C (b-a)^(m+1) / (D N^m) ≤ ε.

  • complete
    theorem CAS.Continuum.PanelPlan.errorConstant_div_requiredPanels_pow_le {m : ℕ}
      (hm : m ≠ 0) {denominator a b C tolerance : ℝ}
      (htolerance : 0 < tolerance) :
      CAS.Continuum.PanelPlan.errorConstant m denominator a b C /
          ↑(CAS.Continuum.PanelPlan.requiredPanels m denominator a b C
                tolerance) ^
            m ≤
        tolerance
    theorem CAS.Continuum.PanelPlan.errorConstant_div_requiredPanels_pow_le
      {m : ℕ} (hm : m ≠ 0)
      {denominator a b C tolerance : ℝ}
      (htolerance : 0 < tolerance) :
      CAS.Continuum.PanelPlan.errorConstant m
            denominator a b C /
          ↑(CAS.Continuum.PanelPlan.requiredPanels
                m denominator a b C
                tolerance) ^
            m ≤
        tolerance

    For a positive order m and a positive tolerance, the planned panel count reduces the error model B / N^m to at most the tolerance.

  • def CAS.Continuum.PanelPlan.requiredPanels (m : ℕ)
      (denominator a b C tolerance : ℝ) : ℕ
    def CAS.Continuum.PanelPlan.requiredPanels
      (m : ℕ)
      (denominator a b C tolerance : ℝ) : ℕ

    Panel count max 1 ⌈(B / ε)^(1/m)⌉₊ for an order-m error model with numerator B = errorConstant m D a b C and tolerance ε. Sufficiency requires m > 0 and a positive tolerance; a negative numerator is below the tolerance for every panel count.

  • def CAS.Continuum.PanelRule.compositeToTolerance {m : ℕ}
      (R : CAS.Continuum.PanelRule m) {f : ℝ → ℝ} {a b C tolerance : ℝ}
      (hab : a < b) (hf : ContDiffOn ℝ (↑m) f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn m f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r) (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C) :
      CAS.Continuum.QuadratureCert f a b
    def CAS.Continuum.PanelRule.compositeToTolerance
      {m : ℕ} (R : CAS.Continuum.PanelRule m)
      {f : ℝ → ℝ} {a b C tolerance : ℝ}
      (hab : a < b)
      (hf : ContDiffOn ℝ (↑m) f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn
          m f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r)
          (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C) :
      CAS.Continuum.QuadratureCert f a b

    Composite certificate whose panel count is chosen by PanelPlan.requiredPanels.

Proof for Theorem 10.108
uses 0

The ceiling gives N\ge(B/\varepsilon)^{1/m}, and raising both sides to the power m gives N^m\ge B/\varepsilon. The composite budget is B/N^m, and certificate soundness bounds the actual error by the budget.

For m=4 we use the classical one-panel constants for Simpson's rule and the two-point Gauss rule. We prove their composite bounds and choose meshes with planners in exact rational arithmetic that run inside Lean.

Theorem10.109
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Definition 10.83
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
Used by 2
Reverse dependency previews
Preview
Definition 10.76
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

For an ordered interval [a,b], a C^4 scalar integrand, and a bound C on its fourth within-derivative, the Peano-kernel argument gives the classical one-panel Simpson estimate \lVert\int_a^b f-S(f)\rVert\le C(b-a)^5/2880, returned as a QuadratureCert.

Lean code for Theorem10.109●2 declarations
  • theorem CAS.Continuum.norm_integral_sub_simpsonRule_valueOn_le {f : ℝ → ℝ}
      {a b C : ℝ} (hab : a < b) (hf : ContDiffOn ℝ 4 f (Set.Icc a b))
      (hfourth :
        ∀ x ∈ Set.Icc a b, ‖iteratedDerivWithin 4 f (Set.Icc a b) x‖ ≤ C) :
      ‖(∫ (x : ℝ) in a..b, f x) - CAS.Continuum.simpsonRule.valueOn f a b‖ ≤
        C * (b - a) ^ 5 / 2880
    theorem CAS.Continuum.norm_integral_sub_simpsonRule_valueOn_le
      {f : ℝ → ℝ} {a b C : ℝ} (hab : a < b)
      (hf : ContDiffOn ℝ 4 f (Set.Icc a b))
      (hfourth :
        ∀ x ∈ Set.Icc a b,
          ‖iteratedDerivWithin 4 f
                (Set.Icc a b) x‖ ≤
            C) :
      ‖(∫ (x : ℝ) in a..b, f x) -
            CAS.Continuum.simpsonRule.valueOn
              f a b‖ ≤
        C * (b - a) ^ 5 / 2880

    Sharp one-panel Simpson estimate on an ordered interval.

    The fourth within-derivative bound C yields the classical error C * (b-a)^5 / 2880.

  • def CAS.Continuum.simpsonRule.fourthOrderCert {f : ℝ → ℝ} {a b C : ℝ}
      (hab : a < b) (hf : ContDiffOn ℝ 4 f (Set.Icc a b))
      (hfourth :
        ∀ x ∈ Set.Icc a b, ‖iteratedDerivWithin 4 f (Set.Icc a b) x‖ ≤ C) :
      CAS.Continuum.QuadratureCert f a b
    def CAS.Continuum.simpsonRule.fourthOrderCert
      {f : ℝ → ℝ} {a b C : ℝ} (hab : a < b)
      (hf : ContDiffOn ℝ 4 f (Set.Icc a b))
      (hfourth :
        ∀ x ∈ Set.Icc a b,
          ‖iteratedDerivWithin 4 f
                (Set.Icc a b) x‖ ≤
            C) :
      CAS.Continuum.QuadratureCert f a b

    Sharp one-panel Simpson certificate on an ordered interval.

Proof for Theorem 10.109
uses 0

Represent the Simpson error as the integral of the fourth derivative against its Peano kernel, whose two polynomial pieces live on [a,(a+b)/2] and [(a+b)/2,b]; four integrations by parts produce it, and cubic exactness cancels all boundary polynomial terms. The kernel has fixed sign and exact mass (b-a)^5/2880. Bounding the fourth derivative by C gives the stated norm estimate.

Theorem10.110
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Definition 10.83
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
Used by 2
Reverse dependency previews
Preview
Definition 10.77
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

For an ordered interval [a,b], a C^4 scalar integrand, and a bound C on its fourth within-derivative, the two-point Gauss–Legendre Peano kernel is nonnegative and has mass (b-a)^5/4320. Consequently \lVert\int_a^b f-G_2(f)\rVert\le C(b-a)^5/4320, with the irrational nodes treated exactly; the estimate is returned as a QuadratureCert.

Lean code for Theorem10.110●2 declarations
  • theorem CAS.Continuum.norm_integral_sub_gaussLegendreTwoRule_valueOn_le
      {f : ℝ → ℝ} {a b C : ℝ} (hab : a < b)
      (hf : ContDiffOn ℝ 4 f (Set.Icc a b))
      (hfourth :
        ∀ x ∈ Set.Icc a b, ‖iteratedDerivWithin 4 f (Set.Icc a b) x‖ ≤ C) :
      ‖(∫ (x : ℝ) in a..b, f x) -
            CAS.Continuum.gaussLegendreTwoRule.valueOn f a b‖ ≤
        C * (b - a) ^ 5 / 4320
    theorem CAS.Continuum.norm_integral_sub_gaussLegendreTwoRule_valueOn_le
      {f : ℝ → ℝ} {a b C : ℝ} (hab : a < b)
      (hf : ContDiffOn ℝ 4 f (Set.Icc a b))
      (hfourth :
        ∀ x ∈ Set.Icc a b,
          ‖iteratedDerivWithin 4 f
                (Set.Icc a b) x‖ ≤
            C) :
      ‖(∫ (x : ℝ) in a..b, f x) -
            CAS.Continuum.gaussLegendreTwoRule.valueOn
              f a b‖ ≤
        C * (b - a) ^ 5 / 4320

    Sharp two-point Gauss-Legendre estimate on an ordered interval.

    The fourth within-derivative bound C yields the classical error C * (b-a)^5 / 4320. This proof combines the three nonnegative-kernel bounds with the exact total-mass theorem above.

  • def CAS.Continuum.gaussLegendreTwoRule.fourthOrderCert {f : ℝ → ℝ}
      {a b C : ℝ} (hab : a < b) (hf : ContDiffOn ℝ 4 f (Set.Icc a b))
      (hfourth :
        ∀ x ∈ Set.Icc a b, ‖iteratedDerivWithin 4 f (Set.Icc a b) x‖ ≤ C) :
      CAS.Continuum.QuadratureCert f a b
    def CAS.Continuum.gaussLegendreTwoRule.fourthOrderCert
      {f : ℝ → ℝ} {a b C : ℝ} (hab : a < b)
      (hf : ContDiffOn ℝ 4 f (Set.Icc a b))
      (hfourth :
        ∀ x ∈ Set.Icc a b,
          ‖iteratedDerivWithin 4 f
                (Set.Icc a b) x‖ ≤
            C) :
      CAS.Continuum.QuadratureCert f a b

    Sharp two-point Gauss-Legendre certificate on an ordered interval.

Proof for Theorem 10.110
uses 0

Use cubic exactness to express the rule error through the fourth-order Peano kernel. The exact two Gauss nodes make the boundary terms vanish, and the kernel is nonnegative with mass (b-a)^5/4320. The uniform fourth-derivative bound therefore yields the claimed certificate.

Theorem10.111
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 5
Reverse dependency previews
Preview
Theorem 10.112
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

Any local quadrature constructor with certified error C(v-u)^5/D can be accumulated over N>0 equal panels. The generic theorem produces error C(b-a)^5/(DN^4) and a canonical flattened ordered term list whose exact weighted sum equals the composite value. Smoothness is assumed only on the root interval, and one IteratedDerivativeBounderOn supplies each panel's within-derivative bound together with a common upper bound C. Analytic composition and finite-precision execution therefore share one rule-independent boundary.

Lean code for Theorem10.111●2 declarations
  • theorem CAS.Continuum.weightedSum_uniformCompositeTerms
      (rule : CAS.Continuum.QuadratureRule) (f : ℝ → ℝ) (N : ℕ) (a b : ℝ) :
      CAS.Continuum.weightedSum
          (CAS.Continuum.uniformCompositeTerms rule f N a b) =
        CAS.Continuum.uniformCompositeValue rule f N a b
    theorem CAS.Continuum.weightedSum_uniformCompositeTerms
      (rule : CAS.Continuum.QuadratureRule)
      (f : ℝ → ℝ) (N : ℕ) (a b : ℝ) :
      CAS.Continuum.weightedSum
          (CAS.Continuum.uniformCompositeTerms
            rule f N a b) =
        CAS.Continuum.uniformCompositeValue
          rule f N a b

    Flattened terms denote exactly the corresponding composite-rule value.

  • def CAS.Continuum.QuadratureCert.uniformCompositeFourthOrder
      (rule : CAS.Continuum.QuadratureRule) (denominator : ℝ) {f : ℝ → ℝ}
      {a b C : ℝ} {N : ℕ} (hab : a < b) (hN : 0 < N)
      (hf : ContDiffOn ℝ 4 f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn 4 f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r) (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C)
      (onePanel :
        ∀ {l r : ℝ},
          l < r →
            ContDiffOn ℝ 4 f (Set.Icc l r) →
              (∀ x ∈ Set.Icc l r,
                  ‖iteratedDerivWithin 4 f (Set.Icc l r) x‖ ≤ C) →
                ‖(∫ (x : ℝ) in l..r, f x) - rule.valueOn f l r‖ ≤
                  C * (r - l) ^ 5 / denominator) :
      CAS.Continuum.QuadratureCert f a b
    def CAS.Continuum.QuadratureCert.uniformCompositeFourthOrder
      (rule : CAS.Continuum.QuadratureRule)
      (denominator : ℝ) {f : ℝ → ℝ}
      {a b C : ℝ} {N : ℕ} (hab : a < b)
      (hN : 0 < N)
      (hf : ContDiffOn ℝ 4 f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn
          4 f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r)
          (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C)
      (onePanel :
        ∀ {l r : ℝ},
          l < r →
            ContDiffOn ℝ 4 f (Set.Icc l r) →
              (∀ x ∈ Set.Icc l r,
                  ‖iteratedDerivWithin 4 f
                        (Set.Icc l r) x‖ ≤
                    C) →
                ‖(∫ (x : ℝ) in l..r, f x) -
                      rule.valueOn f l r‖ ≤
                  C * (r - l) ^ 5 /
                    denominator) :
      CAS.Continuum.QuadratureCert f a b

    Accumulate a fourth-order one-panel theorem over a uniform mesh.

    onePanel is the complete rule-specific analytic input. This is the m = 4 case of uniformCompositeOfOrder.

Proof for Theorem 10.111
uses 0

Split the interval into N equal panels and add the local integral identities. The triangle inequality sums the local errors. Since each panel has length (b-a)/N, the sum of N terms C((b-a)/N)^5/D simplifies to C(b-a)^5/(DN^4). Flattening the panel term lists preserves the same finite weighted sum.

Theorem10.112
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Theorem 10.109
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
Used by 3
Reverse dependency previews
Preview
Theorem 10.114
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

For N>0 equal Simpson panels, an integrand that is C^4 on [a,b], and certified panelwise fourth within-derivative bounds at most C, summing the sharp local certificates gives \lVert\int_a^b f-S_N(f)\rVert\le C(b-a)^5/(2880N^4). Each panel consists of the usual two half-subintervals.

Lean code for Theorem10.112●2 declarations
  • theorem CAS.Continuum.QuadratureCert.compositeSimpson_error {f : ℝ → ℝ}
      {a b C : ℝ} {N : ℕ} (hab : a < b) (hN : 0 < N)
      (hf : ContDiffOn ℝ 4 f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn 4 f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r) (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C) :
      (CAS.Continuum.QuadratureCert.compositeSimpson hab hN hf bounder
            ⋯).error =
        C * (b - a) ^ 5 / (2880 * ↑N ^ 4)
    theorem CAS.Continuum.QuadratureCert.compositeSimpson_error
      {f : ℝ → ℝ} {a b C : ℝ} {N : ℕ}
      (hab : a < b) (hN : 0 < N)
      (hf : ContDiffOn ℝ 4 f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn
          4 f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r)
          (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C) :
      (CAS.Continuum.QuadratureCert.compositeSimpson
            hab hN hf bounder ⋯).error =
        C * (b - a) ^ 5 / (2880 * ↑N ^ 4)

    The composite Simpson certificate records its accumulated fourth-order error bound.

  • def CAS.Continuum.QuadratureCert.compositeSimpson {f : ℝ → ℝ} {a b C : ℝ}
      {N : ℕ} (hab : a < b) (hN : 0 < N)
      (hf : ContDiffOn ℝ 4 f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn 4 f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r) (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C) :
      CAS.Continuum.QuadratureCert f a b
    def CAS.Continuum.QuadratureCert.compositeSimpson
      {f : ℝ → ℝ} {a b C : ℝ} {N : ℕ}
      (hab : a < b) (hN : 0 < N)
      (hf : ContDiffOn ℝ 4 f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn
          4 f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r)
          (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C) :
      CAS.Continuum.QuadratureCert f a b

    Composite Simpson quadrature with its sharp accumulated analytic error.

Proof for Theorem 10.112
uses 0

Instantiate the generic composite theorem with the sharp one-panel Simpson certificate and denominator 2880. The common fourth-derivative bound dominates every panel certificate, and the generic error calculation gives the displayed N^{-4} estimate.

Theorem10.113
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Theorem 10.110
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
Used by 2
Reverse dependency previews
Preview
Theorem 10.119
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

For N>0 equal two-point Gauss–Legendre panels and the same root-local smoothness and panelwise derivative-bound hypotheses, the composite certificate has error C(b-a)^5/(4320N^4). Its ordered term list retains the two exact irrational nodes on every panel and is proved equal to the analytic composite value.

Lean code for Theorem10.113●2 declarations
  • theorem CAS.Continuum.QuadratureCert.compositeGaussLegendreTwo_error {f : ℝ → ℝ}
      {a b C : ℝ} {N : ℕ} (hab : a < b) (hN : 0 < N)
      (hf : ContDiffOn ℝ 4 f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn 4 f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r) (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C) :
      (CAS.Continuum.QuadratureCert.compositeGaussLegendreTwo hab hN hf
            bounder ⋯).error =
        C * (b - a) ^ 5 / (4320 * ↑N ^ 4)
    theorem CAS.Continuum.QuadratureCert.compositeGaussLegendreTwo_error
      {f : ℝ → ℝ} {a b C : ℝ} {N : ℕ}
      (hab : a < b) (hN : 0 < N)
      (hf : ContDiffOn ℝ 4 f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn
          4 f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r)
          (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C) :
      (CAS.Continuum.QuadratureCert.compositeGaussLegendreTwo
            hab hN hf bounder ⋯).error =
        C * (b - a) ^ 5 / (4320 * ↑N ^ 4)

    The composite Gauss-Legendre certificate records its accumulated fourth-order error bound.

  • def CAS.Continuum.QuadratureCert.compositeGaussLegendreTwo {f : ℝ → ℝ}
      {a b C : ℝ} {N : ℕ} (hab : a < b) (hN : 0 < N)
      (hf : ContDiffOn ℝ 4 f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn 4 f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r) (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C) :
      CAS.Continuum.QuadratureCert f a b
    def CAS.Continuum.QuadratureCert.compositeGaussLegendreTwo
      {f : ℝ → ℝ} {a b C : ℝ} {N : ℕ}
      (hab : a < b) (hN : 0 < N)
      (hf : ContDiffOn ℝ 4 f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn
          4 f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r)
          (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C) :
      CAS.Continuum.QuadratureCert f a b

    Composite two-point Gauss-Legendre certificate with sharp analytic error.

Proof for Theorem 10.113
uses 0

Instantiate the uniform composite construction with the sharp two-point Gauss–Legendre certificate and denominator 4320. Summing the panel certificates gives the global error, while the generic flattening theorem retains the exact ordered nodes and weights.

Theorem10.114
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 3
Statement dependency previews
Preview
Definition 10.86
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 0✓L∃∀N

The composite rule has a canonical flattened list of ordered weighted terms. Its exact-real weighted sum is proved equal to the analytic composite Simpson value. Verified rational, interval, or floating-point evaluators can therefore evaluate the same term list.

For the canonical panel-major list T_N(f,a,b),

\operatorname{weightedSum}\!\left(T_N(f,a,b)\right) =S_N(f;[a,b]).

The canonical term list fixes the nodes and accumulation order; this equality certifies its exact-real value. Equality of sums alone would not fix an order.

Lean code for Theorem10.114●1 theorem
  • theorem CAS.Continuum.weightedSum_compositeSimpsonTerms (f : ℝ → ℝ) (N : ℕ)
      (a b : ℝ) :
      CAS.Continuum.weightedSum
          (CAS.Continuum.compositeSimpsonTerms f N a b) =
        CAS.Continuum.compositeSimpsonValue f N a b
    theorem CAS.Continuum.weightedSum_compositeSimpsonTerms
      (f : ℝ → ℝ) (N : ℕ) (a b : ℝ) :
      CAS.Continuum.weightedSum
          (CAS.Continuum.compositeSimpsonTerms
            f N a b) =
        CAS.Continuum.compositeSimpsonValue f
          N a b

    Flattened composite Simpson terms have exactly the exact-real value.

Proof for Theorem 10.114
uses 0

Unfold the uniform composite rule panel by panel. On each panel the three listed weighted terms are definitionally the transported Simpson value. Induction over the panel list shows that flattening and then taking the weighted sum equals the sum of the analytic panel values.

Theorem10.115
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Theorem 10.87
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 0✓L∃∀N

Every normalized exact-rational rule compiles uniformly to N > 0 panels by mapping a source term (w,\xi) on panel k to (w/N,(k+\xi)/N). The cast rule is proved equal term-for-term to the canonical analytic uniform-composite list. This preserves both the exact-real value and the panel-major accumulation schedule used by verified numerical backends.

Lean code for Theorem10.115●2 theorems
  • theorem CAS.Continuum.RationalQuadratureRule.uniformComposite_toQuadratureRule_termsOn
      (rule : CAS.Continuum.RationalQuadratureRule) (N : ℕ) (hN : 0 < N)
      (f : ℝ → ℝ) (a b : ℝ) :
      (rule.uniformComposite N hN).toQuadratureRule.termsOn f a b =
        CAS.Continuum.uniformCompositeTerms rule.toQuadratureRule f N a b
    theorem CAS.Continuum.RationalQuadratureRule.uniformComposite_toQuadratureRule_termsOn
      (rule :
        CAS.Continuum.RationalQuadratureRule)
      (N : ℕ) (hN : 0 < N) (f : ℝ → ℝ)
      (a b : ℝ) :
      (rule.uniformComposite N
                hN).toQuadratureRule.termsOn
          f a b =
        CAS.Continuum.uniformCompositeTerms
          rule.toQuadratureRule f N a b

    The exact-rational composite rule produces precisely the ordered real term list for uniform panel composition.

    This is stronger than equality of quadrature values: both lists add the terms in the same panel-major order.

  • theorem CAS.Continuum.RationalQuadratureRule.uniformComposite_toQuadratureRule_valueOn
      (rule : CAS.Continuum.RationalQuadratureRule) (N : ℕ) (hN : 0 < N)
      (f : ℝ → ℝ) (a b : ℝ) :
      (rule.uniformComposite N hN).toQuadratureRule.valueOn f a b =
        CAS.Continuum.uniformCompositeValue rule.toQuadratureRule f N a b
    theorem CAS.Continuum.RationalQuadratureRule.uniformComposite_toQuadratureRule_valueOn
      (rule :
        CAS.Continuum.RationalQuadratureRule)
      (N : ℕ) (hN : 0 < N) (f : ℝ → ℝ)
      (a b : ℝ) :
      (rule.uniformComposite N
                hN).toQuadratureRule.valueOn
          f a b =
        CAS.Continuum.uniformCompositeValue
          rule.toQuadratureRule f N a b

    Exact-rational uniform composition denotes the canonical exact-real uniform composite value on every real interval.

Proof for Theorem 10.115
uses 0

Map every rational source node and weight by the affine panel formula and cast the result to the reals. Field identities show term by term that the cast node and weight equal those of the analytic transported rule. Mapping this equality over panels and flattening proves equality of both schedules and values.

Theorem10.116
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 2
Reverse dependency previews
Preview
Theorem 10.117
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

Let B=C(b-a)^5/D. For a positive tolerance, choosing N=\max(1,\lceil(B/\mathrm{tolerance})^{1/4}\rceil) proves B/N^4\leq\mathrm{tolerance}. This is the case m=4 of the planner for an error model B/N^m of any order m>0, and it is the rule-independent planner behind every fourth-order uniform composite rule.

Lean code for Theorem10.116●1 theorem
  • complete
    theorem CAS.Continuum.PanelPlan.errorConstant_div_requiredPanels_pow_le {m : ℕ}
      (hm : m ≠ 0) {denominator a b C tolerance : ℝ}
      (htolerance : 0 < tolerance) :
      CAS.Continuum.PanelPlan.errorConstant m denominator a b C /
          ↑(CAS.Continuum.PanelPlan.requiredPanels m denominator a b C
                tolerance) ^
            m ≤
        tolerance
    theorem CAS.Continuum.PanelPlan.errorConstant_div_requiredPanels_pow_le
      {m : ℕ} (hm : m ≠ 0)
      {denominator a b C tolerance : ℝ}
      (htolerance : 0 < tolerance) :
      CAS.Continuum.PanelPlan.errorConstant m
            denominator a b C /
          ↑(CAS.Continuum.PanelPlan.requiredPanels
                m denominator a b C
                tolerance) ^
            m ≤
        tolerance

    For a positive order m and a positive tolerance, the planned panel count reduces the error model B / N^m to at most the tolerance.

Proof for Theorem 10.116
uses 0

If B<0 the bound holds for every N. Otherwise the ceiling construction gives N\geq(B/\tau)^{1/4} and N\geq1. Positivity permits raising the first inequality to the fourth power, yielding N^4\geq B/\tau. Rearranging with \tau>0 proves B/N^4\leq\tau.

Theorem10.117
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 2
Reverse dependency previews
Preview
Theorem 10.118
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

For exact rational error data, the executable planner rounds B/\mathrm{tolerance} upward and takes one more than the integer fourth root of the result (Mathlib's Nat.nthRoot 4). The resulting positive natural panel count satisfies the same fourth-order inequality without evaluating a noncomputable real root.

Lean code for Theorem10.117●1 theorem
  • complete
    theorem CAS.Continuum.PanelPlan.div_ratRequiredPanels_pow_le {m : ℕ}
      (hm : m ≠ 0) {errorConstant tolerance : ℚ}
      (htolerance : 0 < tolerance) :
      errorConstant /
          ↑(CAS.Continuum.PanelPlan.ratRequiredPanels m errorConstant
                tolerance) ^
            m ≤
        tolerance
    theorem CAS.Continuum.PanelPlan.div_ratRequiredPanels_pow_le
      {m : ℕ} (hm : m ≠ 0)
      {errorConstant tolerance : ℚ}
      (htolerance : 0 < tolerance) :
      errorConstant /
          ↑(CAS.Continuum.PanelPlan.ratRequiredPanels
                m errorConstant tolerance) ^
            m ≤
        tolerance

    For a positive order m and a positive tolerance, the executable panel count reduces the error model B / N^m below the tolerance, for every rational B.

Proof for Theorem 10.117
uses 0

Mathlib's Nat.lt_pow_nthRoot_add_one says that one more than the integer fourth root of \lceil B/\tau\rceil has fourth power above it, so the chosen natural's fourth power is at least the exact rational ratio. Rearranging with \tau>0 gives the same tolerance estimate as the real planner.

Theorem10.118
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Theorem 10.112
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 0✓L∃∀N

Substituting the sharp Simpson denominator D=2880 into the executable rational planner produces a panel count whose composite error bound C(b-a)^5/(2880N^4) is at most the requested rational tolerance.

Lean code for Theorem10.118●1 theorem
  • complete
    theorem CAS.Continuum.PanelPlan.div_ratRequiredPanels_pow_le {m : ℕ}
      (hm : m ≠ 0) {errorConstant tolerance : ℚ}
      (htolerance : 0 < tolerance) :
      errorConstant /
          ↑(CAS.Continuum.PanelPlan.ratRequiredPanels m errorConstant
                tolerance) ^
            m ≤
        tolerance
    theorem CAS.Continuum.PanelPlan.div_ratRequiredPanels_pow_le
      {m : ℕ} (hm : m ≠ 0)
      {errorConstant tolerance : ℚ}
      (htolerance : 0 < tolerance) :
      errorConstant /
          ↑(CAS.Continuum.PanelPlan.ratRequiredPanels
                m errorConstant tolerance) ^
            m ≤
        tolerance

    For a positive order m and a positive tolerance, the executable panel count reduces the error model B / N^m below the tolerance, for every rational B.

Proof for Theorem 10.118
uses 0

Apply the rational fourth-order planner with denominator 2880, the error constant B=C(b-a)^5/2880 of the composite Simpson theorem: its panel count N satisfies B/N^4\leq\tau in exact rational arithmetic.

Theorem10.119
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Theorem 10.113
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 0✓L∃∀N

Substituting the two-point Gauss–Legendre denominator D=4320 gives the corresponding executable panel count, whose composite error bound C(b-a)^5/(4320N^4) is at most the requested rational tolerance.

Lean code for Theorem10.119●1 theorem
  • complete
    theorem CAS.Continuum.PanelPlan.div_ratRequiredPanels_pow_le {m : ℕ}
      (hm : m ≠ 0) {errorConstant tolerance : ℚ}
      (htolerance : 0 < tolerance) :
      errorConstant /
          ↑(CAS.Continuum.PanelPlan.ratRequiredPanels m errorConstant
                tolerance) ^
            m ≤
        tolerance
    theorem CAS.Continuum.PanelPlan.div_ratRequiredPanels_pow_le
      {m : ℕ} (hm : m ≠ 0)
      {errorConstant tolerance : ℚ}
      (htolerance : 0 < tolerance) :
      errorConstant /
          ↑(CAS.Continuum.PanelPlan.ratRequiredPanels
                m errorConstant tolerance) ^
            m ≤
        tolerance

    For a positive order m and a positive tolerance, the executable panel count reduces the error model B / N^m below the tolerance, for every rational B.

Proof for Theorem 10.119
uses 0

Apply the same executable fourth-order planner with denominator 4320, the error constant of the composite two-point Gauss–Legendre theorem: its panel count N satisfies C(b-a)^5/(4320N^4)\leq\tau in exact rational arithmetic.

Theorem10.120
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 3
Statement dependency previews
Preview
Theorem 10.112
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 0✓L∃∀N

Given root-interval smoothness and certified panelwise fourth-derivative bounds, the planned Simpson and two-point Gauss–Legendre constructors return ordinary QuadratureCerts whose semantic error is at most the user's positive tolerance. The public conclusion refers only to the integral, computed rule value, and tolerance; panel selection remains an internal construction.

For either planned fourth-order rule Q_{N(\tau)},

\left|\int_a^b f(x)\,dx-Q_{N(\tau)}(f)\right| \leq\tau.

Lean code for Theorem10.120●3 declarations
  • complete
    theorem CAS.Continuum.PanelRule.compositeToTolerance_sound_le {m : ℕ}
      (R : CAS.Continuum.PanelRule m) (hm : m ≠ 0) {f : ℝ → ℝ}
      {a b C tolerance : ℝ} (hab : a < b)
      (hf : ContDiffOn ℝ (↑m) f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn m f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r) (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C)
      (htolerance : 0 < tolerance) :
      ‖(∫ (x : ℝ) in a..b, f x) -
            (R.compositeToTolerance hab hf bounder ⋯).value‖ ≤
        tolerance
    theorem CAS.Continuum.PanelRule.compositeToTolerance_sound_le
      {m : ℕ} (R : CAS.Continuum.PanelRule m)
      (hm : m ≠ 0) {f : ℝ → ℝ}
      {a b C tolerance : ℝ} (hab : a < b)
      (hf : ContDiffOn ℝ (↑m) f (Set.Icc a b))
      (bounder :
        CAS.Continuum.IteratedDerivativeBounderOn
          m f (Set.Icc a b))
      (hbound :
        ∀ {l r : ℝ} (hlr : l < r)
          (hsub : Set.Icc l r ⊆ Set.Icc a b),
          bounder.bound hlr hsub ≤ C)
      (htolerance : 0 < tolerance) :
      ‖(∫ (x : ℝ) in a..b, f x) -
            (R.compositeToTolerance hab hf
                bounder ⋯).value‖ ≤
        tolerance

    For a positive order and a positive tolerance, the planned composite value approximates the integral within the tolerance.

  • def CAS.Continuum.simpsonRule.fourthOrder : CAS.Continuum.PanelRule 4
    def CAS.Continuum.simpsonRule.fourthOrder :
      CAS.Continuum.PanelRule 4

    Simpson's rule as a panel rule of order 4, with its sharp one-panel constant 2880.

  • def CAS.Continuum.gaussLegendreTwoRule.fourthOrder :
      CAS.Continuum.PanelRule 4
    def CAS.Continuum.gaussLegendreTwoRule.fourthOrder :
      CAS.Continuum.PanelRule 4

    The two-point Gauss-Legendre rule as a panel rule of order 4, with its sharp one-panel constant 4320.

Proof for Theorem 10.120
uses 0

The planner chooses a positive panel count whose formula is below \tau. Build the corresponding composite Simpson or Gauss–Legendre certificate from the supplied smoothness and derivative bounds, then compose its analytic error estimate with the planner inequality.

Definition10.121
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 2
Reverse dependency previews
Preview
Theorem 10.122
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

Mathlib's composite trapezoidal rule is exposed through the common certificate interface. Assume f is C^2 on S=[\min(a,b),\max(a,b)] and |D^2_S f(x)|\leq\zeta for every real x, where D^2_S denotes the second iterated within-derivative. For N>0 subintervals the error is at most |b-a|^3\zeta/(12N^2).

Lean code for Definition10.121●1 definition
  • def CAS.Continuum.QuadratureCert.trapezoidal {f : ℝ → ℝ} {a b ζ : ℝ} {N : ℕ}
      (hf : ContDiffOn ℝ 2 f (Set.uIcc a b))
      (hsecond : ∀ (x : ℝ), |iteratedDerivWithin 2 f (Set.uIcc a b) x| ≤ ζ)
      (hN : 0 < N) : CAS.Continuum.QuadratureCert f a b
    def CAS.Continuum.QuadratureCert.trapezoidal
      {f : ℝ → ℝ} {a b ζ : ℝ} {N : ℕ}
      (hf : ContDiffOn ℝ 2 f (Set.uIcc a b))
      (hsecond :
        ∀ (x : ℝ),
          |iteratedDerivWithin 2 f
                (Set.uIcc a b) x| ≤
            ζ)
      (hN : 0 < N) :
      CAS.Continuum.QuadratureCert f a b

    The composite trapezoidal rule as a quadrature certificate.

    The rule uses N subintervals and therefore N + 1 function evaluations. The error budget is

    |b-a|^3 * ζ / (12 * N^2),

    where ζ bounds the absolute value of iteratedDerivWithin 2 f [[a,b]] at every real point, as required by the underlying mathlib theorem.

Theorem10.122
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1used by 1✓L∃∀N

Under these same regularity and derivative-bound hypotheses, for a positive tolerance the checked planner chooses N=\max(1,\lceil\sqrt{B/\mathrm{tolerance}}\rceil) with B=|b-a|^3\zeta/12. The bound forces \zeta\ge 0, and the resulting composite trapezoidal certificate has error at most the requested tolerance. The square-root choice retains the standard O(\mathrm{tolerance}^{-1/2}) mesh scaling.

Lean code for Theorem10.122●1 theorem
  • complete
    theorem CAS.Continuum.QuadratureCert.trapezoidalToTolerance_sound_le {f : ℝ → ℝ}
      {a b ζ tolerance : ℝ} (hf : ContDiffOn ℝ 2 f (Set.uIcc a b))
      (hsecond : ∀ (x : ℝ), |iteratedDerivWithin 2 f (Set.uIcc a b) x| ≤ ζ)
      (htolerance : 0 < tolerance) :
      ‖(∫ (x : ℝ) in a..b, f x) -
            (CAS.Continuum.QuadratureCert.trapezoidalToTolerance hf
                hsecond).value‖ ≤
        tolerance
    theorem CAS.Continuum.QuadratureCert.trapezoidalToTolerance_sound_le
      {f : ℝ → ℝ} {a b ζ tolerance : ℝ}
      (hf : ContDiffOn ℝ 2 f (Set.uIcc a b))
      (hsecond :
        ∀ (x : ℝ),
          |iteratedDerivWithin 2 f
                (Set.uIcc a b) x| ≤
            ζ)
      (htolerance : 0 < tolerance) :
      ‖(∫ (x : ℝ) in a..b, f x) -
            (CAS.Continuum.QuadratureCert.trapezoidalToTolerance
                hf hsecond).value‖ ≤
        tolerance

    For a C² function f on [[a, b]] with |f''| ≤ ζ and a positive tolerance, the planned composite trapezoidal value is within the tolerance of ∫ₐᵇ f.

Proof for Theorem 10.122
uses 0

The ceiling square-root choice ensures N^2\geq B/\tau and N>0. Rearranging gives B/N^2\leq\tau; substituting the trapezoidal error constant B=|b-a|^3\zeta/12 into the composite trapezoidal certificate proves the result.

Theorem10.123
Group: Certified continuous computation (105)
Group member previews
Preview
Definition 10.36
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Definition 10.83
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
Used by 2
Reverse dependency previews
Preview
Theorem 10.74
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

A QuadratureTree records a rule-independent binary subdivision. Each leaf contains an ordinary local quadrature certificate and integrability evidence; adjacent children compose by interval-integral additivity. The root therefore certifies the sum of all leaf values with the sum of their error budgets. An adaptive tactic or external checker may choose the tree; soundness does not depend on that choice.

If \mathcal L(T) is the set of leaves, then the root certificate states

\left\|\int_a^b f(x)\,dx -\sum_{\ell\in\mathcal L(T)}Q_\ell\right\| \leq\sum_{\ell\in\mathcal L(T)}E_\ell.

Lean code for Theorem10.123●1 theorem
  • theorem CAS.Continuum.QuadratureTree.sound.{u_1} {E : Type u_1}
      [NormedAddCommGroup E] [NormedSpace ℝ E] {f : ℝ → E} {a b : ℝ}
      (tree : CAS.Continuum.QuadratureTree f a b) :
      ‖(∫ (x : ℝ) in a..b, f x) - tree.toCert.value‖ ≤ tree.toCert.error
    theorem CAS.Continuum.QuadratureTree.sound.{u_1}
      {E : Type u_1} [NormedAddCommGroup E]
      [NormedSpace ℝ E] {f : ℝ → E} {a b : ℝ}
      (tree :
        CAS.Continuum.QuadratureTree f a b) :
      ‖(∫ (x : ℝ) in a..b, f x) -
            tree.toCert.value‖ ≤
        tree.toCert.error

    The root certificate carries the tree's full integral error theorem.

Proof for Theorem 10.123
uses 0

Induct on the binary tree. A leaf is exactly its stored local certificate. At a branch, interval-integral additivity splits the root integral across the two adjacent children; apply the two inductive estimates and the triangle inequality. Their values and budgets add, giving the recursively stored root certificate.