SlideShare a Scribd company logo
1 of 9
Problem Statement: Define trapezoidal formula for, write the algorithm, draw the
flowchart, and develop a python program for trapezoidal formula.
Trapezoidal Formula:
In Numerical analysis, the trapezoidal rule or method is a technique for approximating the
definite integral.
∫ 𝑓( 𝑥) 𝑑𝑥
𝑥𝑛
𝑥0
= h 1.y0 +
1
2
∆𝑦0
It is also known as trapezium rule.
In general Integration formula when n=1 its trapezoidal rule is
= h 1.y0 +
1
2
(𝑦1 − 𝑦0
= h/2 (y0 + y1)
∫ 𝑓( 𝑥) 𝑑𝑥
𝑥n
𝑥0
= ∫ 𝑓( 𝑥) 𝑑𝑥
𝑥0+𝑛ℎ
𝑥0
= ∫ 𝑓( 𝑥) 𝑑𝑥
𝑥0+ℎ
𝑥0
+ ∫ 𝑓( 𝑥) 𝑑𝑥 + ⋯.
𝑥0+2ℎ
𝑥0+ℎ
+ ∫ 𝑓( 𝑥) 𝑑𝑥
𝑥0+𝑛ℎ
𝑥0+( 𝑛−1)ℎ
=
ℎ
2
(y0+ y1) +
ℎ
2
(y1+y2) + …….. + h/2 (yn-1 + yn)
=
ℎ
2
(y0+ y1) + 2(y1+y2+ y3+ y4+…….. yn-1)
= h/2 sum of the first and last ordinates + 2(sum of the remaining ordinates)
Geometrical Interpretation:
Geometrically, if the ordered pairs (x1, y1), i = 0, 1, 2,…….,n are potted, and if any two
consecutive points are joined by straight lines, we get the figure as shown.
The area between f(x), x-axis and ordinates x = x0 and x = xn is approximated to sum of the
areas of the trapeziums as shown in the figure.
Fig: Geometrical Interpretation of trapezoidal rule.
How it Works:
Trapezoid is an one kind of rectangle which has 4 sides and minimum two sides are parallel
Area = (
𝑏1+𝑏2
2
)h
The Trapezoidal rule works by approximating the region under the graph of the function as a
trapezoid and calculating its area in limit.
It follows that,
∫ 𝑓( 𝑥) 𝑑𝑥 ≈ (
𝑏 − 𝑎
2
)[ 𝑓( 𝑎) + 𝑓(𝑏)]
𝑏
𝑎
The Trapezoidal rule approximation improves with more strips, from this figure we can clearly see
it
Truncation error in Trapezoidal rule:
In the neighbourhood of x = x0, we can expand y = f(x), by Tailor series in power of x-x0, that
is,
Y(x) = y0 +
(𝑥−𝑥0)
1!
(y0’) +
(𝑥−𝑥0)2
2!
(y0”) + …… + …
Algorithm:
 Start
 Define and Declare the function
 Input initial boundary value, final boundary value and length of interval
 Calculate number of strips, n=(final boundary value-initial boundary value)/length of
interval
 Perform the following operations in loop
x[i]=x0+i*h
y[i]=f(x[i])
print y[i]
 Initialize se=0,s0=0
 Do the following using a loop
if i%2=0
s0=s0+y[i]
Otherwise
se=se+y[i]
 ans=h/3*(y[0]+y[n]+4*s0+2*se
 print the ans
 stop
Flowchart:
Coding:
def Trapezoidal(f, a, b, n):
h = (b-a)/float (n)
s = 0.5*(f (a) + f(b))
for i in range(1,n,1):
s = s + f(a + i*h)
return h*s
from math import exp
def g(t):
return exp(-t**4)
a = -2; b = 2
n = 1000
result = Trapezoidal(g, a, b, n)
print result
Sample Input:
Enter sample inputes
a = -2, b = 2, n= 1000
Sample Output:
Answer is: 1.8128049473666044
Exercise:
Problem 1: Evaluate ∫ 𝑑𝑥/
6
0
(1+x2) by using Trapezoidal rule.
Solution:
Divide the interval (0,6) into 6 parts each of width h = 1, The values of f(x)=
1
1+𝑥2
are given
below.
x 0 1 2 3 4 5 6
F(x)x = y 1 0.5 0.2 0.1 0.0588 0.0385 0.027
Y0 Y1 Y2 Y3 Y4 Y5 Y6
By Trapezoidal rule, we have,
∫
𝑑𝑥
(1+𝑥2)
6
0
=
ℎ
2
(y0+ y6) + 2(y1+y2+ y3+ y4 + y5)
=
ℎ
2
(1+0.027) + 2(0.5+0.2+0.1+0.0588+0.0385)
= 1.4108
The answer is 1.4108
Problem 2: Dividing the range into 10 equal ports, find the approximate value of ∫ 𝑠𝑖𝑛𝑥𝑑𝑥
𝜋
0
by trapezoidal rule.
Solution:
The range (0,𝜋) is divided into 10 equal parts,
Hence, h = 𝜋/10
We compute the values of sinx for each point of subdivision,
i.e., for x =0,
𝜋
10
,
2𝜋
10
, … … 𝜋. These values are tabulated as follows
x 0 𝜋/10 2𝜋/10 3𝜋/10 4𝜋/10 5𝜋/10 6𝜋/10 7𝜋/10 8𝜋/10 9𝜋/10 𝜋
sinx 0 0.3090 0.5878 0.8090 0.9511 1 0.9511 0.8090 0.5878 0.3090 0
Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7 Y8 Y9 Y10
By Trapezoidal rule, we have,
∫ 𝑠𝑖𝑛𝑥𝑑𝑥
𝑥
0
=
ℎ
2
(y0+ y10) + 2(y1+y2+ y3+ y4 + y5+ y6+y7+ y8+ y9)
h =
𝜋
10
∫ 𝑠𝑖𝑛𝑥𝑑𝑥
𝑥
0
=
𝜋
20
(0+0) + 2(0.3090+0.5878+0.8090+0.9511+1+0.3090+0.5878+0.8090+0.9511)
=
𝜋
20
2*6.3138)
= 1.984 (approximately)
The answer is 1.984.
Problem 3: Using n=5, Calculate approximate the integral by trapezoidal rule.
∫ √
5
1
(x2+1).
Solution:
For n = 5 we have △x = 5−1/5= 0.8
Computing the values for y0, y1,......,y5
x y = √1+x2
1 1.41
1.8 2.06
2.6 2.78
3.4 3.54
4.2 4.32
5 5.10
∫ √
5
1
(x2+1) dx = 0.8/2 (1.41 + 2(2.06) + 2(2.18) + 2(3.54) + 2(4.32) + (5.10))
= 12.284
The answer is 12.284.
Conclusion:
The above program is successfully written in python programming language for Trapezoidal
formula which can calculate the approximating integrals.
Reference:
1. https://en.wikipedia.org/wiki/Trapezoidal_rule
2. https://stackoverflow.com
Trapezoidal Method IN  Numerical Analysis

More Related Content

What's hot

Numerical Differentiations Solved examples
Numerical Differentiations Solved examplesNumerical Differentiations Solved examples
Numerical Differentiations Solved examplesDevelopedia
 
application of partial differentiation
application of partial differentiationapplication of partial differentiation
application of partial differentiationeteaching
 
Lagrange's method
Lagrange's methodLagrange's method
Lagrange's methodKarnav Rana
 
Linear transformation.ppt
Linear transformation.pptLinear transformation.ppt
Linear transformation.pptRaj Parekh
 
Runge Kutta Method
Runge Kutta Method Runge Kutta Method
Runge Kutta Method Bhavik Vashi
 
Presentation on Numerical Integration
Presentation on Numerical IntegrationPresentation on Numerical Integration
Presentation on Numerical IntegrationTausif Shahanshah
 
Lagrange equation and its application
Lagrange equation and its applicationLagrange equation and its application
Lagrange equation and its applicationMahmudul Alam
 
Laplace Transform and its applications
Laplace Transform and its applicationsLaplace Transform and its applications
Laplace Transform and its applicationsDeepRaval7
 
Interpolation with Finite differences
Interpolation with Finite differencesInterpolation with Finite differences
Interpolation with Finite differencesDr. Nirav Vyas
 
Ordinary differential equations
Ordinary differential equationsOrdinary differential equations
Ordinary differential equationsAhmed Haider
 
Matlab Graphics Tutorial
Matlab Graphics TutorialMatlab Graphics Tutorial
Matlab Graphics TutorialCheng-An Yang
 
Newton raphson method
Newton raphson methodNewton raphson method
Newton raphson methodBijay Mishra
 
APPLICATION OF PARTIAL DIFFERENTIATION
APPLICATION OF PARTIAL DIFFERENTIATIONAPPLICATION OF PARTIAL DIFFERENTIATION
APPLICATION OF PARTIAL DIFFERENTIATIONDhrupal Patel
 
Fourier series of odd functions with period 2 l
Fourier series of odd functions with period 2 lFourier series of odd functions with period 2 l
Fourier series of odd functions with period 2 lPepa Vidosa Serradilla
 
Partial differential equations
Partial differential equationsPartial differential equations
Partial differential equationsaman1894
 

What's hot (20)

Numerical Differentiations Solved examples
Numerical Differentiations Solved examplesNumerical Differentiations Solved examples
Numerical Differentiations Solved examples
 
application of partial differentiation
application of partial differentiationapplication of partial differentiation
application of partial differentiation
 
Lagrange's method
Lagrange's methodLagrange's method
Lagrange's method
 
Differential equations
Differential equationsDifferential equations
Differential equations
 
Initial Value Problems
Initial Value ProblemsInitial Value Problems
Initial Value Problems
 
Linear transformation.ppt
Linear transformation.pptLinear transformation.ppt
Linear transformation.ppt
 
Runge Kutta Method
Runge Kutta Method Runge Kutta Method
Runge Kutta Method
 
Presentation on Numerical Integration
Presentation on Numerical IntegrationPresentation on Numerical Integration
Presentation on Numerical Integration
 
Lagrange equation and its application
Lagrange equation and its applicationLagrange equation and its application
Lagrange equation and its application
 
Unit 5: All
Unit 5: AllUnit 5: All
Unit 5: All
 
Laplace Transform and its applications
Laplace Transform and its applicationsLaplace Transform and its applications
Laplace Transform and its applications
 
newton raphson method
newton raphson methodnewton raphson method
newton raphson method
 
Fourier series
Fourier seriesFourier series
Fourier series
 
Interpolation with Finite differences
Interpolation with Finite differencesInterpolation with Finite differences
Interpolation with Finite differences
 
Ordinary differential equations
Ordinary differential equationsOrdinary differential equations
Ordinary differential equations
 
Matlab Graphics Tutorial
Matlab Graphics TutorialMatlab Graphics Tutorial
Matlab Graphics Tutorial
 
Newton raphson method
Newton raphson methodNewton raphson method
Newton raphson method
 
APPLICATION OF PARTIAL DIFFERENTIATION
APPLICATION OF PARTIAL DIFFERENTIATIONAPPLICATION OF PARTIAL DIFFERENTIATION
APPLICATION OF PARTIAL DIFFERENTIATION
 
Fourier series of odd functions with period 2 l
Fourier series of odd functions with period 2 lFourier series of odd functions with period 2 l
Fourier series of odd functions with period 2 l
 
Partial differential equations
Partial differential equationsPartial differential equations
Partial differential equations
 

Similar to Trapezoidal Method IN Numerical Analysis

Applications of Differential Calculus in real life
Applications of Differential Calculus in real life Applications of Differential Calculus in real life
Applications of Differential Calculus in real life OlooPundit
 
Lecture 3 - Series Expansion III.pptx
Lecture 3 - Series Expansion III.pptxLecture 3 - Series Expansion III.pptx
Lecture 3 - Series Expansion III.pptxPratik P Chougule
 
Matlab lab manual
Matlab lab manualMatlab lab manual
Matlab lab manualnmahi96
 
Differential Calculus- differentiation
Differential Calculus- differentiationDifferential Calculus- differentiation
Differential Calculus- differentiationSanthanam Krishnan
 
Physical Chemistry Assignment Help
Physical Chemistry Assignment HelpPhysical Chemistry Assignment Help
Physical Chemistry Assignment HelpEdu Assignment Help
 
NONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALES
NONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALESNONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALES
NONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALESTahia ZERIZER
 
Study Material Numerical Differentiation and Integration
Study Material Numerical Differentiation and IntegrationStudy Material Numerical Differentiation and Integration
Study Material Numerical Differentiation and IntegrationMeenakshisundaram N
 
Numerical Methods.pptx
Numerical Methods.pptxNumerical Methods.pptx
Numerical Methods.pptxRehmanRasheed3
 
Term paper inna_tarasyan
Term paper inna_tarasyanTerm paper inna_tarasyan
Term paper inna_tarasyanInna Таrasyan
 
2. Fixed Point Iteration.pptx
2. Fixed Point Iteration.pptx2. Fixed Point Iteration.pptx
2. Fixed Point Iteration.pptxsaadhaq6
 
Rasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithmRasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithmKALAIRANJANI21
 
Rasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithmRasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithmKALAIRANJANI21
 
Differential Calculus
Differential Calculus Differential Calculus
Differential Calculus OlooPundit
 
research paper publication
research paper publicationresearch paper publication
research paper publicationsamuu45sam
 

Similar to Trapezoidal Method IN Numerical Analysis (20)

Applications of Differential Calculus in real life
Applications of Differential Calculus in real life Applications of Differential Calculus in real life
Applications of Differential Calculus in real life
 
NPDE-TCA
NPDE-TCANPDE-TCA
NPDE-TCA
 
Lecture 3 - Series Expansion III.pptx
Lecture 3 - Series Expansion III.pptxLecture 3 - Series Expansion III.pptx
Lecture 3 - Series Expansion III.pptx
 
Matlab lab manual
Matlab lab manualMatlab lab manual
Matlab lab manual
 
Differential Calculus- differentiation
Differential Calculus- differentiationDifferential Calculus- differentiation
Differential Calculus- differentiation
 
Physical Chemistry Assignment Help
Physical Chemistry Assignment HelpPhysical Chemistry Assignment Help
Physical Chemistry Assignment Help
 
NONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALES
NONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALESNONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALES
NONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALES
 
Study Material Numerical Differentiation and Integration
Study Material Numerical Differentiation and IntegrationStudy Material Numerical Differentiation and Integration
Study Material Numerical Differentiation and Integration
 
Numerical Methods.pptx
Numerical Methods.pptxNumerical Methods.pptx
Numerical Methods.pptx
 
Term paper inna_tarasyan
Term paper inna_tarasyanTerm paper inna_tarasyan
Term paper inna_tarasyan
 
stochastic processes assignment help
stochastic processes assignment helpstochastic processes assignment help
stochastic processes assignment help
 
doc
docdoc
doc
 
2. Fixed Point Iteration.pptx
2. Fixed Point Iteration.pptx2. Fixed Point Iteration.pptx
2. Fixed Point Iteration.pptx
 
Rasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithmRasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithm
 
Rasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithmRasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithm
 
Ch05 2
Ch05 2Ch05 2
Ch05 2
 
05_AJMS_332_21.pdf
05_AJMS_332_21.pdf05_AJMS_332_21.pdf
05_AJMS_332_21.pdf
 
Triple Integral
Triple IntegralTriple Integral
Triple Integral
 
Differential Calculus
Differential Calculus Differential Calculus
Differential Calculus
 
research paper publication
research paper publicationresearch paper publication
research paper publication
 

More from Mostafijur Rahman

More from Mostafijur Rahman (7)

Health-aware Personalized Food Recommender System
 Health-aware Personalized Food Recommender System Health-aware Personalized Food Recommender System
Health-aware Personalized Food Recommender System
 
Tower of Hanoi
Tower of HanoiTower of Hanoi
Tower of Hanoi
 
Project Proposal
Project ProposalProject Proposal
Project Proposal
 
Key management
Key managementKey management
Key management
 
Public Key Distribution
Public Key Distribution Public Key Distribution
Public Key Distribution
 
Challenge responese networking
Challenge responese networkingChallenge responese networking
Challenge responese networking
 
Namaz remainder demo presentation
Namaz remainder demo presentationNamaz remainder demo presentation
Namaz remainder demo presentation
 

Recently uploaded

DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........LeaCamillePacle
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayMakMakNepo
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 

Recently uploaded (20)

DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up Friday
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 

Trapezoidal Method IN Numerical Analysis

  • 1. Problem Statement: Define trapezoidal formula for, write the algorithm, draw the flowchart, and develop a python program for trapezoidal formula. Trapezoidal Formula: In Numerical analysis, the trapezoidal rule or method is a technique for approximating the definite integral. ∫ 𝑓( 𝑥) 𝑑𝑥 𝑥𝑛 𝑥0 = h 1.y0 + 1 2 ∆𝑦0 It is also known as trapezium rule. In general Integration formula when n=1 its trapezoidal rule is = h 1.y0 + 1 2 (𝑦1 − 𝑦0 = h/2 (y0 + y1) ∫ 𝑓( 𝑥) 𝑑𝑥 𝑥n 𝑥0 = ∫ 𝑓( 𝑥) 𝑑𝑥 𝑥0+𝑛ℎ 𝑥0 = ∫ 𝑓( 𝑥) 𝑑𝑥 𝑥0+ℎ 𝑥0 + ∫ 𝑓( 𝑥) 𝑑𝑥 + ⋯. 𝑥0+2ℎ 𝑥0+ℎ + ∫ 𝑓( 𝑥) 𝑑𝑥 𝑥0+𝑛ℎ 𝑥0+( 𝑛−1)ℎ = ℎ 2 (y0+ y1) + ℎ 2 (y1+y2) + …….. + h/2 (yn-1 + yn) = ℎ 2 (y0+ y1) + 2(y1+y2+ y3+ y4+…….. yn-1) = h/2 sum of the first and last ordinates + 2(sum of the remaining ordinates) Geometrical Interpretation: Geometrically, if the ordered pairs (x1, y1), i = 0, 1, 2,…….,n are potted, and if any two consecutive points are joined by straight lines, we get the figure as shown. The area between f(x), x-axis and ordinates x = x0 and x = xn is approximated to sum of the areas of the trapeziums as shown in the figure.
  • 2. Fig: Geometrical Interpretation of trapezoidal rule. How it Works: Trapezoid is an one kind of rectangle which has 4 sides and minimum two sides are parallel Area = ( 𝑏1+𝑏2 2 )h The Trapezoidal rule works by approximating the region under the graph of the function as a trapezoid and calculating its area in limit.
  • 3. It follows that, ∫ 𝑓( 𝑥) 𝑑𝑥 ≈ ( 𝑏 − 𝑎 2 )[ 𝑓( 𝑎) + 𝑓(𝑏)] 𝑏 𝑎 The Trapezoidal rule approximation improves with more strips, from this figure we can clearly see it Truncation error in Trapezoidal rule: In the neighbourhood of x = x0, we can expand y = f(x), by Tailor series in power of x-x0, that is, Y(x) = y0 + (𝑥−𝑥0) 1! (y0’) + (𝑥−𝑥0)2 2! (y0”) + …… + …
  • 4. Algorithm:  Start  Define and Declare the function  Input initial boundary value, final boundary value and length of interval  Calculate number of strips, n=(final boundary value-initial boundary value)/length of interval  Perform the following operations in loop x[i]=x0+i*h y[i]=f(x[i]) print y[i]  Initialize se=0,s0=0  Do the following using a loop if i%2=0 s0=s0+y[i] Otherwise se=se+y[i]  ans=h/3*(y[0]+y[n]+4*s0+2*se  print the ans  stop
  • 6. Coding: def Trapezoidal(f, a, b, n): h = (b-a)/float (n) s = 0.5*(f (a) + f(b)) for i in range(1,n,1): s = s + f(a + i*h) return h*s from math import exp def g(t): return exp(-t**4) a = -2; b = 2 n = 1000 result = Trapezoidal(g, a, b, n) print result Sample Input: Enter sample inputes a = -2, b = 2, n= 1000 Sample Output: Answer is: 1.8128049473666044 Exercise: Problem 1: Evaluate ∫ 𝑑𝑥/ 6 0 (1+x2) by using Trapezoidal rule. Solution: Divide the interval (0,6) into 6 parts each of width h = 1, The values of f(x)= 1 1+𝑥2 are given below.
  • 7. x 0 1 2 3 4 5 6 F(x)x = y 1 0.5 0.2 0.1 0.0588 0.0385 0.027 Y0 Y1 Y2 Y3 Y4 Y5 Y6 By Trapezoidal rule, we have, ∫ 𝑑𝑥 (1+𝑥2) 6 0 = ℎ 2 (y0+ y6) + 2(y1+y2+ y3+ y4 + y5) = ℎ 2 (1+0.027) + 2(0.5+0.2+0.1+0.0588+0.0385) = 1.4108 The answer is 1.4108 Problem 2: Dividing the range into 10 equal ports, find the approximate value of ∫ 𝑠𝑖𝑛𝑥𝑑𝑥 𝜋 0 by trapezoidal rule. Solution: The range (0,𝜋) is divided into 10 equal parts, Hence, h = 𝜋/10 We compute the values of sinx for each point of subdivision, i.e., for x =0, 𝜋 10 , 2𝜋 10 , … … 𝜋. These values are tabulated as follows x 0 𝜋/10 2𝜋/10 3𝜋/10 4𝜋/10 5𝜋/10 6𝜋/10 7𝜋/10 8𝜋/10 9𝜋/10 𝜋 sinx 0 0.3090 0.5878 0.8090 0.9511 1 0.9511 0.8090 0.5878 0.3090 0 Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7 Y8 Y9 Y10 By Trapezoidal rule, we have, ∫ 𝑠𝑖𝑛𝑥𝑑𝑥 𝑥 0 = ℎ 2 (y0+ y10) + 2(y1+y2+ y3+ y4 + y5+ y6+y7+ y8+ y9) h = 𝜋 10 ∫ 𝑠𝑖𝑛𝑥𝑑𝑥 𝑥 0 = 𝜋 20 (0+0) + 2(0.3090+0.5878+0.8090+0.9511+1+0.3090+0.5878+0.8090+0.9511) = 𝜋 20 2*6.3138) = 1.984 (approximately) The answer is 1.984.
  • 8. Problem 3: Using n=5, Calculate approximate the integral by trapezoidal rule. ∫ √ 5 1 (x2+1). Solution: For n = 5 we have △x = 5−1/5= 0.8 Computing the values for y0, y1,......,y5 x y = √1+x2 1 1.41 1.8 2.06 2.6 2.78 3.4 3.54 4.2 4.32 5 5.10 ∫ √ 5 1 (x2+1) dx = 0.8/2 (1.41 + 2(2.06) + 2(2.18) + 2(3.54) + 2(4.32) + (5.10)) = 12.284 The answer is 12.284. Conclusion: The above program is successfully written in python programming language for Trapezoidal formula which can calculate the approximating integrals. Reference: 1. https://en.wikipedia.org/wiki/Trapezoidal_rule 2. https://stackoverflow.com