Upload
verity-watkins
View
217
Download
0
Embed Size (px)
Citation preview
4. NUMERICAL INTEGRATION:
)x(ff kk
b
a
Idx)x(f0xa
nxb
Trapezoidal Rule:
h]ff...fff[I nn 2
1
2
11210
1x2x ...
)x(f
x
0x nx
0f1f
..
.
k1k xxhx
Area of a single trapezoid =
)xx(*2
ff01
10
h
n
xxh 0n
There are various numerical methods to calculate the definite integrals. The integral gives the area under the curve defined by the function f(x). We use the function values and increment value between the successive points on the x axis in order to calculate the integral.
In Simpson’s rule, number of section n must be even!
Simpson’s Rule:
34224 21222210
h]fff...fff[I nnm n=2*m
Example:
1
0
x ?dxe2
k x Exp(-x^2)
0 0 1
1 0.25 0.939
2 0.50 0.779
3 0.75 0.570
4 1 0.368
Trapezoidal Rule gives: 0.743
Simpson’s Rule gives: 0.747
Numerical Integration using Matlab:
clc; clearsyms xf=exp(-x^2)y=int(f,0,1)vpa(y,5)
>> vpa(int('exp(-x^2)',0,1))
743.0I
2
368.0570.0779.0939.0
2
125.0I
747.0I
368.0570.0*4779.0*2939.0*413
25.0I
4n 25.0
4
01
n
xx
n
abhx 0n