Numerical Integration
-
Upload
mohammad-tawfik -
Category
Education
-
view
220 -
download
4
Transcript of Numerical Integration
![Page 1: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/1.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Numerical Integration
Mohammad Tawfik
![Page 2: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/2.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Objectives
• The student should be able to
– Understand the need for numerical integration
– Derive the trapezoidal rule using geometric
insight
– Apply the trapezoidal rule
– Apply Simpson’s rule
![Page 3: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/3.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Need for Numerical Integration!
6
1101
2
1
3
1
231
1
0
231
0
2
x
xxdxxxI
11
0
1
0
1 eedxeI xx
1
0
2
dxeI x
![Page 4: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/4.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Area under the graph!
• Definite integrations always result in the
area under the graph (in x-y plane)
• Are we capable of evaluating an
approximate value for the area?
![Page 5: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/5.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Example
• To perform the
definite integration of
the function between
(x0 & x1), we may
assume that the area
is equal to that of the
trapezium:
0101
2
1
0
xxyy
dxxf
x
x
![Page 6: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/6.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Adding adjacent areas
![Page 7: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/7.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
The Trapezoidal Rule
2
2
1212
0101
yyxx
yyxxI
Integrating from x0 to x2:
2
212112101001 yxxyxxyxxyxxI
![Page 8: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/8.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
The Trapezoidal Rule
hxxxx 1201
If the points are equidistant
2
2110 hyhyhyhyI
210 22
yyyh
I
![Page 9: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/9.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Dividing the whole interval into “n”
subintervals
n
n
i
i yyyh
I1
1
0 22
![Page 10: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/10.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
The Algorithm
• To integrate f(x) from a to b, determine the number of intervals “n”
• Calculate the interval length h=(b-a)/n
• Evaluate the function at the points yi=f(xi) where xi=x0+i*h
• Evaluate the integral by performing the summation
n
n
i
i yyyh
I1
1
0 22
![Page 11: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/11.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Note that
X0=a
Xn=b
![Page 12: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/12.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Example
• Integrate
• Using the trapezoidal
rule
• Use 2,3,&4 points and
compare the results
1
0
2dxxI
![Page 13: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/13.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Solution
• Using 2 points (n=1),
h=(1-0)/(1)=1
• Substituting:
212
1yyI 5.010
2
1I
Y X
0 0
1 1
2 points, 1 interval
![Page 14: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/14.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Solution
• Using 3 points (n=2),
h=(1-0)/(2)=0.5
• Substituting:
321 22
5.0yyyI
375.0125.0*202
5.0I
Y X
0 0
0.25 0.5
1 1
3 points, 2 interval
![Page 15: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/15.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Solution
• Using 4 points (n=3),
h=(1-0)/(3)=0.333
• Substituting:
4321 222
333.0yyyyI
3519.01444.0*2111.0*202
333.0I
Y X
0 0
0.111 0.33
0.444 0.667
1 1
4 points, 3 interval
![Page 16: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/16.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Let’s use Interpolation!
![Page 17: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/17.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Interpolation!
• If we have a function that needs to be integrated between two points
• We may use an approximate form of the function to integrate!
• Polynomials are always integrable
• Why don’t we use a polynomial to approximate the function, then evaluate the integral
![Page 18: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/18.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Example
• To perform the
definite integration of
the function between
(x0 & x1), we may
interpolate the
function between the
two points as a line.
0
01
010 xx
xx
yyyxf
![Page 19: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/19.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Example
• Performing the integration on the approximate
function:
1
0
1
0
0
01
010
x
x
x
x
dxxxxx
yyydxxfI
1
0
0
2
01
010
2
x
x
xxx
xx
yyxyI
![Page 20: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/20.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Example
• Performing the integration on the approximate
function:
00
2
0
01
010010
2
1
01
0110
22xx
x
xx
yyxyxx
x
xx
yyxyI
2
0101
yyxxI
• Which is equivalent to the area of the trapezium!
![Page 21: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/21.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
The Trapezoidal Rule
2
0101
yyxxI
2
2
1212
0101
yyxx
yyxxI
Integrating from x0 to x2:
![Page 22: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/22.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Simpson’s Rule
Using a parabola to join three
adjacent points!
![Page 23: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/23.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Quadratic Interpolation
• If we get to interpolate a quadratic equation
between every neighboring 3 points, we may use
Newton’s interpolation formula:
103021 xxxxbxxbbxf
1010
2
3021 xxxxxxbxxbbxf
![Page 24: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/24.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Integrating
1010
2
3021 xxxxxxbxxbbxf
2
0
2
0
1010
2
3021
x
x
x
x
dxxxxxxxbxxbbdxxf
2
0
2
0
10
2
10
3
30
2
21232
x
x
x
x
xxxx
xxx
bxxx
bxbdxxf
![Page 25: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/25.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
After substitutions and
manipulation!
210 43
2
0
yyyh
dxxf
x
x
![Page 26: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/26.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Working with three points!
210 43
2
0
yyyh
dxxf
x
x
![Page 27: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/27.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
For 4-Intervals
432210 443
4
0
yyyyyyh
dxxf
x
x
![Page 28: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/28.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
In General: Simpson’s Rule
n
n
i
i
n
i
i
x
x
yyyyh
dxxfn 2
,..4,2
1
,..3,1
0 243
0
NOTE: the number of intervals HAS TO BE even
![Page 29: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/29.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Example
• Integrate
• Using the Simpson
rule
• Use 3 points
1
0
2dxxI
![Page 30: Numerical Integration](https://reader033.fdocuments.net/reader033/viewer/2022042512/55a67f951a28ab6c6f8b4897/html5/thumbnails/30.jpg)
Numerical Integration
Mohammad Tawfik #WikiCourses
http://WikiCourses.WikiSpaces.com
Solution
• Using 3 points (n=2),
h=(1-0)/(2)=0.5
• Substituting:
• Which is the exact
solution!
210 43
5.0yyyI
3
1125.0*40
3
5.0I