gauss_legendre

std.seq.gauss_legendre · Level L3

The n-point Gauss–Legendre rule on [−1, 1], n the length of points (only its length is read): nodes x ascending and weights w, so that Σ wᵢ·f(xᵢ) is exact for every polynomial of degree up to 2n − 1. By Golub–Welsch: the nodes are the eigenvalues of the symmetric tridiagonal Jacobi matrix with off-diagonal βₘ = m/√(4m² − 1), then one Newton step on Pₙ, which is zero in exact arithmetic and brings each node to within about a unit of roundoff; each weight is 2(1 − x²)/(n·Pₙ₋₁(x))², with Pₙ and Pₙ₋₁ from the three-term recurrence.

x = eig(J), Jₘ₋₁,ₘ = m/√(4m² − 1); w = 2(1 − x²)/(n·Pₙ₋₁(x))²

Signature

gauss_legendre(points: f64[n]) → f64[n], f64[n]

Structure

The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks another library function this one runs — called once, or by Scan once per element; select it to open that function.

pointsf64[n]IotaiSizenReshapeicReshapeirSubtractdMaximummNegatendMultiplymm4.0Maximumad1.0Multiplymm4EqualadjSubtractqMaximumqsSqrtroot0.0DividebetaWhereJEighValuesx0Multiplyxx0Multiplyp00Subtractxx1Addq00Scan·legendre_stepbefore0, at0Slicelast_b0Slicelast_a0Reshapepm0Reshapepn0MultiplyxpnSubtractliftMultiplynliftDividedpDividestepSubtractxMultiplyx2Multiplyp02.0SubtractomxAddq0MultiplynumScan·legendre_stepbefore, atSlicelastReshapepn1MultiplynpnMultiplydenDividewwf64[n]xf64[n]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size.
  • Agrees with the reference np.polynomial.legendre.leggauss(n); exactly: the roots of Pₙ by Newton's method at 100 digits to 80 digits (100-digit arithmetic), on all 40 test cases.
  • All 280 float64 results inside the running error bound; the closest uses 3% of it.
  • Interpreter and NumPy backend return bit-identical results.
  • At float32 too: the 40 test cases rounded to float32, and 40 of them inside the running error bound at u = 2⁻²⁴; the closest uses 2% of it.
Accuracy in detail
correctly rounded (the float64 nearest the exact value)
56%
bit-equal to the NumPy formula in float64
54%
largest error, in units in the last place
143

Large ulp counts appear where a result is tiny next to the numbers it is computed from (after cancellation, for example), so one unit in the last place is tiny too; the absolute error is still inside the bound. Results within their own error of zero are not counted.

Note

The nodes are the eigenvalues of a matrix whose eigenvalues are well separated, so their error bound stays near u. The weights avoid the eigenvectors: they would need a sign convention, and the Legendre matrix's eigenvectors are symmetric or antisymmetric, so their largest components tie.

Identity

sha256:d2baa11aa1fc3f813488f155668d1ddb17fd8072e7d8379db2794fb09911ecf4

The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.

Control handle

Symbol
Ω:std.seq.gauss_legendre · Ω:gauss_legendre
Pins
sha256:9856a8cd3f8b67110ca7c16558e788adaf306557ea58dc392a09f04a6c0d239ethis graph and the 1 it reaches through calls
Evidence
sha256:1777d6d9871bc2ee70f4cdbca48c69c1b34c38bb0ec4be19d3473e79b9897c37the hash of its verification record
Needs
no capability: a pure function

Through NOVA’s control layer, the symbol launches this function only while the program still matches what it pins: a change to this graph, or to any graph it reaches, needs a migration first.

ΣEML 2026

Efficient New Language — a high-density semantic overlay for humans and AI agents.

This site’s demos run on the real EML toolchain, in your browser.

© 2026 EveMissLab (一言諾科技有限公司) / Neo.K. All rights reserved.