Learn R Programming

asymmetry.measures (version 0.2)

SimpsonInt: Simpson integration

Description

Implements simpson's extended integration rule.

Usage

SimpsonInt(xin,h)

Arguments

xin

A vector of design points where the integral will be evaluated.

h

Assuming a<b and n is a positive integer. \(h = (b-a)/n\).

Value

A scalar, the approximate value of the integral.

Details

Simpson's extended numerical integration rule is implemented for \(n+1\) equally spaced subdivisions (where \(n\) is even) of \([a, b]\) as

$$\int_{a}^{b} f(x)\, dx = \frac{h}{3} \left \{ f(a) + 4f(x_1) + 2f(x_2) + 4f(x_3) + 2f(x_4) + ... + 4f(x_{n-1}) + f(b)\right \}$$

where \(hx=(b-a)/n\) and \(x_i=a+ihx\). Simpson's rule will return an exact result when the polynomial in question has a degree of three or less. For other functions, Simpson's Rule only gives an approximation.

References

Simpson's Rule

Examples

Run this code
# NOT RUN {
x.in<- seq(0,pi/4,length=5)
h.out <- pi/8
SimpsonInt(x.in,h.out)
# }

Run the code above in your browser using DataLab