The "exact value" is a reference computed with a finely subdivided composite Simpson rule.
Cyan = integrand f(x) / shaded = the area being integrated / orange vertical line = sample point xᵢ (circle size = weight wᵢ)
X axis = number of points n / Y axis = log₁₀|absolute error| (yellow dot = current n, lower is more accurate)
Gauss-Legendre quadrature approximates an integral as a sum of function values at sample points times weights. What sets it apart from the equally spaced trapezoidal and Simpson rules is that it optimizes both the positions of the sample points and the weights.
The n-point Gauss quadrature rule. xᵢ are the sample points, wᵢ are the weights:
$$\int_a^b f(x)\,dx \approx \sum_{i=1}^{n} w_i\,f(x_i)$$Linear transformation of the standard-interval [−1, 1] points ξᵢ and weights to an arbitrary interval [a, b]:
$$x_i = \frac{b-a}{2}\,\xi_i + \frac{a+b}{2}, \qquad w_i = \frac{b-a}{2}\,\hat{w}_i$$The sample points ξᵢ are the roots of the n-th Legendre polynomial Pₙ(ξ), and the n-point rule integrates polynomials up to degree 2n−1 exactly.
Because it uses 2n free parameters (n positions plus n weights), it can satisfy 2n exactness conditions. This is why it beats equally spaced methods.