0% found this document useful (0 votes)
64 views

Matlab Project

The document describes numerical integration methods for approximating definite integrals, specifically the trapezoidal rule and Simpson's rule. It provides outlines and formulas for: 1) The trapezoidal rule and its composite form for approximating integrals using linear interpolation over subintervals. 2) Simpson's 1/3 rule which uses quadratic interpolation over two intervals, and its multiple-segment extension for dividing the interval into an even number of segments. 3) An example applying Simpson's 1/3 rule to estimate the distance covered by a rocket between time intervals by approximating the definite integral representation of the distance function.

Uploaded by

Uyên Thư
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views

Matlab Project

The document describes numerical integration methods for approximating definite integrals, specifically the trapezoidal rule and Simpson's rule. It provides outlines and formulas for: 1) The trapezoidal rule and its composite form for approximating integrals using linear interpolation over subintervals. 2) Simpson's 1/3 rule which uses quadratic interpolation over two intervals, and its multiple-segment extension for dividing the interval into an even number of segments. 3) An example applying Simpson's 1/3 rule to estimate the distance covered by a rocket between time intervals by approximating the definite integral representation of the distance function.

Uploaded by

Uyên Thư
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

Group 8: Matlab project

Numerical integration
Presentation Outline

1. Trapezoidal rule
2. Simpson’s rule
Newton-Leibniz formula

 f ( x)dx  F ( x) |  F (b)  F (a ), F '( x)  f ( x)


b
a
a

• But the function f(x) is not defined


• Replace f(x) by the interpolating polynomial
Pn(x)
1. Trapezoidal rule

• To approximating, we replace f(x) by Newton


forward divided-difference formula which
passes 2 point from (a,f(a)) and (b,f(b))

f (b)  f (a)
P( x)  f (a)  f [a, b]( x  a)  f (a)  ( x  a)
ba
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 ba 2
ba
 [ f ( a )  f (b)]
2

b ba
a
f ( x)dx 
2
[ f (a)  f (b)]
Composite Trapezoidal rule

• Divide the interval [a,b] into n subinterval


• Subinterval width is h=(b-a)/n

a  x0 , x1  x0  h,..., xk  x0  kh,...xn  x0  nh
yk  f ( xk ), k  0,1, 2,..., n
Composite Trapezoidal rule

• Using trapezoidal rule for each subinterval we have


b
x1 x2 xn
a
f ( x ) dx  
x0
f ( x ) dx  
x1
f ( x ) dx ....  
xn1
f ( x)dx

y0  y1 y1  y2 yn 1  yn
h h  ...  h
2 2 2
2. SIMPSON’RULE

Definition

Formula

Simpson’s 1/3 Rule

Multiple-segment Simpson’s 1/3 Rule


Definition

• Simpson’s 1/3 rule is an extension of Trapezoidal rule


where the integrand is approximated by a second order
polynomial.

• Multiple-segment Simpson’s 1/3 Rule Just like in multiple-


segment trapezoidal rule, one can subdivide the interval
[a,b] into n segments and apply Simpson’s 1/3 rule
repeatedly over every two segments. Note that n needs to
be even. Divide interval [a,b] into n equal segments
Formula

Simpson’s 1/3 Rule Multiple-segment Simpson’s 1/3 Rule


Simpson’s 1/3 rule’s Proverment

Hence
Where f2(x) a second order polynomial
given by:

Choose

as the three points of the function to evaluate , a0 a1 and a2 .


• Solving the above three equations for unknowns a0 a1 and a2 give:

• Simpson’s 1/3 Rule of Integration


• Then

• Substituting values of a0 a1 and a2 give


Since for Simpson 1/3 rule, the interval [a,b] is broken into 2
segments, the segment width

Hence the Simpson’s 1/3 rule is given by


EXAMPLE

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 distance covered


2. Find the true error by a rocket in meters from
t=2s to t= 28s is given by
The exact28 value of the above integral is
𝑥 150000
𝑥28= න 2500 ln − 9.8t
150000
150000 − 2000𝑡
= න 2500 ln
2 − 9.8𝑡 𝑑𝑡 = 11198.22
150000 − 2000𝑡
1. 2Use Simpson’s 1/3 rule to find the approximate
So the trueoferror
value x . is:
𝐸𝑡 = 𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒 − 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑒 𝑣𝑎𝑙𝑢𝑒
2. Use Simpson’s 1/3 rule to find the approximate
=11198.22 – 11203.05 = -4.833 m
value of x .
The absolute relative error is
3. Find𝑡𝑟𝑢𝑒
the 𝑒𝑟𝑟𝑜𝑟
absolute relative true error 𝜖𝑡
−4.8333 −4
𝜖𝑡 = × 100 = = −4.316 × 10
𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒 11198.22
Multiple-segment Simpson’s 1/3 Rule

𝑏−𝑎
• The segment width is given by ℎ=
𝑛

Now

Where
Multiple-segment Simpson’s 1/3 Rule

• Aplly Simpson’s 1/3rd Rule over each interval,


Multiple-segment Simpson’s 1/3 Rule
• Sine 𝑥𝑖 − 𝑥𝑖−2 = 2ℎ 𝑎𝑛𝑑 𝑖 = 2,4, … , 𝑛
• Then

• Simpson’s 1/3 Rule of Integration


Multiple-segment Simpson’s 1/3 Rule

𝑏−𝑎
• The segment width is given by ℎ=
𝑛

Now

Where
EXAMPLE

Use 4-segment Simpson’s 1/3 rule to approximate the distance


covered by a rocket in meters from t = 2 s to t = 28s as given by:
28
150000
𝑥 = න 2500 ln − 9.8t
150000 − 2000𝑡
2
1. Use four segment Simpson’s 1/3rd Rule to estimate x.
2. Find the true error
3. Find the absolute relative true error
Solution

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

You might also like