Matlab Project
Matlab Project
Numerical integration
Presentation Outline
1. Trapezoidal rule
2. Simpson’s rule
Newton-Leibniz formula
f (b) f (a)
P( x) f (a) f [a, b]( x a) f (a) ( x a)
ba
b b
a
P( x)dx [f (a ) f [a, b]( x a )]dx
a
f (b) f (a) x
b
2
f (a) x| ( ax) |a
b
a ba 2
ba
[ f ( a ) f (b)]
2
b ba
a
f ( x)dx
2
[ f (a) f (b)]
Composite Trapezoidal rule
a x0 , x1 x0 h,..., xk x0 kh,...xn x0 nh
yk f ( xk ), k 0,1, 2,..., n
Composite Trapezoidal rule
y0 y1 y1 y2 yn 1 yn
h h ... h
2 2 2
2. SIMPSON’RULE
Definition
Formula
Hence
Where f2(x) a second order polynomial
given by:
Choose
The Plan
The distance covered by a rocket in meters from
t=2s to t= 28s is given by
28
150000
𝑥 = න 2500 ln − 9.8t
150000 − 2000𝑡
2
1. Use Simpson’s 1/3 rule to find the approximate
value of x .
2. Find the absolute relative true error 𝜖𝑡
Solution
1
The
𝑏 − distance
𝑎 covered
𝑎 + 𝑏 by a rocket in meters from
𝑥≈ 𝑓 𝑎 + 4𝑓 + 𝑓(𝑏)
t=2s
6 to t= 28s is given
2 by
28
• a=2 150000
𝑥 = න 2500 ln − 9.8t
• b=28 150000 − 2000𝑡
2
• 1. =Use
𝑎+𝑏
2
15 Simpson’s 1/3 rule to find the approximate
value of x .150000
𝑓 𝑡2.= Use
2500Simpson’s
ln − 9.8𝑡
150000 −1/3 rule to find the approximate
2000𝑡
value of x .
We have f(2)= 47.97, f(28)= 893.95,f(15)= 410.85
Find the absolute relative true error 𝜖𝑡
3. 28−2
𝑥 ≈ 𝑓 2 + 4𝑓 15 + 𝑓 28 = 111203 m
6
Solution
𝑏−𝑎
• The segment width is given by ℎ=
𝑛
Now
Where
Multiple-segment Simpson’s 1/3 Rule
𝑏−𝑎
• The segment width is given by ℎ=
𝑛
Now
Where
EXAMPLE
1.
Using n segment Simpson’s 1/3 rule,
𝑛−1 𝑛−2
𝑏−𝑎
𝑥≈ 𝑓 𝑡 + 4 𝑓 𝑡𝑖 + 2 𝑓 𝑡𝑖 + 𝑓 𝑡𝑛
3𝑛
𝑖=1 𝑖=2
𝑖=𝑜𝑑𝑑 𝑖=𝑒𝑣𝑒𝑛
a=2, b=28, n=4
𝑏−𝑎
ℎ= = 6.5
𝑛
150000
𝑓 𝑡 = 2500 ln − 9.8𝑡
150000 − 2000𝑡
𝑛−1 𝑛−2
𝑏−𝑎
𝑥≈ 𝑓 𝑡 + 4 𝑓 𝑡𝑖 + 2 𝑓 𝑡𝑖 + 𝑓 𝑡𝑛
3𝑛
𝑖=1 𝑖=2
𝑖=𝑜𝑑𝑑 𝑖=𝑒𝑣𝑒𝑛
f(t0)=f(2)=47.97
3 2
f(t1)=f(2+6.5)=217.41 28 − 2
𝑥≈ 𝑓 2 + 4 𝑓 𝑡𝑖 + 2 𝑓 𝑡𝑖 + 𝑓 28
f(t2)=f(8.5+6.5)=410.85 3(4)
𝑖=1 𝑖=2
𝑖=𝑜𝑑𝑑 𝑖=𝑒𝑣𝑒𝑛
f(t3)=f(15+6.5)=633.81
26
f(t4)=f(tn)=f(28)=893.95 = 𝑓 2 + 4 𝑓𝑡1 + 4𝑓 𝑓𝑡3 + 2𝑓 𝑓𝑡2 + 𝑓(30)
12
26
= (47.97 + 4 217.41 + 4 633.81 + 2 410.85
12
2. Find the true error
The exact value of the above integral is
28
150000
𝑥 = න 2500 ln − 9.8𝑡 𝑑𝑡 = 11198.22
150000 − 2000𝑡
2
So the true error is
𝐸𝑡 = 𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒 − 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑒 𝑣𝑎𝑙𝑢𝑒
=11198.22 – 11198.41 = -0.19 m
3. The absolute relative error is
𝑡𝑟𝑢𝑒 𝑒𝑟𝑟𝑜𝑟 −0.19
𝜖𝑡 = × 100 = = −1.6966 × 10−5
𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒 11198.22
Thank You