0% found this document useful (0 votes)
43 views17 pages

M25L08 NumIntA

This document discusses numerical integration methods, specifically focusing on the Trapezoidal rule and its composite extension for approximating definite integrals. It covers the derivation of the Trapezoidal rule, the remainder term, and provides examples of its application. The lecture aims to equip students with the ability to derive and apply these numerical methods effectively.

Uploaded by

thbngmzbk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views17 pages

M25L08 NumIntA

This document discusses numerical integration methods, specifically focusing on the Trapezoidal rule and its composite extension for approximating definite integrals. It covers the derivation of the Trapezoidal rule, the remainder term, and provides examples of its application. The lecture aims to equip students with the ability to derive and apply these numerical methods effectively.

Uploaded by

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

Numerical

Integration:
Part A
Numerical Methods 2 presented by H Smith
Applied Mathematics
Nelson Mandela University
Outcomes of this lecture

Approximation to definite integral

Derive and apply formulae with remainder term to approximate a


definite integral:
• Approximating the function by a polynomial of degree one leads to
Trapezoidal rule
• Extend approximation to form Composite Trapezoidal rule
• Apply to double integral
3 4
Discussion

Weighted 𝛽𝛽
functional
Approximation values � 𝑓𝑓 𝑥𝑥 𝑑𝑑𝑑𝑑
to definite 𝛼𝛼

integral

𝛼𝛼 𝛽𝛽

Paired Data “Area” under


Points the curve
Derivation of Trapezoidal rule

𝑥𝑥
Consider ∫𝑥𝑥 1 𝑓𝑓 𝑥𝑥 𝑑𝑑𝑑𝑑 and approximate the integrand by a (NDD) polynomial of degree one:
0
𝑓𝑓 𝑥𝑥1 − 𝑓𝑓 𝑥𝑥0 𝑥𝑥 − 𝑥𝑥0 𝑥𝑥 − 𝑥𝑥1 2
𝑓𝑓 𝑥𝑥 = 𝑃𝑃1 𝑥𝑥 + 𝑅𝑅1 (𝜇𝜇) = 𝑓𝑓 𝑥𝑥0 + 𝑥𝑥 − 𝑥𝑥0 + 𝑓𝑓 (𝜇𝜇)
𝑥𝑥1 − 𝑥𝑥0 2
The integral becomes:
𝑥𝑥1 𝑥𝑥1 𝑥𝑥1
� 𝑓𝑓 𝑥𝑥 𝑑𝑑𝑑𝑑 = � 𝑃𝑃1 𝑥𝑥 𝑑𝑑𝑑𝑑 + � 𝑅𝑅𝑑𝑑𝑑𝑑
𝑥𝑥0 𝑥𝑥0 𝑥𝑥0
𝑥𝑥 𝑥𝑥 𝑓𝑓 𝑥𝑥1 −𝑓𝑓 𝑥𝑥0
Consider the polynomial part : ∫𝑥𝑥 1 𝑃𝑃1 𝑥𝑥 𝑑𝑑𝑑𝑑 = ∫𝑥𝑥 1 𝑓𝑓 𝑥𝑥0 + 𝑥𝑥 − 𝑥𝑥0 𝑑𝑑𝑑𝑑
0 0 𝑥𝑥1 −𝑥𝑥0
𝑥𝑥1
𝑥𝑥1 𝑓𝑓(𝑥𝑥1 ) − 𝑓𝑓 𝑥𝑥0 1
𝑓𝑓 𝑥𝑥0 𝑥𝑥 � + 𝑥𝑥 − 𝑥𝑥0 2 �
𝑥𝑥0 (𝑥𝑥1 −𝑥𝑥0 ) 2 𝑥𝑥0
𝑓𝑓 𝑥𝑥1 − 𝑓𝑓 𝑥𝑥0
= 𝑓𝑓 𝑥𝑥0 𝑥𝑥1 − 𝑥𝑥0 + 𝑥𝑥1 − 𝑥𝑥0
2
𝑓𝑓 𝑥𝑥1 + 𝑓𝑓(𝑥𝑥0 )
= (𝑥𝑥1 − 𝑥𝑥0 )
2
Derivation of remainder term

Consider the remainder part:


