## LevinIntegrate Mathematica package

Home > Mathematica packages > **LevinIntegrate package** > Revision history

#### Note

Following my work described on this page, I took a position at Wolfram Research. There we implemented a much more powerful set of Levin-type methods directly into Mathematica's NIntegrate solver. These superior methods are built in to Mathematica 8+. I retain this page for historical reasons and users of previous versions.

### Summary

LevinIntegrate is an automatic numerical integrator for one-dimensional highly oscillatory integrands. It outperforms existing automatic integrators (such as Mathematica's NIntegrate) for many irregularly-oscillatory functions, including solving some oscillatory integrals that no existing automatic integrator can solve.

### Download latest version

LevinIntegrate has undergone changes since its initial release that improve its performance and reliability. I recommend you use the latest release. (See the the revision history).

To use LevinIntegrate, click here to download Moylan.zip
and extract the "Moylan" folder to your Mathematica Applications
folder, or any other place where it will be found by Needs[]. For more
information about installing Mathematica packages, see my main Mathematica packages page.

### Usage

LevinIntegrate is designed to be as similar in interface to Mathematica's NIntegrate as possible. Here is how to use LevinIntegrate to solve Problem 1 of the SIAM 100-Dollar, 100-Digit Challenge:

LevinIntegrate can presently automatically integrate functions containing arbitrary
products of the following oscillators: Sin, Cos, Exp,
and BesselJ. For other oscillators, see the **GeneralisedLevinIntegrate** section, below. The range of integration need not be finite.

### Documentation

Many of the options to LevinIntegrate, such as PrecisionGoal and
WorkingPrecision, are identical in function to those of NIntegrate.

Comprehensive documentation will appear online here and/or as part of
the downloadable Mathematica package depending on time and demand. For
now, if you have any particular questions about usage, please email me.

### How it works

LevinIntegrate combines *Levin's method* for the integration of highly
oscillatory functions (Levin (1996)) with some important features of automatic
integrators: adaptive recursive subdivision, and automatic change of
variable / coordinate transformations for compactifying infinite
integration regions and transforming away singularities in the
integrand. It also takes advantage of Mathematica's capability for symbolic pre-processing to automatically identify the oscillatory part(s) of the integrand. You can examine the source code in LevinIntegrate.nb (included in the package) to see the inner workings of LevinIntegrate.

LevinIntegrate has been mentioned in some of my conference presentations and scientific articles. See my scientific articles page for references. A comprehensive article about LevinIntegrate, and its motivating application in numerical wave optics, is in preparation (Moylan et al. (2008)).

### GeneralisedLevinIntegrate

LevinIntegrate needs to be able to identify the form of the oscillatory term in your integrand. Otherwise it won't work:

LevinIntegrate can presently integrate functions containing
(arbitrary products of) oscillators of the form Sin[f[x]], Cos[f[x]],
Exp[I*f[x]], and BesselJ[n,f[x]], but Levin's method applies to many
other oscillatory functions. If your oscillatory function is not one of the above forms that are built in to LevinIntegrate, you might still be able to integrate it. Levin's method can be applied when *the oscillatory term in the integrand satisfies a known linear differential equation *with coefficients that are non-rapidly-oscillatory functions (Levin (1996)). In principle, the differential equation need not be homogeneous (Chung et al. (2000)), but in the present implementation of LevinIntegrate it must be.

To integrate a function whose oscillatory term is not one of the built-in types, use **GeneralisedLevinIntegrate**. Here is an example, using an oscillatory function called "sol":

If there is a common type of oscillatory function
you need for your application, please let me know by email and I will consider including it as a standard oscillatory function that LevinIntegrate can recognise automatically.

### Development

LevinIntegrate is still under development. Please send your comments, problems and suggestions to me by email.

As noted by Anton Antonov,
ideally LevinIntegrate will eventually be packaged in the form of an
additional integration strategy for NIntegrate, rather than as a
separate stand-alone function. If you want to try this yourself, see Anton's post, which shows that it isn't very difficult to set up.

### References

*For a comprehensive list of references, see my scientific articles about LevinIntegrate. *

K. C. Chung, G. A. Evans, and J. R. Webster. Applied Numerical Mathematics **34**, 1: 85-93 (2000).

D. Levin, *Journal of Computational and Applied Mathematics ***67**, 95 (1996).

A. J. Moylan, S. M. Scott and A. C. Searle, in preparation (2008).