Quadrature rule optimization

A compact five-node rule for estimating one-dimensional integrals, improved against a fixed public test suite. The report separates the acceptance score from direct residual errors so the gain can be inspected, replayed, and challenged.

Abstract

This note reports a compact five-node rule for estimating one-dimensional integrals on the unit interval. Relative to the fixed public baseline, the accepted rule reduces the frozen lower-is-better acceptance score by 83.37%. On the most improved public residual component, the direct numerical error falls from 0.3634 to 0.0010, a 99.72% reduction.

The public claim is bounded to the stated one-dimensional analytic test contract. The acceptance score is the retention objective used by the run; the residual errors are the direct numerical readout. Both surfaces are shown so the candidate can be audited without presenting the rule as a universal integration method.

1. Problem formulation

Numerical integration estimates the area accumulated under a function. The conceptual object is an integral of an arbitrary scalar function \(g\) on the unit interval:

\[ I[g] = \int_{0}^{1} g(x)\,dx. \]
(1)
Conceptual integral of an arbitrary g(x) 1 0 1 x g(x)
Figure 1. Conceptual setup for the exact integral. The shaded surface denotes \(I[g]\) for an arbitrary function \(g\), separate from the public integrand suite used by the evaluation contract.

The exact area is rarely the object a production system computes directly. Instead, a quadrature rule \(r\) replaces the continuous integral with a finite set of weighted point evaluations. The nodes \(x_i\) determine where the function is sampled and the normalized weights \(w_i\) determine how much each sample contributes:

\[ Q_r[g] = \sum_{i=1}^{n} w_i\,g(x_i), \qquad x_i \in [0,1], \qquad \sum_{i=1}^{n} w_i = 1. \]
(2)
Weighted point evaluations 1 0 1 x g(x)
Figure 2. Quadrature replaces the continuous integral with weighted point evaluations. The blue cells are the estimate \(Q_r[g]\): each cell width represents \(w_i\), each height is \(g(x_i)\), and each area is one contribution \(w_i g(x_i)\).

The residual is the direct error a reader can interpret without knowing the optimization machinery. It compares the analytic integral with the quadrature estimate. The visual residual can have regions where the rule overestimates and regions where it underestimates; the reported scalar residual is the absolute value of the net difference:

\[ e(r;g) = \left|Q_r[g] - I[g]\right|. \]
(3)
Residual between I[g] and Qr[g] 1 0 1 x g(x)
Figure 3. Conceptual residual diagnostic. Local over- and under-estimation can coexist; the reported scalar residual is the absolute net difference between the quadrature estimate and the exact integral.

Figures 1-3 introduce the objects used by the report. They are deliberately conceptual: the actual acceptance contract below uses a fixed public suite of three analytic functions, not the illustrative function \(g\).

2. Evaluation contract

The evaluation contract is what makes the comparison fair. It is fixed before candidate comparison, so the accepted rule cannot change the test after seeing the result. Each candidate rule is scored on the same public analytic integrand suite:

\[ \begin{aligned} f_1(x) &= \sin(\pi x),\\ f_2(x) &= \sqrt{x},\\ f_3(x) &= \log(1+x). \end{aligned} \]
(4)

For each function \(f_j\), the evaluator computes the residual by specializing Equation (3) to the contract integrand:

\[ e_j(r) = \left|Q_r[f_j] - I[f_j]\right|. \]
(5)

The run objective \(J(r)\) is the acceptance score used during the run. It is a lower-is-better aggregate of the public residual components:

\[ J(r) = \sum_{j=1}^{3} \alpha_j\,e_j(r). \]
(6)
Component Integrand Analytic reference Baseline residual
1 \(\sin(\pi x)\) \(2/\pi\) 0.363380
2 \(\sqrt{x}\) \(2/3\) 0.040440
3 \(\log(1+x)\) \(2\log 2 - 1\) 0.019171
Table 1. Evaluation contract surface. Each row defines one public residual component and the residual of the fixed run baseline.

The public bundle identifies the integrand suite and objective direction, but it does not expose numeric component weights \(\alpha_j\). Table 1 therefore fixes the public residual components without inventing unpublished objective weights or mixing in accepted-candidate outcomes. In plain terms: the table shows what was tested and where the baseline started; it does not ask the reader to trust an unpublished weighting scheme.

Run baseline

The run baseline \(r_0\) is the first public rule in the curated trace. It fixes the comparison point before candidate selection. Every improvement reported later is measured relative to this same baseline.

normalized weight wi run baseline Run baseline 0 0.5 1 0 0.5 1 node position xi
Figure 4. Run baseline \(r_0\). This fixed rule anchors the residual and objective improvements reported later.

All objective and residual improvements reported below are measured against this same run baseline, whose contracted objective is \(J(r_0)=688.676231\).

3. Accepted candidate

The accepted candidate is the five-node rule shown in Figure 5. This is the object being reported: five sample locations and five normalized weights. The figure is the primary definition of the node placement and weights; it should be read against the run baseline in Figure 4 before interpreting the objective change.