𝑥𝑥1 𝑥𝑥1
𝑥𝑥 − 𝑥𝑥0 𝑥𝑥 − 𝑥𝑥1 2
� 𝑅𝑅1 (𝜇𝜇)𝑑𝑑𝑑𝑑 = � 𝑓𝑓 (𝜇𝜇) 𝑑𝑑𝑑𝑑
𝑥𝑥0 𝑥𝑥0 2
2 𝑥𝑥1
𝑓𝑓 (𝜇𝜇)
= � 𝑥𝑥 2 − 𝑥𝑥 𝑥𝑥0 + 𝑥𝑥1 + 𝑥𝑥0 𝑥𝑥1 𝑑𝑑𝑑𝑑
2 𝑥𝑥0
𝑥𝑥1
𝑓𝑓 (2) (𝜇𝜇) 𝑥𝑥 3 𝑥𝑥 2
= − 𝑥𝑥1 + 𝑥𝑥0 + 𝑥𝑥𝑥𝑥1 𝑥𝑥0 �
2 3 2
𝑥𝑥0
𝑓𝑓 (2) 𝜇𝜇 3
=− 𝑥𝑥1 − 𝑥𝑥0
12
Finally, the Trapezoidal rule is given by:
𝑥𝑥 𝑓𝑓 𝑥𝑥1 +𝑓𝑓(𝑥𝑥0 ) 𝑓𝑓(2) 𝜇𝜇 3
∫𝑥𝑥 1 𝑓𝑓 𝑥𝑥 𝑑𝑑𝑑𝑑 = (𝑥𝑥1 − 𝑥𝑥0 )
2

12
𝑥𝑥1 − 𝑥𝑥0
0
Inspection of the formula

Consider the Trapezoidal rule is given by:


𝑥𝑥1
𝑓𝑓 𝑥𝑥1 + 𝑓𝑓(𝑥𝑥0 )
� 𝑓𝑓 𝑥𝑥 𝑑𝑑𝑑𝑑 ≈ (𝑥𝑥1 − 𝑥𝑥0 )
𝑥𝑥0 2

From the formula, we see that it consists of


the width between the two integration limits
∆𝑥𝑥 = (𝑥𝑥1 − 𝑥𝑥0 )
and multiplied by the average of the functional
values of these limits
𝑓𝑓 𝑥𝑥1 + 𝑓𝑓 𝑥𝑥0
2

This leads to the impression of determining


the area of a rectangle or trapezium.
Approximating definite integral

0.8 𝑥𝑥
Example 1: ∫0.4 𝑒𝑒 𝑑𝑑𝑑𝑑
Use Trapezoidal rule:
𝑥𝑥1
𝑓𝑓 𝑥𝑥1 + 𝑓𝑓(𝑥𝑥0 ) x F(x)
� 𝑓𝑓 𝑥𝑥 𝑑𝑑𝑑𝑑 ≈ (𝑥𝑥1 − 𝑥𝑥0 )
𝑥𝑥0 2 0.4 1.49182
0.5 1.64872
0.8 − 0.4 2.22554 + 1.49182 0.6 1.82212
𝑇𝑇1 = = 0.743472
2 0.7 2.01375
True result: 0.733716 0.8 2.22554
Extension of Trapezoidal rule

From calculus we have


𝑥𝑥 𝑥𝑥 𝑥𝑥
∫𝑥𝑥 1 𝑓𝑓 𝑥𝑥 𝑑𝑑𝑑𝑑 = ∫𝑥𝑥 𝑗𝑗 𝑓𝑓 𝑥𝑥 𝑑𝑑𝑑𝑑 + ∫𝑥𝑥 1 𝑓𝑓 𝑥𝑥 𝑑𝑑𝑑𝑑
0 0 𝑗𝑗
where 𝑥𝑥𝑗𝑗 ∈ 𝑥𝑥0 , 𝑥𝑥1 .
Divide interval into multiple equally spaced
subintervals and apply Trapezoidal rule to each
subinterval.
For two equally spaced subintervals:
𝑇𝑇2
𝑥𝑥1/2 − 𝑥𝑥0
= 𝑓𝑓(𝑥𝑥1/2 ) + 𝑓𝑓(𝑥𝑥0 )
2
𝑥𝑥1 − 𝑥𝑥1/2
+ 𝑓𝑓(𝑥𝑥1/2 ) + 𝑓𝑓(𝑥𝑥1 )
2
𝑇𝑇2 = ℎ 𝟎𝟎. 𝟓𝟓𝑓𝑓 𝑥𝑥0 + 𝟏𝟏𝑓𝑓 𝑥𝑥1/2 + 𝟎𝟎. 𝟓𝟓𝑓𝑓(𝑥𝑥1 )
Where ℎ = 𝑥𝑥1 − 𝑥𝑥1/2 or ℎ = 𝑥𝑥1/2 − 𝑥𝑥0
Remainder term for two subintervals

