Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

area

Adaptive Numerical Integration


Description

Integrate a function of one variable over a finite range using a recursive adaptive method. This function is mainly for demonstration purposes.

Usage

area(f, a, b, ..., fa = f(a, ...), fb = f(b, ...),
     limit = 10, eps = 1e-05)

Arguments

f

The integrand as an S function object. The variable of integration must be the first argument.

a

Lower limit of integration.

b

Upper limit of integration.

...

Additional arguments needed by the integrand.

fa

Function value at the lower limit.

fb

Function value at the upper limit.

limit

Limit on the depth to which recursion is allowed to go.

eps

Error tolerance to control the process.

Details

The method divides the interval in two and compares the values given by Simpson's rule and the trapezium rule. If these are within eps of each other the Simpson's rule result is given, otherwise the process is applied separately to each half of the interval and the results added together.

Value

The integral from a to b of f(x).

References

Venables, W. N. and Ripley, B. D. (1994) Modern Applied Statistics with S-Plus. Springer. pp. 105–110.

Examples

area(sin, 0, pi)  # integrate the sin function from 0 to pi.

MASS

Support Functions and Datasets for Venables and Ripley's MASS

v7.3-54
GPL-2 | GPL-3
Authors
Brian Ripley [aut, cre, cph], Bill Venables [ctb], Douglas M. Bates [ctb], Kurt Hornik [trl] (partial port ca 1998), Albrecht Gebhardt [trl] (partial port ca 1998), David Firth [ctb]
Initial release
2021-04-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.