Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Numerical Methods 5.1 Numerical Integration

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

NumericalIntegration 5. 5.

1 Numerical Methods Numerical Integration


Sometimes, it is difficult or even impossible to find the exact value of a definite integral. For example, it is impossible to evaluate i)

e
0

x2

dx

ii)

1+ x

dx

iii)

sin x dx x

The function determined from a scientific experiment through instrument reading is also impossible to evaluate because there may be no formula for the function. Therefore we need to approximate value of the definite integral. Trapezoidal Rule We wish to find the area under y = f(x) from x = a to x = b. The required area is divided in to n strips, each of width h. The width of each strip is given by b a x = h = . Each strip is the approximated by a trapezium. n y

a=xo

x1

X2

X3

b=xn

The vertical line from the ends of the segments to the partition points create a collection of trapezoids that approximate the region between the curve and the xaxis. Add the area of the trapezoids, counting area above x-axis as positive and the area below the x- axis as negative.

T =

1 1 1 1 ( y o + y 1 ) h + ( y 1 + y 2 ) h + . ( y n 2 + y n 1 ) h + ( y n 1 + y n ) h . 2 2 2 2 1 1 = h ( y o + y 1 + y 2 + y n 1 + y n ) 2 2 h = ( y o + 2y 1 + 2y 2 + 2 y n 1 + y n ) 2

where y o = f(xo), y 1 = f(x1), . y n 1 = f(xn-1), y n = f(xn)

CJHL2009

Page1

NumericalIntegration
If the number of strips is increased, that is h decreased, then the accuracy of the approximation is increased. The Trapezoidal rule: To approximate

f ( x ) dx , use
a

h T = ( y o + 2y 1 + 2y 2 + 2 y n 1 + y n ) 2 ba and y k = f(xk), Where x = n


Example 1 Use the trapezoidal Rule with given n to estimate i)

x 2 dx , n = 4 1

iii)

x
1

dx , n = 6

Example 2
1.3

Use the trapezoidal rule to estimate a) a strip width of 0.2

0.5

e
b)

x2

dx using
a strip width of 0.1

Simpsons Rule Simpson rule for approximating

f ( x ) dx
a

is based on approximating f with

quadratic polynomials. We approximate the graph with parabolic arcs instead of line segments. The area is divided intoyan even number of strips of equal width.

a=xo

x1

X2

X3

b=xn

CJHL2009

Page2

NumericalIntegration
After some analysis an expression for approximating the area is found as follow.

Simpsons Rule To approximate

f ( x ) dx , use
a

h S = (y o + 4 y 1 + 2 y 2 + 4 y 3 + ..... + 2 y n 2 + 4 y n 1 + y n ) 3

The ys are the values of f at the partition points, xo = a1, x1 = a + h, x2 = a + 2h, , xn-1 = a + (n-1)h, xn =b. Example 3
1.3

Estimate a)

0.5

x e dx using Simpsons rule with


2

Four strips,

b)

eight strips

Example 4 Estimate

1 + x 3 dx using Simpsons rule with n = 4

Exercises 5.1 Use a) the trapezoidal rule and b) Simpsons rule to approximate the given integral with the specific value of n. 1.

1 + x 3 dx , n = 8

2.

sin x dx , n = 6 x

3.

0
1

cos ( x 2 ) dx , n = 4

4.

x tan x dx ,
0 1

n =6

5.

0 1 0 3

e x dx , n =10

6.

cos( e
0

), n = 8

7. 9.

x 5 e x dx , n = 5 1 dx , n = 6

8. 10.


0 1 2

e x dx , n = 4 1 1+ x3 dx , n = 8

1+ x
0

CJHL2009

Page3

NumericalIntegration
Runge-Kutta Method of Order 4 Runge- Kutta methods are a large family of methods used for solving differential dy equations. To solve the differential equation = f ( x , y ) subject to y = yo at x = dx xo for a x b . We generate the sequence of values yi from the formula:

y i +1 = y i +
where

h (k1 + 2 k 2 + 2 k 3 + k 4 ) 6

k1 = f ( x i , y i ) h h k 2 = f ( x i + , y i + k1 ) 2 2 h h k3 = f ( xi + , y i + k2 ) 2 2 k 4 = f ( x i + h, y i + h k 3 )
Example1. Ues the Runge Kutta method to solve
dy = x 2 + x y for 0 x 0.4 subject dx to y(0) = 0. Use h = 0,2 and work throughout to four decimal places.

Example 2 Find y(0.2) if Take a)


dy = ( x + y ) 2 and y(0) = 1 using Runge-Kutta method of order 4 dx h = 0.2 b) h = 0.1

Exercises 5.2 1. Use the Runge-Kutta of Order 4 to find y(0.25) if for 0 x 1 . Use h = 0.25. 2 The differential equation

dy = x + y subject to y(0) = 0 dx

dy x + y = with h = 0.5 has an initial value of y(1) = 1. dx x Estimate y when x = 1.5 using Runge_Kutta method of order 4.
Use the Runge-Kutta of order 4 method to approximate the specified solution to each of the follwing initial value problems a) b) c)
dy = xe 3 x 2 y , for 0 x 1 with y(0) = 0, h = 0.5; y(0.5) dx dy =1 + ( x y ) 2 , for 2 x 3 with y(2) = 1, h = 0.5.; y(2.5) dx dy = cos 2 x + sin 3 x , for 0 x 1 with y(0) = 1, h = 0.25; y(0.25) dx

3.

CJHL2009

Page4

NumericalIntegration

e)

dy y y = , for 1 x 2 with y(1) = 1, h = 0.25; dx x x

y(1.25)

CJHL2009

Page5

You might also like