SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

Interpolation with unequal interval
Interpolation with unequal intervalInterpolation with unequal interval
Interpolation with unequal intervalDr. Nirav Vyas
 
Interpolation In Numerical Methods.
 Interpolation In Numerical Methods. Interpolation In Numerical Methods.
Interpolation In Numerical Methods.Abu Kaisar
 
Gauss Quadrature Formula
Gauss Quadrature FormulaGauss Quadrature Formula
Gauss Quadrature FormulaMaitree Patel
 
Presentation on Numerical Integration
Presentation on Numerical IntegrationPresentation on Numerical Integration
Presentation on Numerical IntegrationTausif Shahanshah
 
Numerical integration
Numerical integrationNumerical integration
Numerical integrationSunny Chauhan
 
Integrals and its applications
Integrals  and  its applicationsIntegrals  and  its applications
Integrals and its applicationsPoojith Chowdhary
 
Vector calculus
Vector calculusVector calculus
Vector calculusraghu ram
 
Numerical Analysis and Its application to Boundary Value Problems
Numerical Analysis and Its application to Boundary Value ProblemsNumerical Analysis and Its application to Boundary Value Problems
Numerical Analysis and Its application to Boundary Value ProblemsGobinda Debnath
 
Numerical integration;Gaussian integration one point, two point and three poi...
Numerical integration;Gaussian integration one point, two point and three poi...Numerical integration;Gaussian integration one point, two point and three poi...
Numerical integration;Gaussian integration one point, two point and three poi...vaibhav tailor
 
Ordinary differential equations
Ordinary differential equationsOrdinary differential equations
Ordinary differential equationsAhmed Haider
 
Fundamentals of Finite Difference Methods
Fundamentals of Finite Difference MethodsFundamentals of Finite Difference Methods
Fundamentals of Finite Difference Methods1rj
 
Newton Forward Difference Interpolation Method
Newton Forward Difference Interpolation MethodNewton Forward Difference Interpolation Method
Newton Forward Difference Interpolation MethodAdeel Rasheed
 
Numerical Solution of Ordinary Differential Equations
Numerical Solution of Ordinary Differential EquationsNumerical Solution of Ordinary Differential Equations
Numerical Solution of Ordinary Differential EquationsMeenakshisundaram N
 
Partial differential equations
Partial differential equationsPartial differential equations
Partial differential equationsmuhammadabullah
 
1st order differential equations
1st order differential equations1st order differential equations
1st order differential equationsNisarg Amin
 

Was ist angesagt? (20)

Interpolation with unequal interval
Interpolation with unequal intervalInterpolation with unequal interval
Interpolation with unequal interval
 
Interpolation In Numerical Methods.
 Interpolation In Numerical Methods. Interpolation In Numerical Methods.
Interpolation In Numerical Methods.
 
1 d wave equation
1 d wave equation1 d wave equation
1 d wave equation
 
Gauss Quadrature Formula
Gauss Quadrature FormulaGauss Quadrature Formula
Gauss Quadrature Formula
 
Presentation on Numerical Integration
Presentation on Numerical IntegrationPresentation on Numerical Integration
Presentation on Numerical Integration
 
Numerical integration
Numerical integrationNumerical integration
Numerical integration
 
Integrals and its applications
Integrals  and  its applicationsIntegrals  and  its applications
Integrals and its applications
 
Vector calculus
Vector calculusVector calculus
Vector calculus
 
Fourier series
Fourier series Fourier series
Fourier series
 
Numerical Analysis and Its application to Boundary Value Problems
Numerical Analysis and Its application to Boundary Value ProblemsNumerical Analysis and Its application to Boundary Value Problems
Numerical Analysis and Its application to Boundary Value Problems
 
Numerical integration;Gaussian integration one point, two point and three poi...
Numerical integration;Gaussian integration one point, two point and three poi...Numerical integration;Gaussian integration one point, two point and three poi...
Numerical integration;Gaussian integration one point, two point and three poi...
 
Laplace transformation
Laplace transformationLaplace transformation
Laplace transformation
 
Ordinary differential equations
Ordinary differential equationsOrdinary differential equations
Ordinary differential equations
 
Fundamentals of Finite Difference Methods
Fundamentals of Finite Difference MethodsFundamentals of Finite Difference Methods
Fundamentals of Finite Difference Methods
 
Numerical method
Numerical methodNumerical method
Numerical method
 
Newton Forward Difference Interpolation Method
Newton Forward Difference Interpolation MethodNewton Forward Difference Interpolation Method
Newton Forward Difference Interpolation Method
 
Numerical Solution of Ordinary Differential Equations
Numerical Solution of Ordinary Differential EquationsNumerical Solution of Ordinary Differential Equations
Numerical Solution of Ordinary Differential Equations
 
Partial differential equations
Partial differential equationsPartial differential equations
Partial differential equations
 
1st order differential equations
1st order differential equations1st order differential equations
1st order differential equations
 
Stoke’s theorem
Stoke’s theoremStoke’s theorem
Stoke’s theorem
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von Mostafijur Rahman

Mehr von 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
 

Kürzlich hochgeladen

How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 

Kürzlich hochgeladen (20)

How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 

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