Numerical integration

Download Report

Transcript Numerical integration

Department of Engineering Mathematics and
Physics, Faculty of Engineering
Zagazig University
2009-2010
Numerical solution of linear equations.
Numerical solution of non linear equations.
Numerical integrations.
Curve fitting.
Numerical solution of ordinary differential equations.
Numerical solution of partial differential equations.
Next
The Main Menu
‫ا‬Previous
Numerical integration
It is the evaluation of a definite integral
y
y = f(x)
b
I   f(x) dx .
Area
a
By using a numerical method of
0
approximate integration.
a
b
Where f(x)
it is complicated to integrate analytically.
Or it is given by a table.
Or the integral cannot be represented in terms of
finitely elementary functions.
Next
The Main Menu
‫ا‬Previous
x
y
y = f(x)
0
b
a
I   f(x) dx 
a
x1 x2
xn-1 b
x
and a = x0, b =xn
h
f(a)  2 f(x 1 )  2 f(x 2 )  ....  2 f(x n 1 )  f(b) .
2
1

i . e . I   f(x) dx  h  [f(a)  f(b)]  f(x 1 )  f(x 2 )  ....  f(x n 1 ).
2

a
b
Where h 
b a
n
Next
The Main Menu
‫ا‬Previous
Evaluate
1
I  e
x 2
dx by means of trapezoidal rule with n = 10. For 4D.
0
b a 1
  0.1
n
10
2
Calculate the values of f(x)  e  x
h 
x
0
f(x)
1
1
I   e
0
0.1
0.2
0.9900 0.9608
 x2
dx 
0.3
0.4
0.5
0.6
0.7
0.8
0.9139 0.8521 0.7788 0.6977 0.6126 0.5273
0.9
1.0
0.4449
0.3679
1 1
[ (1  0.3679)  0.9900  0.9608  0.9139  0.8521  0.7788 
10 2
0.6977  0.6126  0.5273  0.4449]  0.7462
Next
The Main Menu
‫ا‬Previous
y
y = f(x)
0
b
I   f(x) dx 
a
a x1 x2 x3
x2n-1 b
x
h
f(a)  f(b)  4f(x 1 )  f(x 3 )  ...  f(x 2 n 1 ) 2f(x 2 )  f(x 4 )  ...  f(x 2 n 2 ).
3
Where h 
b a
2n
and a = x0, b = x2n
Next
The Main Menu
‫ا‬Previous
Evaluate
π/ 2
I

1  ((sinx) 2 / 4) dx by means of Simpson’s rule with 2n = 6. For 4D.
0
b a π/ 2  0 π
h 


2n
6
12
Calculate the values of f(x)  1  ((sinx) 2 / 4)
π
6
π
4
0.9682
0.9354
0
π
12
f(x)
1
0.9916
 I   f(x) dx 
I 
2
x
b
a
1

3x12
3
4
5
π
3
0.9014
5π
12
0.8756
π
2
0.8660
h
f(a)  f(b)  4f(x 1 )  f(x 3 )  ...  f(x 2 n 1 ) 2f(x 2 )  f(x 4 )  ...  f(x 2 n 2 ).
3
1  0.8660  40.9916  0.9354  0.8756 20.9682  0.9014  1.4674.
Next
The Main Menu
‫ا‬Previous
3
 rule
8
b
I   f(x) dx 
a
Where n = 3,
3h
f 0  3 f1  3 f 2  f3 .
8
b a
h
3
b
3h
f 0  5 f1  f 2  6 f3  f 4  5 f5  f 6 .
I   f(x) dx 
10
a
Where n = 6,
Next
h
b a
6
The Main Menu
‫ا‬Previous
Evaluate
0.5
I   e x sin 2 xdx . Using 3  rule .
8
0.2
h 
b a 0.5  0.2

 0.1
3
3
Calculate the values of
I 
f(x)  e x sin 2 x
x
0.2
0.3
0.4
0.5
f(x)
0.4756
0.7622
1.0702
1.3873
3(0.1)
0.4756  3(0.7622  1.0702)  1.3873  0.2760.
8
Next
The Main Menu
‫ا‬Previous
Evaluate
0.5
I   e x sin 2 xdx .
Using Weddl’s rule
0.2
b a 0.5  0.2
h 

 0.05
6
6
Calculate the values of f(x)  e x sin 2 x
0
1
2
3
x
0.2
0.25
0.3
0.35
0.4756
f(x)
b
 I   f(x) dx 
a
0.6156
0.7622
0.9142
4
0.4
5
0.45
6
0.5
1.0702
1.2285
1.3873
3h
f 0  5 f1  f 2  6 f3  f 4  5 f5  f 6 .
10
3(0.05)
0.4756  5(0.6156)  0.7622  6(0.9142)  1.0702  5(1.2285)  1.3873  0.2760.
I 
10
Next
The Main Menu
‫ا‬Previous
The double integral evaluated as an iterated integral
d b
I    f(x, y) dx dy .
c a
d b
  (  f(x, y) dx) dy .
c
a
b
d
a
c
  (  f(x, y) dy) dx .
We can the do the same, using any integration method.
Next
The Main Menu
‫ا‬Previous
Evaluate
2.64.6
I

2
1
4 xy dx dy,
take h = 0.2 in x-direction, k = 0.3 in y-direction. Use
in x- direction and Simpson’s rule in y-direction.
3
 rule
8
Calculate the values of f(x, y)  1
xy
y
x
4
4.2
4.4
4.6
2
0.125
0.1191
0.1136
0.1087
2.3
0.1087
0.1035
0.0988
0.0945
2.6
0.0962
0.0916
0.0874
0.0836
Next
The Main Menu
‫ا‬Previous
3
Applying  rule in x-direction
8
For y
=2
3(0.2)
0.125  3(0.1191  0.1136)  0.1087  0.0698.
 I0 
8
For y
=2.3
3(0.2)
0.1087  3(0.1035  0.0988)  0.0945  0.0608
 I1 
8
For y
=2.6 3(0.2)
0.0962  3(0.0916  0.0874)  0.0836  0.0538
 I2 
8
We can put in the
table
2
2.3
2.6
y
f(y)
0.0698
Next
0.0608
0.0538
The Main Menu
‫ا‬Previous
Applying Simpson’s in ydirection
2
y
f(y)
0.0698
2.3
2.6
0.0608
0.0538
k
I  f(a)  f(b)  4f(x 1 )  f(x 3 )  ...  f(x 2 n 1 ) 2f(x 2 )  f(x 4 )  ...  f(x 2 n 2 ).
3
I 
0.3
0.0698  0.0538  4(0.0608)  0.0367.
3
Next
The Main Menu
‫ا‬Previous