Numerical Methods/Numerical Integration

From testwiki
Revision as of 21:19, 12 October 2007 by imported>Mike's bot account (re-categorization for Subject: pages)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

<< Numerical Methods

Often, we need to find the integral of a function that may be difficult to integrate analytically (ie, as a definite integral) or impossible (the function only existing as a table of values).

Some methods of approximating said integral are listed below.

Trapezoidal Rule

Consider some function, possibly unknown, f(x), with known values over the interval [a,b] at n+1 evenly spaced points xi of spacing h=(ba)n, x0=a and xn=b.

Further, denote the function value at the ith mesh point as f(xi).

Using the notion of integration as "finding the area under the function curve", we can denote the integral over the ith segment of the interval, from xi1 to xi as:

xi1xif(x)dx = (1)

Since we may not know the antiderivative of f(x), we must approximate it. Such approximation in the Trapezoidal Rule, unsurprisingly, involves approximating (1) with a trapezoid of width h, left height f(xi1), right height f(xi). Thus,

(1) 12h(f(xi1)+f(xi)) = (2)

(2) gives us an approximation to the area under one interval of the curve, and must be repeated to cover the entire interval.

For the case where n = 2,

xaxbf(x)dx12h(f(x0)+f(x1))+12h(f(x1)+f(x2)) = (3)


Collecting like terms on the right hand side of (3) gives us:

12h(f(x0)+f(x1)+f(x1)+f(x2))

or

12h(f(x0)+2f(x1)+f(x2))

Now, substituting in for h and cleaning up,

(ba)22(f(x0)+2f(x1)+f(x2))


To motivate the general version of the trapezoidal rule, now consider n = 4,

xaxbf(x)dx12h(f(x0)+f(x1))+12h(f(x1)+f(x2))+12h(f(x2)+f(x3))+12h(f(x3)+f(x4))

Following a similar process as for the case when n=2, we obtain

(ba)24(f(x0)+2(f(x1)+f(x2)+f(x3))+f(x4))

Proceeding to the general case where n = N,

xaxbf(x)dx(ba)2n(f(x0)+2(k=1Nf(xk))+f(xn))

This is an example of what the trapezoidal rule would represent graphicly, here y=x2+5.


Example

Approximate 01x3dx to within 5%.

First, since the function can be exactly integrated, let us do so, to provide a check on our answer.

01x3dx=[x44]01=14=0.25 = (4)

We will start with an interval size of 1, only considering the end points.

f(0)=0

f(1)=1

(4) (10)(21)(f(0)+f(1))=12.1(0+1)=12=0.5

Relative error = |(0.50.25)0.25|=1

Hmm, a little high for our purposes. So, we halve the interval size to 0.5 and add to the list

f(0.5)=0.125

(4) (10)(22)(f(0)+2f(0.5)+f(1))=122(0+2(0.125)+1)=1.254=0.3125

Relative error = |(0.31250.25)0.25|=0.25

Still above 0.01, but vastly improved from the initial step. We continue in the same fashion, calculating f(0.25) and f(0.75), rounding off to four decimal places.

f(0.25)=0.0156

f(0.75)=0.4219

(4) (10)(24)(0+2(0.0156+0.125+0.4219)+1)=18(2.2150)=0.2656

Relative error = |(0.26560.25)0.25|=0.0624

We are well on our way. Continuing, with interval size 0.125 and rounding as before,

f(0.125)=0.0020

f(0.375)=0.0527

f(0.625)=0.2441

f(0.875)=0.6699


(4) (10)(28)(0+2(0.0020+0.0156+0.0527+0.0125+0.2441+0.4219+0.6699)+1)=116(4.0624)=0.2539

Relative error = |(0.25390.25)0.25|=0.0156

Since our relative error is less than 5%, we stop.

Error Analysis

Let y=f(x) be continuous,well-behaved and have continuous derivatives in [x0,xn]. We expand y in a Taylor series about x=x0,thus-
x0x1ydx=x0x1[y0+(xx0)y'0+(xx0)2y'0/2!+......]dx

Simpson's Rule

Consider some function y=f(x) possibily unknown with known values over the interval [a,b] at n+1 evently spaced points then it defined as

x0xnf(x)dx13h{f(x0)+f(xn)+2(f(x2)+f(x4)+...+f(xn2))+4(f(x1)+f(x3)+...+f(xn1))}

where h=(ba)n and x0=a and xn=b.

Example

Evaluate 01.2x(8x3)12dx by taking n=6 (n must be even)

Solution: Here f(x)=x(8x3)12

Since a=0 & b=1.2 so h=ban=1.206=0.2

Now when a=x0=0 then f(x0)=0

And since xn=xn1+h, therefore for x1=0.2 , x2=0.4 , x3=0.6 , x4=0.8 , x5=1 , x6=b=1.2 the corresponding values are f(x1)=0.7784 , f(x2)=1.58721 , f(x3)=1.6740 , f(x4)=2.1891 , f(x5)=2.6458 , f(x6)=3.0053

Incomplete ... Completed soon

Error Analysis

Simpson's 3/8

Headline text

Example

Error Analysis

References

Eric W. Weisstein. "Trapezoidal Rule." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/TrapezoidalRule.html



Main Page - Mathematics bookshelf - Numerical Methods