The remainder term for interval 𝑥𝑥0 , 𝑥𝑥1/2 :


𝑓𝑓(2) 𝜇𝜇0 3
𝑅𝑅1 (𝜇𝜇0 ) = − 𝑥𝑥1/2 − 𝑥𝑥0 where 𝜇𝜇0 ∈ 𝑥𝑥0 , 𝑥𝑥1/2
12
The remainder term for interval 𝑥𝑥1/2 , 𝑥𝑥1 :
𝑓𝑓(2) 𝜇𝜇1 3
𝑅𝑅1 (𝜇𝜇1 ) = − 𝑥𝑥1 − 𝑥𝑥1/2 where 𝜇𝜇1 ∈ 𝑥𝑥1 , 𝑥𝑥1
12 2
Since the intervals are equal in length, let ℎ = 𝑥𝑥1/2 − 𝑥𝑥0 = (𝑥𝑥1 − 𝑥𝑥1/2 )
ℎ3 (2)
𝑅𝑅1 = − 𝑓𝑓 𝜇𝜇0 + 𝑓𝑓 (2) 𝜇𝜇1/2
12
Using the Intermediate value theorem:
𝑓𝑓 (2) 𝜇𝜇0 + 𝑓𝑓 (2) 𝜇𝜇1 = 2𝑓𝑓 (2) 𝜇𝜇 where 𝜇𝜇 ∈ 𝑥𝑥0 , 𝑥𝑥1
ℎ3 ℎ2
Note 2ℎ = (𝑥𝑥1 − 𝑥𝑥0 ), thus, 𝑅𝑅1 = − 2𝑓𝑓 2 𝜇𝜇 = − (𝑥𝑥1 − 𝑥𝑥0 )𝑓𝑓 (2) 𝜇𝜇
12 12
Approximating definite integral

0.8 𝑥𝑥
Example 1: ∫0.4 𝑒𝑒 𝑑𝑑𝑑𝑑
Use Trapezoidal rule:
𝑥𝑥1
𝑓𝑓 𝑥𝑥0 𝑓𝑓 𝑥𝑥1 x F(x)
� 𝑓𝑓 𝑥𝑥 𝑑𝑑𝑑𝑑 ≈ ℎ( + 𝑓𝑓 𝑥𝑥1/2 + )
𝑥𝑥0 2 2 0.4 1.49182
0.5 1.64872
1.49182 2.22554
𝑇𝑇2 = (0.8 − 0.6)( + 1.82212 + ) = 0.736160 0.6 1.82212
2 2
0.7 2.01375
True result: 0.733716 0.8 2.22554

Class: Determine 𝑇𝑇4


Composite Trapezoidal rule
𝑏𝑏
Consider the definite integral: ∫𝑎𝑎 𝑓𝑓 𝑥𝑥 𝑑𝑑𝑑𝑑
The interval [𝑎𝑎, 𝑏𝑏] is subdivided into 𝑛𝑛 subintervals with (𝑛𝑛 + 1) equally
𝑥𝑥 −𝑥𝑥
spaced points. Let ℎ = 𝑥𝑥𝑗𝑗+1 − 𝑥𝑥𝑗𝑗 = 𝑛𝑛 0 where 𝑎𝑎 = 𝑥𝑥0 and 𝑏𝑏 = 𝑥𝑥𝑛𝑛
𝑛𝑛
The Composite Trapezoidal rule is then given by:
(𝑛𝑛−1)
𝑓𝑓(𝑥𝑥0 ) 𝑓𝑓(𝑥𝑥𝑛𝑛 )
𝑇𝑇 = ℎ + � 𝑓𝑓(𝑥𝑥𝑗𝑗 ) +
2 2
𝑗𝑗=1
With remainder term:
ℎ2
𝑅𝑅1 = − (𝑥𝑥𝑛𝑛 − 𝑥𝑥0 )𝑓𝑓 (2) 𝜇𝜇 where μ ∈ 𝑥𝑥0 , 𝑥𝑥𝑛𝑛
12
𝑦𝑦𝑏𝑏 𝑥𝑥𝑏𝑏
Double Integrals: ∫𝑦𝑦 ∫𝑥𝑥 𝑓𝑓(𝑥𝑥, 𝑦𝑦)𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑
𝑎𝑎 𝑎𝑎

