Connect via MCP →

Enter Calculation

Formula

Advertisement

Results

20-Point Gauss-Legendre Rule on [-1, 1]
2
sum of weights (should equal 2)
i Node x_i Weight w_i
1 -0.993128599185095 0.017614007139152
2 -0.963971927277914 0.040601429800387
3 -0.912234428251326 0.062672048334109
4 -0.839116971822219 0.083276741576705
5 -0.746331906460151 0.10193011981724
6 -0.636053680726515 0.118194531961518
7 -0.510867001950827 0.131688638449176
8 -0.37370608871542 0.142096109318382
9 -0.227785851141645 0.149172986472604
10 -0.076526521133497 0.152753387130726
11 0.076526521133497 0.152753387130726
12 0.227785851141645 0.149172986472604
13 0.37370608871542 0.142096109318382
14 0.510867001950827 0.131688638449176
15 0.636053680726515 0.118194531961518
16 0.746331906460151 0.10193011981724
17 0.839116971822219 0.083276741576705
18 0.912234428251326 0.062672048334109
19 0.963971927277914 0.040601429800387
20 0.993128599185095 0.017614007139152

What is the Gauss-Legendre Quadrature Calculator?

This tool computes the nodes (abscissas) and weights of the n-point Gauss-Legendre quadrature rule on the reference interval [-1, 1]. Gauss-Legendre quadrature is a numerical integration method that approximates a definite integral as a weighted sum of function values: the integral of \(f(x)\) from \(-1\) to \(1\) is approximately the sum over \(i\) of \(w_i\) times \(f(x_i)\). With just \(n\) points it integrates any polynomial up to degree \(2n-1\) exactly, making it far more accurate than equally-spaced rules like the trapezoidal or Simpson methods.

How to Use It

Pick the order \(n\) (the number of points, 2 to 100) and optionally the number of significant digits to display. The calculator returns a table of \(n\) rows, each with a node \(x_i\) and its weight \(w_i\). The nodes are symmetric about 0 and all lie strictly inside \((-1, 1)\); the weights are all positive and sum to exactly 2, the length of the interval. To integrate over an arbitrary interval \([a, b]\), map each node with \(t_i = \frac{b-a}{2} x_i + \frac{a+b}{2}\) and multiply each weight by \(\frac{b-a}{2}\).

The Formula Explained

The nodes are the \(n\) roots of the Legendre polynomial \(P_n(x)\), built with Bonnet's recurrence: \(P_0=1\), \(P_1=x\), and \(P_k = \frac{(2k-1) x P_{k-1} - (k-1) P_{k-2}}{k}\). Each weight is $$w_i = \frac{2}{\left(1 - x_i^{2}\right)\left[P_n^{\prime}(x_i)\right]^{2}},$$ where the derivative is \(P_n^{\prime}(x) = \frac{n\left(x P_n(x) - P_{n-1}(x)\right)}{x^2 - 1}\). Roots are found by Newton's method seeded at \(x = \cos\left(\frac{\pi (i - 0.25)}{n + 0.5}\right)\), which converges in a few iterations.

Smooth function over [-1,1] sampled at several non-uniform symmetric nodes with weighted contributions
Gauss-Legendre quadrature approximates the integral as a weighted sum of function values at specially chosen nodes.

Worked Example (n = 3)

The roots of \(P_3\) are \(x = 0\) and \(x = \pm\sqrt{3/5} = \pm 0.7745966692\). The weight at \(x = 0\) is \(\frac{8}{9} = 0.888888889\), and the weight at each \(x = \pm 0.7745966692\) is \(\frac{5}{9} = 0.555555556\). The weights sum to $$\frac{5}{9} + \frac{8}{9} + \frac{5}{9} = 2,$$ and this 3-point rule integrates polynomials up to degree 5 exactly.

Three symmetric Gauss-Legendre nodes on [-1,1] with the central node carrying a larger weight
The 3-point rule uses a central node and two symmetric outer nodes, with the central node given the largest weight.

FAQ

Why do the weights sum to 2? Integrating the constant function \(f(x) = 1\) over \([-1, 1]\) gives 2, and quadrature must reproduce constants exactly, so the weights must total the interval length.

How accurate are the values? This is a double-precision rebuild giving about 15 significant digits. Display options requesting more digits are rounded to what double precision can represent.

What is the maximum degree integrated exactly? An \(n\)-point rule is exact for all polynomials of degree up to \(2n-1\).

Last updated: