[Math] When is trapezoidal rule better than Gaussian quadrature

numerical methods

I have used the trapezoidal rule to evaluate the integral $$\int_{-1}^1 |x| \, dx$$ and it gives an aproximation without any error (the exact solution: $1$). However, when I use Gauss–Chebyshev or Gauss–Legendre quadrature, I have an error in the approximation. Why? I thought Gauss quadrature was always more precise than the trapezoidal rule.

Best Answer

In your example this happens because: 1) the function is not a polynomial so one should not expect quadrature rules to give the exact result 2) it's a perfect function for the trapezoidal rule because it consists of two trapezoids so this rule will give exact results if and only if $x=0$ is a grid-point.

Exactly when one method is better than another is not the right question to ask because you are not going to find a good answer (a classification would be horrendously complicated). What we can say is that:

  • A higher order method is usually better than a lower order method
  • Higher number of grid-points usually gives better results than fewer grid-points

But these are not absolutes as you have discovered. The best we can do in general is to put up an upper bound for the error in terms of some properties of the function like it's derivatives and the number of grid-points used etc. This will give you a rough idea about how accurate the method will be for any given function and that is usually the only thing we need to know in practice.

Related Question