(𝑥𝑥𝑏𝑏 −𝑥𝑥𝑎𝑎 ) (𝑦𝑦𝑏𝑏 −𝑦𝑦𝑎𝑎 )


Construct a two-dimensional grid with ℎ𝑥𝑥 = and ℎ𝑦𝑦 = .
𝑛𝑛𝑥𝑥 𝑛𝑛𝑦𝑦

Note that 𝑥𝑥𝑎𝑎 = 𝑥𝑥0 ; 𝑥𝑥𝑏𝑏 = 𝑥𝑥𝑛𝑛𝑥𝑥 ; 𝑦𝑦𝑎𝑎 = 𝑦𝑦0 and 𝑦𝑦𝑏𝑏 = 𝑦𝑦𝑛𝑛𝑦𝑦
Apply Composite Trapezoidal Rule first for say 𝑥𝑥 domain:
𝑦𝑦𝑏𝑏 𝑥𝑥𝑏𝑏 𝑦𝑦𝑏𝑏 𝑛𝑛𝑥𝑥 −1

� � 𝑓𝑓(𝑥𝑥, 𝑦𝑦)𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑 ≈ � ℎ𝑥𝑥 0.5𝑓𝑓 𝑥𝑥0 , 𝑦𝑦 + 1 � 𝑓𝑓(𝑥𝑥𝑗𝑗 , 𝑦𝑦) + 0.5𝑓𝑓(𝑥𝑥𝑛𝑛𝑥𝑥 , 𝑦𝑦) 𝑑𝑑𝑑𝑑
𝑦𝑦𝑎𝑎 𝑥𝑥𝑎𝑎 𝑦𝑦𝑎𝑎 𝑗𝑗=1
1
Factorize from the approximation i.e
2
𝑦𝑦𝑏𝑏 𝑥𝑥𝑏𝑏 𝑦𝑦𝑏𝑏 𝑛𝑛𝑥𝑥 −1
ℎ𝑥𝑥
� � 𝑓𝑓(𝑥𝑥, 𝑦𝑦)𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑 ≈ � 1𝑓𝑓 𝑥𝑥0 , 𝑦𝑦 + 2 � 𝑓𝑓(𝑥𝑥𝑗𝑗 , 𝑦𝑦) + 1𝑓𝑓(𝑥𝑥𝑛𝑛𝑥𝑥 , 𝑦𝑦) 𝑑𝑑𝑑𝑑
𝑦𝑦𝑎𝑎 𝑥𝑥𝑎𝑎 𝑦𝑦𝑎𝑎 2
𝑗𝑗=1

Note: the variable 𝑦𝑦 is treated independent to 𝑥𝑥.


𝑦𝑦𝑏𝑏 𝑥𝑥𝑏𝑏
Double Integrals: ∫𝑦𝑦 ∫𝑥𝑥 𝑓𝑓(𝑥𝑥, 𝑦𝑦)𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑
𝑎𝑎 𝑎𝑎

Then 𝑦𝑦 domain. We have three integrals:

