Experience Gauss-Legendre quadrature, the rule the finite element method uses to integrate element stiffness matrices. Change the number of integration points (1-3) and the polynomial coefficients to see the numerical integral, the exact value and the error update in real time, and grasp intuitively why an n-point rule is exact up to degree 2n-1.
Parameters
Integration points n
Number of Gauss-Legendre points. n points are exact to degree 2n-1
Constant term c0
Constant term of the integrand f(ξ)
Linear term c1 (×ξ)
Odd term — contributes nothing to the exact integral over [-1,1]
Quadratic term c2 (×ξ²)
Degree 2 and above produce error with a 1-point rule
Cubic term c3 (×ξ³)
Odd term. Highest degree a 2-point rule still integrates exactly
Quartic term c4 (×ξ⁴)
Degree 4. First captured exactly by a 3-point rule
Results
—
Numerical integral I_num
—
Exact value I_exact
—
Error I_num − I_exact
—
Integration points n
—
Exact degree 2n−1
—
Verdict
—
Integrand and Gauss points — integral visualisation
The blue curve is the integrand f(ξ) and the shading is the area being integrated. The orange dots are the Gauss points, with dot size proportional to the weight w_i. A vertical line rises from each point to the curve.
Gauss-Legendre quadrature. On the reference coordinate ξ∈[-1,1], the function values at the n Gauss points ξ_i are multiplied by weights w_i and summed.
The n points and n weights give 2n degrees of freedom, enough to reproduce the 2n-dimensional polynomial space (degree up to 2n-1) exactly. FEM exploits this to evaluate the element-stiffness integral with only a handful of Gauss points.
What is the Gauss Quadrature Simulator?
🙋
"Gauss quadrature" is one way to do integration on a computer, right? How is it different from approximating with trapezoids?
🎓
Yes, it is a numerical-integration method. The trapezoidal and Simpson rules take points at equal spacing and add up the function values. Gauss quadrature has a different idea — it moves the point locations themselves to the "optimal" places. With the same number of points it then becomes far more accurate than the trapezoidal rule. That accuracy is exactly why FEM uses it as standard.
🙋
Move the point locations — what does that mean? If you can move them freely, surely you could make it as good as you like?
🎓
It is not free. With n points you have n locations and n weights — 2n knobs in total. You set those 2n knobs by solving simultaneous equations so that every polynomial up to degree 2n-1 is integrated exactly. For 2 points, for example, the locations come out at ξ=±0.5774 with both weights equal to 1. Use that combination and any polynomial up to degree 3 integrates with zero error. Set the select on the left to "2 points" and the coefficients to c0=1, c2=3, c4=2. Switch to 3 points and you will see the error snap to zero.
🙋
It really does — with 2 points the error is about −0.36, but with 3 points it became almost zero! Why didn't 2 points work?
🎓
The f(ξ) you just entered has a ξ⁴ term (c4=2), so it is a degree-4 polynomial. A 2-point rule integrates exactly only up to 2n-1 = 3. The degree-4 term is "beyond what 2 points can capture", so an error appears. With 3 points the rule is exact up to 2n-1 = 5, so the degree-4 term integrates perfectly and the error vanishes. The relationship between the integrand degree and the points you need — that is the single most important point in using Gauss quadrature.
🙋
I see. So in the finite element method, how is this point count decided? Wouldn't using plenty of points always be safe?
🎓
Too many is not good either. FEM computes the element stiffness matrix K = ∫B^T D B dV with Gauss quadrature. The point count that exactly integrates the integrand of that degree is called full integration. Adding more points just makes the computation slower without raising accuracy. Conversely there is a technique of deliberately removing one point — reduced integration — which prevents the "shear locking" that occurs when bending thin plates. But remove too many and you get a troublesome deformation called the hourglass mode. So a feel for "the right number of points" is essential for an FEM analyst.
🙋
It is also interesting that moving the odd terms (c1, c3) does not change the exact value. Why is that?
🎓
Good observation. It is because the integration interval [-1,1] is symmetric about the origin. Odd functions such as ξ and ξ³ have opposite signs on the left and right halves and cancel out. So the exact integrals ∫ξ dξ and ∫ξ³ dξ are exactly zero over [-1,1]. That is why only c0, c2 and c4 appear in the exact-value formula. The numerical value itself stays consistent too, because when the Gauss points are placed symmetrically the odd terms cancel automatically.
Frequently Asked Questions
Gauss quadrature (Gauss-Legendre quadrature) is a numerical-integration method that approximates an integral ∫f(ξ)dξ by the weighted sum Σw_i·f(ξ_i) of function values at a few points. By choosing the point locations ξ_i and weights w_i optimally, an n-point rule integrates polynomials up to degree 2n-1 exactly. Because it reaches high accuracy with fewer points than the trapezoidal or Simpson rules, it has become the standard numerical-integration method in the finite element method.
FEM computes the element stiffness matrix K = ∫B^T D B dV, but for isoparametric elements the integrand becomes a complicated rational function that cannot be integrated analytically. So the integral is evaluated on the reference domain [-1,1] with Gauss quadrature: the integrand is sampled at a few integration points (Gauss points) and combined with weights to obtain K numerically. Fewer points mean faster computation, and the point count is chosen so that the required polynomial degree is integrated exactly.
An n-point Gauss rule integrates polynomials up to degree 2n-1 exactly. So for an integrand of polynomial degree p, choosing the smallest n that satisfies n ≥ (p+1)/2 makes the error zero. A degree-4 polynomial needs 2n-1 ≥ 4, i.e. n = 3. In FEM the point count that integrates the element stiffness matrix exactly is called full integration, and a smaller count is called reduced integration — sometimes used deliberately to avoid shear locking.
Reduced integration evaluates the element stiffness matrix with fewer Gauss points than would integrate it exactly. It is faster and, when bending thin elements, it relaxes the artificial extra stiffness known as shear locking. The drawback is that the element becomes too soft and develops unnatural deformation patterns that carry no energy — zero-energy or hourglass modes — so in practice it is combined with hourglass control. Whether to use full or reduced integration depends on the element type and the problem.
Real-World Applications
Element stiffness matrices in FEM: Almost every structural FEM package (Abaqus, Ansys, Nastran, LS-DYNA and others) uses Gauss quadrature to compute the element stiffness matrix K = ∫B^T D B dV. For isoparametric elements the mapping from physical to reference coordinates [-1,1] makes the integrand a rational function that cannot be integrated by hand. An 8-node hexahedral element is integrated at 2×2×2 = 8 Gauss points and a 20-node element at 3×3×3 = 27 points as standard. The same quadrature is used for the mass matrix and the equivalent nodal force vector.
Reduced integration and shear-locking remedies: Solving thin beams, plates and shells with first-order elements produces excessive shear stiffness where the body should deform by bending, giving artificially small displacements — shear locking. To avoid it, selective reduced integration drops the point count of the shear term by one. The trailing "R" in Abaqus C3D8R or S4R means exactly reduced integration. It is a textbook example of how the choice of point count can change the analysis result dramatically.
Stress evaluation and superconvergent points: Stresses obtained by FEM are not equally accurate everywhere in an element. At the Gauss points — especially the point locations of reduced integration — the stresses and strains derived from displacement gradients are known to be more accurate than at the nodes, and are called superconvergent or optimal stress points. Commercial software extrapolates the stresses computed at Gauss points to the nodes for display, so knowing the Gauss-point locations is important for reading contour plots correctly.
Optimising computational cost: In large analyses the element count reaches millions, and integrating the element stiffness matrices takes a large fraction of the run time. Choosing exactly enough Gauss points for the integrand degree cuts the work without losing accuracy. Explicit crash analysis (such as automotive crash) uses first-order elements with single-point integration as standard, minimising the integration per element to handle the enormous number of time steps.
Common Misconceptions and Pitfalls
The biggest misconception is that more integration points always means more accuracy. Gauss quadrature integrates a polynomial of degree 2n-1 "exactly" with n points. If the integrand is a degree-4 polynomial, the error becomes exactly zero with 3 points, and going to 4 or 5 points changes nothing — all you add is computation time. With this tool you can feel it: use 3 points on a degree-4 polynomial that includes c4 and the error vanishes, and adding more points is pointless. For a general non-polynomial function accuracy does improve with more points, but even then you must judge "stop once it has converged" — blindly adding points wastes cost.
Next, the belief that in FEM more points is always safer. Adding points beyond full integration (the count that integrates the integrand exactly) does not raise accuracy, and reduced integration — using fewer points — is often beneficial. Thin-plate bending deliberately drops points to avoid shear locking, and explicit analysis uses single-point integration for speed. Equating "more points = higher accuracy = safe" can give an unrealistically stiff result through locking or simply slow the computation. You need the judgement to choose the right point count for the element type and the nature of the problem.
Finally, reduced integration does not always pay off. Remove too many points and the element stiffness falls short, producing unnatural deformation patterns that carry no energy at all — zero-energy or hourglass modes. A first-order hexahedral element with single-point integration develops as many as twelve hourglass modes, and with no countermeasure the mesh wobbles into hourglass shapes and the solution becomes meaningless. In practice an artificial stiffness called hourglass control suppresses this. Reduced integration is powerful, but never forget to pair it with hourglass control.
How to Use
Select the number of Gauss points (n) for each quadrature order using the Num fields (typically 1–4 points per dimension).
Set the integration range [a, b] for each coordinate using the Range inputs; standard FEM uses [-1, 1] for isoparametric elements.
Input your integrand function coefficients or select a preset polynomial; the simulator computes I_num via Gauss-Legendre weights and abscissae, then compares against I_exact to display absolute error.
Worked Example
Integrate f(x) = 3x² + 2x over [-1, 1]. With n=2 Gauss points (x₁ = -1/√3, x₂ = 1/√3, weights w₁ = w₂ = 1), I_num = 1(3·1/3 + (-2/√3)) + 1(3·1/3 + 2/√3) = 2.0. Exact I_exact = [x³ + x²]₋₁¹ = 2.0, Error = 0.0. This 2-point rule achieves degree 2n−1 = 3, integrating all polynomials up to cubic exactly—why FEM uses Gauss quadrature for 8-node brick element stiffness matrices (requiring accurate integration of degree-3 polynomials).
Practical Notes
Insufficient Gauss points cause underintegration: a 1-point rule (degree 1) over a quadratic load distribution in a beam element introduces parasitic shear locking.
For 2D/3D FEM assembly, n-point Gauss quadrature in each direction requires n² (2D) or n³ (3D) total integration points; use the Range fields to confirm [-1, 1] isoparametric mapping.
Verify the Exact degree 2n−1 matches your integrand complexity; nonlinear material laws may require selective reduced integration (e.g., n=1 for volumetric terms in nearly-incompressible elasticity).