Gauss-Legendre vs trapezoid quadrature
What you are seeing: two ways of approximating . The trapezoidal rule uses equispaced points and converges as for smooth . Gauss-Legendre uses optimized nodes (roots of ) with matching weights, exact for polynomials up to degree . For analytic the GL error decays exponentially.
Top panel: with nodes overlaid (orange = trapezoid, cyan = GL). Bottom: log-error vs . For smooth , GL reaches machine precision by while trapezoid still loses accuracy as .
n nodes8
functioncos
speed2
WHAT TO TRY
- Vary each control and watch the rail readouts respond.
- Compare the diagnostic plot against the live scene.