𝑛𝑛𝑦𝑦 −1
𝑦𝑦𝑏𝑏
ℎ𝑥𝑥 ℎ𝑥𝑥 ℎ𝑦𝑦
� 1𝑓𝑓(𝒙𝒙𝟎𝟎 , 𝑦𝑦) 𝑑𝑑𝑑𝑑 ≈ 1 𝒇𝒇 𝒙𝒙𝟎𝟎 , 𝒚𝒚𝟎𝟎 + 2 � 𝑓𝑓(𝑥𝑥0 , 𝑦𝑦𝑘𝑘 ) + 𝒇𝒇(𝒙𝒙𝟎𝟎 , 𝒚𝒚𝒏𝒏𝒚𝒚 )
2 𝑦𝑦𝑎𝑎 2 2
𝑘𝑘=1
Integral of a summation = summation of integral
𝑛𝑛𝑥𝑥 −1 𝑛𝑛𝑥𝑥 −1 𝑛𝑛𝑦𝑦 −1
𝑦𝑦𝑏𝑏
ℎ𝑥𝑥 ℎ𝑥𝑥 ℎ𝑦𝑦
� ( � 2𝑓𝑓(𝒙𝒙𝒋𝒋 , 𝑦𝑦) 𝑑𝑑𝑑𝑑) ≈ � 2 𝑓𝑓 𝑥𝑥𝑗𝑗 , 𝑦𝑦0 + 2 � 𝑓𝑓(𝑥𝑥𝑗𝑗 , 𝑦𝑦𝑘𝑘 ) + 𝑓𝑓(𝑥𝑥𝑗𝑗 , 𝑦𝑦𝑛𝑛𝑦𝑦 )
2 𝑦𝑦𝑎𝑎 2 2
𝑗𝑗=1 𝑗𝑗=1 𝑘𝑘=1
and
𝑛𝑛𝑦𝑦 −1
𝑦𝑦𝑏𝑏
ℎ𝑥𝑥 ℎ𝑥𝑥 ℎ𝑦𝑦
� 1𝑓𝑓(𝒙𝒙𝒏𝒏𝒙𝒙 , 𝑦𝑦) 𝑑𝑑𝑑𝑑 ≈ 1 𝒇𝒇 𝒙𝒙𝒏𝒏𝒙𝒙 , 𝒚𝒚𝟎𝟎 + 2 � 𝑓𝑓 𝑥𝑥𝑛𝑛𝑥𝑥 , 𝑦𝑦𝑘𝑘 + 𝒇𝒇 𝒙𝒙𝒏𝒏𝒙𝒙 , 𝒚𝒚𝒏𝒏𝒚𝒚
2 𝑦𝑦𝑎𝑎 2 2
𝑘𝑘=1
𝑦𝑦𝑏𝑏 𝑥𝑥𝑏𝑏
Double Integrals: ∫𝑦𝑦 ∫𝑥𝑥 𝑓𝑓(𝑥𝑥, 𝑦𝑦)𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑
𝑎𝑎 𝑎𝑎

Finally, we combine to obtain:

𝑦𝑦𝑏𝑏 𝑥𝑥𝑏𝑏 ℎ𝑦𝑦 ℎ𝑥𝑥


� � 𝑓𝑓 𝑥𝑥, 𝑦𝑦 𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑 ≈ 𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪 + 𝑬𝑬𝑬𝑬𝑬𝑬𝑬𝑬𝑬𝑬 + 𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰
𝑦𝑦𝑎𝑎 𝑥𝑥𝑎𝑎 4
Where,
𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶 = 𝑓𝑓 𝑥𝑥0 , 𝑦𝑦0 + 𝑓𝑓 𝑥𝑥𝑛𝑛𝑥𝑥 , 𝑦𝑦0 + 𝑓𝑓 𝑥𝑥𝑛𝑛𝑥𝑥 , 𝑦𝑦𝑛𝑛𝑦𝑦 + 𝑓𝑓 𝑥𝑥0 , 𝑦𝑦𝑛𝑛𝑦𝑦
𝑛𝑛𝑦𝑦 −1 𝑛𝑛𝑥𝑥 −1

𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸 = 2 � (𝑓𝑓 𝑥𝑥0 , 𝑦𝑦𝑘𝑘 + 𝑓𝑓(𝑥𝑥𝑛𝑛𝑥𝑥 , 𝑦𝑦𝑘𝑘 )) + 2 � (𝑓𝑓 𝑥𝑥𝑗𝑗 , 𝑦𝑦0 + 𝑓𝑓(𝑥𝑥𝑗𝑗 , 𝑦𝑦𝑛𝑛𝑦𝑦 ))
𝑘𝑘=1 𝑗𝑗=1
𝑛𝑛𝑦𝑦 −1 𝑛𝑛𝑥𝑥 −1

𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼 = 4 � � 𝑓𝑓(𝑥𝑥𝑗𝑗 , 𝑦𝑦𝑘𝑘 )


𝑘𝑘=1 𝑗𝑗=1
The grid for Composite Trapezoidal

Corner point Edge point Internal point


𝑦𝑦𝑏𝑏 𝑥𝑥𝑏𝑏
Double Integrals: ∫𝑦𝑦 ∫𝑥𝑥 𝑓𝑓(𝑥𝑥, 𝑦𝑦)𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑
𝑎𝑎 𝑎𝑎

With ℎ𝑥𝑥 = 0.2 and ℎ𝑦𝑦 = 0.1 we obtain: 𝑇𝑇𝑥𝑥𝑥𝑥 = 0.466402246


Numerical
Integration:
Part B

You might also like