Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Numerical integration simpson

  1. Jul 26, 2010 #1

    I've using numerical integration method (Simpson rule) to evaluate a definite integral in the interval [a,b]. I was wondering what is the ideal way to approximate the integral in the boundary [a,b) or (a,b] or (a,b) when for example, the function inside the integral does not exist at that point. What I usually do is add a small constant to the open boundary, for example to evaluate integral at (a,b], I will evaluate at [a+10^-6,b]. What are your thoughts?

    Secondly, are there any numerical integration methods available in R?


  2. jcsd
  3. Aug 2, 2010 #2
    Two things.

    Firstly, which Simpson's rule is relatively easy to code, in practice it wouldn't be touched with a ten foot pole because it is so inefficient. Gauusian quadrature provide a much better results with less resources and if your integrals are taking a long time you should look into such methods.

    Secondly, if the function does not exist at a single point you may still be able to evaluate the integral appropriately. If the function has a "removable singularity" at the point, e.g. sin(x)/x at x=0, then you can simply redefine the equation at that point and everything will work.

    However, sometimes the problem is not the undefined point, but the behaviour of the function leading up to that point as well. e.g. 1/x^2 near x=0. You simply can't evaluate the integral on [0,b] or (0,b] as fundamentally it will diverge to infinity no matter how you go about it. In this second case, a boundary cutoff of the type you are using may have to be employed.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook