2
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Gauss quadrature is best when there are polynomials of degree $2n-1$ but however, choosing a particular method depends on the problem. $\endgroup$ – tien lee May 30 '18 at 16:53
  • $\begingroup$ @tienlee When is it better to use each method? Here the derivative of $|x|$ (on all points but $x=0$ is the same ($-1$ and $1$). Therefore taking equidistant nodes is better than taking the chebyshev nodes which are more focused on the sides of the interval $[-1,1]$. This is just what my intuition says, I could not prove it $\endgroup$ – John Keeper May 30 '18 at 17:00
  • 1
    $\begingroup$ Do you get the same relation between errors if the integration interval is not symmetric, if you integrate from $-0.9$ to $1.1$? $\endgroup$ – LutzL May 30 '18 at 17:18
  • $\begingroup$ Try an odd number of trapezoids (evenly spaced) and you don't get error zero anymore. For example $n=3$ the trapazoid rule overestimates by $1/9$ $\endgroup$ – N8tron May 30 '18 at 17:28
  • $\begingroup$ Related: For numerical integration, is it true that higher degree of precision gives better accuracy always? (the answer is no) $\endgroup$ – Winther May 30 '18 at 17:34
2
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.