normalized weight wi accepted Accepted rule 0 0.1 0.2 0.25 0 0.5 1 node position xi
Figure 5. Accepted five-node rule in node-position and normalized-weight coordinates. The near-uniform weights and inward node placement define the candidate evaluated below.

Candidate construction

The candidate is intentionally small enough to audit. The implementation maps source nodes \(\xi_i\) on \([-1,1]\) inward with a fixed remapping exponent \(p=1.7\), maps them back to the unit interval, and renormalizes the weights:

\[ \tilde{\xi}_i=\operatorname{sign}(\xi_i)\,|\xi_i|^p, \qquad x_i=\frac{\tilde{\xi}_i+1}{2}, \qquad p=1.7. \]
(7)

The accepted implementation is included here because it is part of the candidate definition, not only a replay appendix. The code is short enough for a reader to verify that the reported rule is generated by the stated transformation.

1def quadrature_rule(spec: QuadratureSpec) -> QuadratureRule:2    """3    Construct a quadrature rule using Gauss-Legendre nodes with deterministic inward remapping.4    """5    n = max(1, int(spec.n_points))6    if n == 1:7        return QuadratureRule(nodes=[0.5], weights=[1.0])8 9    nodes, weights = np.polynomial.legendre.leggauss(n)10    if n >= 2:11        alpha = 1.712        nodes = np.sign(nodes) * (np.abs(nodes) ** alpha)13 14    mapped_nodes = 0.5 * (nodes + 1.0)15    mapped_weights = 0.5 * weights16    rule = QuadratureRule(nodes=list(mapped_nodes), weights=list(mapped_weights))17 18    if getattr(spec, "enforce_symmetry", False):19        n_half = n // 220        for i in range(n_half):21            avg_node = 0.5 * (rule.nodes[i] + (1.0 - rule.nodes[n - 1 - i]))22            rule.nodes[i] = avg_node23            rule.nodes[n - 1 - i] = 1.0 - avg_node24            avg_weight = 0.5 * (rule.weights[i] + rule.weights[n - 1 - i])25            rule.weights[i] = avg_weight26            rule.weights[n - 1 - i] = avg_weight27 28    return _renormalize(rule)
Listing 1. Accepted candidate implementation. Full executable artifact.

4. Results

The result is read in two layers. Figure 6 and Table 2 show the governed acceptance objective; Figure 7 and Table 3 show where the accepted rule leaves residual error on the public functions.

Best-so-far acceptance objective (lower is better) scored candidate best-so-far objective baseline accepted 0 200 400 600 700 0 20 40 60 84 candidate index J(r)
Figure 6. Objective trace for the curated public chain. Faint points are scored candidates, the solid line is retained best-so-far, and rings mark baseline and accepted.
Metric Run baseline Accepted Change
Acceptance objective \(J(r)\) 688.676231 114.514813 -574.161418
Relative objective change reference 83.372% 83.372% reduction
Table 2. Reported objective comparison under the frozen acceptance contract; lower values are better.

The residual readout is the numerical check on the objective score. The accepted candidate does not erase every residual; it materially reduces the measured behavior under this contract.

Residual location diagnostic run baseline sample accepted samples integrand curve sin(πx) run baseline ej 0.363380 accepted ej 0.001029 0 1 xi √x run baseline ej 0.040440 accepted ej 0.000614 0 1 xi log(1+x) run baseline ej 0.019171 accepted ej 0.000282 0 1 xi
Figure 7. Residual location by public integrand. Grey marks the run baseline, blue marks the accepted rule, and hatching shows local accepted-rule residual area.
Integrand Baseline residual Accepted residual Reduction
\(\sin(\pi x)\) 0.363380 0.001029 99.717%
\(\sqrt{x}\) 0.040440 0.000614 98.482%
\(\log(1+x)\) 0.019171 0.000282 98.529%
Table 3. Representative residual errors.

5. Limitations

This is a bounded benchmark on a fixed one-dimensional analytic suite. The result says that this accepted five-node rule improved this contract. It does not establish superiority for arbitrary integrands, discontinuous functions, oscillatory functions outside the public suite, endpoint singularities not represented by the contract, multidimensional integration, or production workloads with different stability requirements.

The contracted score is intentionally narrow. A lower value of \(J(r)\) is evidence that the accepted candidate improved under this contract, not evidence that every downstream quantity of interest improved. Because the public bundle does not expose numeric component weights \(\alpha_j\), readers should interpret the residual table as the transparent scientific readout alongside the aggregate score.

External validity is deliberately left open. A reader should rerun an evaluation contract that explicitly contains the cases they care about before transferring the node placement to another integration setting.

6. Reproducibility

The public bundle includes the evaluation contract, accepted candidate, curated evolution trace, metrics, provenance, residual readout, and replay surface. The article uses those artifacts as the source for the figures, tables, and accepted implementation.

An animated replay of the same public trace is available at the run page. It is a presentation layer over the same artifacts, not a separate result, and excludes non-public proposal context.

Replaying the result should use the same analytic integrand suite, the same objective definition, the same run baseline, and the same lower-is-better direction. Changing any of those items creates a new evaluation, not a replay of this result.

The source bundle is available in Göther Labs results repository.