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

  1. May 17, 2008 #1
    There isn't an applied mathematics thread so i'll post this here.

    I'm an undergraduate and I have a presentation for my numerical methods/matlab class . I'm looking for examples of
    1)Integrals which are easier/faster to integrate numerically than do evaluate using their antiderivatives. (power series etc)
    2)Integrals whose antiderivatives are not elementary functions on a bounded interval without ''smoothness'' problems on bounds, and if possible with a known integral value.

    Thank you.
  2. jcsd
  3. May 17, 2008 #2
    ... correct me if I'm wrong, but aren't most integrals easier to evaluate numerically? Being able to find an antiderivative for a general function is supposed to be tricky.

    I mean, but a fraction bar in there, add some exponentiation to algebraic functions of x, throw in some discontinuous functions and you should be good to go. As an example,...

    [x^2e^sqrt(x+sin(x))]/(sinh x + cos x + x^x)

    If that has an elementary function as its antiderivative, I'm retiring.

    Or are you asking for useful examples?
  4. May 17, 2008 #3
    Sorry, i wasn't clear.

    By easier i meant that matlab would take less time/ computer memory to evaluate the integral using a numerical integration method ( Simpson, Romberg, etc) than evaluating the antiderative itself which is usually quite complicated ( expressed using power series, etc). I've read about this in articles but i've never seen an example.

    Yeah, i'm looking for useful examples; like we know that integral of exp(-x^2) from -infinity to +infinity is root of phi, so i was wondering if there were integrals without antiderivatives like this on a bounded interval so that i could evaluate it using of the numerical integration methods for a presentation.
  5. May 17, 2008 #4
    Well actually software such as mathematica, maple and perhaps even matlab do not use the elementary algorithms that we learn in high school calculus.

    You are actually asking two different questions-- one question is what class of functions would be easier to integrate numerically using elementary methods, and the other question is what class of functions would be easier to integrate numerically if using sophisticated mathematical software.

    For the latter, I think it's easier to just try and see. If you do it symbolically and it chokes, do it numerically instead. You would be amazed how many crazy integrals a program that Mathematica can handle! But still my experience is that the type of integrals that show up in research are not the kind that have analytic expressions that Mathematica can find.
  6. May 17, 2008 #5
    My bad, i assumed that mathematical software uses elementary methods. Out of curiosity i'd like to know what methods they use.

    But more importantly i'm searching for functions belonging to the former class i.e. easier to integrate numerically using elementary methods, as an example to add to my class presentation.To me at least, it's counterintuitive that numerical integration works better.
  7. May 17, 2008 #6
    What about [tex]\int_{-1}^{1}\sin{(1/x)}dx[/tex]?

    It has an essential discontinuity which should (I hope) make evaluating the integral by series expansion tricky (and I believe also the anti-derivative is non-elementary)... but it can be handled numerically by splitting up the integral by

    [tex]\int_{-\epsilon}^{\+\epsilon}f + \int_{[-1,1]\backslash [-\epsilon,+\epsilon]} f[/tex]

    where you show that the first part vanishes in the limit as [tex]\epsilon \rightarrow 0[/tex] and the other part can be done using numerical methods, and so evaluating the right hand side for non-zero but small [tex]\epsilon[/tex] should yield a good approximation to the integral.
  8. May 17, 2008 #7

    George Jones

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Too easy. :biggrin:

    [itex]\sin \left(1/x \right)[/itex] goes wonky at [itex]x=0[/itex], so

    [tex]\int_{-1}^{1} \sin \left( \frac{1}{x} \right)dx[/tex]

    is an improper integral, and

    [tex]\int_{-1}^{1} \sin \left( \frac{1}{x} \right)dx = \lim_{\epsilon \rightarrow 0} \left( \int_{-1}^{ - \epsilon} \sin \left( \frac{1}{x} \right) dx + \int_{\epsilon}^{1} \sin \left( \frac{1}{x} \right) dx \right) = 0 ,[/tex]

    since [itex]\sin( \left(1/x \right)[/itex] is an odd function.

    I don't know whether

    [tex]\int_{0}^{1} \sin \left( \frac{1}{x} \right)dx[/tex]

    meets the original poster's criteria, but it is an interesting integral.

    The substitution [itex]w = 1/x[/itex] followed by an integration by parts turns this integral into the special function [itex]ci \left( x \right)[/itex].
    Last edited: May 17, 2008
  9. May 17, 2008 #8
    Doing definite integrals with numerical integration is typically 1000s of times faster than with symbolic integration (anti-derivatives). It would be more notable to find an integralwhich can be done very simply using anti-derivatives but will choke most numerical integration algorithms.

    The following description of the implementation of the symbolic integrator in Mathematica is taken from the Wolfram Inc website:

    * For indefinite integrals, an extended version of the Risch algorithm is used whenever both the integrand and integral can be expressed in terms of elementary functions, exponential integral functions, polylogarithms and other related functions.

    * For other indefinite integrals, heuristic simplification followed by pattern matching is used.

    * The algorithms in Mathematica cover all of the indefinite integrals in standard reference books such as Gradshteyn-Ryzhik.

    * Definite integrals that involve no singularities are mostly done by taking limits of the indefinite integrals.

    * Many other definite integrals are done using Marichev-Adamchik Mellin transform methods. The results are often initially expressed in terms of Meijer G functions, which are converted into hypergeometric functions using Slater's Theorem and then simplified.

    * Integrals over multidimensional regions defined by inequalities are computed by iterative decomposition into disjoint cylindrical or triangular cells.

    * Integrate uses about 500 pages of Mathematica code and 600 pages of C code.
  10. May 17, 2008 #9
    Oh woops yeah George, that was dumb of me to claim an odd integral over [-1,1] was hard when it's obviously 0! lol
  11. May 17, 2008 #10
    Yes, i'm looking for functions like the one David and George proposed, but which are defined on the bounds of the integral. I doubt ci(x) can be integrated properly with elementary methods, since it wobbles so much near zero.

    @ Crosson : wow,now i see how advanced the maths is to integrate symbolically with math software. But I'm searching for cases where even though we know what the antiderivative is, it is still faster to integrate numerically than to evaluate the antiderivative.
  12. May 18, 2008 #11
    Perhaps some massively piecewise function would work. I mean, in the limit, it would be doing the same thing as numerical integration, and it would have the extra work of doing the antiderivative in the first place.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook