2 views

Uploaded by మత్సా చంద్ర శేఖర్

matlab

- SAMPLE-introductory-mathematical-analysis.pdf
- Calculus I - MATH 021 Z1 - Course Syllabus
- Engg Maths- Linear Algebra Calculus Probability How to Tackle Only for Ga
- (Advances in Quantum Chemistry Volume 2) Per-Olov Löwdin (Eds.)- Academic Press (1966).pdf
- Biology Major Courses
- Nus Module 2014-2015 Sem 2 (Updated)
- UW CFRM 460 Syllabus
- Tallygyu
- Continuum Mechanics and Continuist Metaphysics
- GATE syllabus for EE
- MATHS
- Indefinite Integration - Quadratic Denominator (SQ) - Questions.docx
- Second Semester
- AA-Abstract Algebra - Dummit and Foote (1)
- ANALYSIS of Cauchy Integral Theorem
- Csc609 Real-time-systems Th 1.10 Ac26
- igcarISOPARAMETRIC.ppt
- Existence the Solution for Fractional order Nonlinear Functional Integro-Differential Equation in Banach Space
- 1 Eutiquio C Young Partial Differential Equations an Introduction Allyn and Bacon 1972
- SMTH101

You are on page 1of 7

MATHEMATICAL ROUTINES

COMPUTATION OF ONE-DIMENSIONAL

INTEGRALS

Ian Cooper

School of Physics, University of Sydney

ian.cooper@sydney.edu.au

math_integration_1D.m

Demonstration mscript evaluating the integral of two functions using a number of

different methods

simpson1d.m

Function to give the integral of a function using Simpsons 1/3 rule.

NUMERICAL INTEGRATION

COMPUTATION OF ONE-DIMENSIONAL INTEGRALS

The function simpson1d.m is a very versatile , accurate and easy to implement

function that can be used to evaluate a definite integral of a function between a lower

bound and an upper bound. It is easier to use than the standard Matlab integration

functions such as quad. The function simpson1d.m is described in detail below.

We want to compute a number expressing the definite integral of the function f(x)

between two specific limits a and b

b

I f ( x) dx

a

We will consider the following integrands to test the accuracy of different integration

procedures:

(1)

f ( x) cos( x)

(2)

f ( x) e j x

The integrals are evaluated over a quarter cycle in an attempt to find a minimum

number of partitions of the domain that produce accurate results within a reasonable

time. For the testing procedures, the following integrals are to be evaluated from

a = 0 to b = /2

/2

cos( x) dx

and

/2

e jx dx

These integrals can be evaluated analytically and the exact answers are

/2

/ 2 jx

1

e dx e jx

j

/2

1 j / 2

e

1 1 j

j

The numerical procedures assume that neither the integrand f(x) nor any of its

derivatives become infinite at any point over the domain of the integration [a, b], and

that the limits of integration a and b are finite. Furthermore, we assume that f(x) can

be computed, or its values are known at N points xc where c = 1, 2, , N that are

distributed in some manner over the domain [a, b] with x1 = a and xN = b.

The qualifier closed signifies that the integration involves the values of the integrand

at both the end-points. If only one or none of the end points are included, the

qualifiers used are semi-closed and open respectively.

A major problem that arises with non-adaptive methods is that the number N of

partitions of the function required to provide a given accuracy is initially unknown.

One approach to this problem is to successively double the number of partitions, and

compare the results as the number of partitions increase.

The region from a to b is divided into N rectangles of equal width x h where

x h

ba

N 1

For example, the plot below shows the domain divided into 4 rectangles, N = 4.

However, the sub-division of the domain by this means extends from

a - h/2 to b + h/2 and not simply from a to b.

120

100

80

60

40

20

0

1

The integral is approximated by the contribution from each rectangle, such that

N

I f ( xi ) x

i 1

For the case shown in the plot above where N = 4, the integral is approximated by

I f ( x1) f ( x2 ) f ( x3 ) f ( x4 ) h where h

ba

.

3

The mid-point rule is the first member of a family of open Newton-Cotes rules

corresponding to quadratic, cubic and higher-order interpolating polynomials with

evenly spaced points. In the open midpoint rule, the area of each rectangle is added to

find the integral. The domain a to b in divided into N partitions, with the width of

each partition being h = (b a)/N. The function is evaluated at the midpoint xi of each

rectangle where xi = a + (h/2)(2N-1). The value of the integral is then given by

N

I f ( x ) dx h f ( xi )

b

Trapezoidal Rule

The function f(x) is approximated by a straight line segment connecting adjacent

points. The area under the curve is then approximated by adding the area of each

trapezium. The interval a to b is divided into N-1 partitions of width h (h x) where

h = (b a)/(N - 1). The area of each partition is simply the area of a trapezium which

is its base times its mean height. The area of the ith trapezium is

f fi 1

h i

Summing all the trapezia gives the composite, closed trapezoidal rule

f1 f N N 1

N

f f

I h

fi h fi 1 N

2

2

2

For evenly distributed spacings, the composite rule is equivalent to the trapezoidal

version of the closed Newton-cotes rule.

The Matlab function, trapz implements a procedure to calculate the integral by the

trapezoidal rule. For example, the integration of the function y1 w.r.t the variable x

Integral_1 = trapz(x,y1)

This rule is based on using a quadratic polynomial approximation to the function f(x)

over a pair of partitions. N-1 is the number of partitions where N must be odd and

h = (b a) / (N-1). The integral is expressed below and is known as composite

Simpsons 1/3 rule.

h

f1 f N 4( f2 f4 ... f N 2 2( f3 f5 ... f N 1)

3

Simpsons rule can be written vector form as

I

h

I cf T

3

where c 1 4 2 4 ... 2 41 and f f1 f 2 ... f N .

Simpsons rule is an example of a closed Newtons-Cotes formula for integration.

Other examples can be obtained by fitting higher degree polynomials through the

appropriate number of points. In general we fit a polynomial of degree N through

N +1 points. The resulting polynomials can them be integrated to provide an

integration formula. Because of the lurking oscillations associated with the Gibbs

effect, higher-order formulas are not used for practical integration.

simpson1d.m

The function f and the lower bound a and the upper bound b are passed onto the

function (in the order f, a, b) and the function returns the value of the integral

function integral = simpson1d(f,a,b)

% [1D] integration - Simpson's 1/3 rule

%

f function

a = lower bound

b = upper bound

%

Must have odd number of data points

%

Simpson's coefficients

1 4 2 4 ... 2 4 1

numS = length(f);

sc = 2*ones(numS,1);

sc(2:2:numS-1) = 4;

sc(1) = 1; sc(numS) = 1;

h = (b-a)/(numS-1);

integral = (h/3) * f * sc;

EXAMPLES

(1) I

/2

(2) I

cos( x ) dx 1

Method

Closed Rectangle

Open-Midpoint

Trapezoidal

Simpsons 1/3

/2

(1)

(2)

(1)

(2)

(1)

(2)

(1)

(2)

(1)

(2)

(1)

(2)

(1)

(2)

e jx dx 1 j

Estimate

1.0950

1.0950 + 1.0950i

1.0080

1.0080 + 1.0080i

0.9978

0.9978 + 0.9978i

0.9968

0.9733 + 0.9733i

1.0000

1.0000 + 1.0000i

1.0000

1.0000 + 1.0000i

1.0000

1.0000 + 1.0000i

N

9

99

9

99

9

99

9

All the integrations took less than one second on a fast Windows computer. Even with

only 9 points, the Simpsons 1/3 rule estimate was equal to the exact values.

- SAMPLE-introductory-mathematical-analysis.pdfUploaded byLalani Wije
- Calculus I - MATH 021 Z1 - Course SyllabusUploaded byContinuing Education at the University of Vermont
- Engg Maths- Linear Algebra Calculus Probability How to Tackle Only for GaUploaded bySumanth_Yedoti
- (Advances in Quantum Chemistry Volume 2) Per-Olov Löwdin (Eds.)- Academic Press (1966).pdfUploaded byandres alfraro cerazo
- Biology Major CoursesUploaded byJulia S
- Nus Module 2014-2015 Sem 2 (Updated)Uploaded byAng Song Gee
- UW CFRM 460 SyllabusUploaded bypoweee
- TallygyuUploaded byRifat Saied
- Continuum Mechanics and Continuist MetaphysicsUploaded byVal Dusek
- GATE syllabus for EEUploaded byauromaaroot
- MATHSUploaded bySaptarshiDutta
- Indefinite Integration - Quadratic Denominator (SQ) - Questions.docxUploaded byLee Chu Keong
- Second SemesterUploaded byrampriya091109
- AA-Abstract Algebra - Dummit and Foote (1)Uploaded byluishipp
- ANALYSIS of Cauchy Integral TheoremUploaded bytarun gehlot
- Csc609 Real-time-systems Th 1.10 Ac26Uploaded bynetgalaxy2010
- igcarISOPARAMETRIC.pptUploaded byIrfan Ahmed Imtiaz
- Existence the Solution for Fractional order Nonlinear Functional Integro-Differential Equation in Banach SpaceUploaded byAnonymous 7VPPkWS8O
- 1 Eutiquio C Young Partial Differential Equations an Introduction Allyn and Bacon 1972Uploaded byJefferson
- SMTH101Uploaded byNitin Jamwal
- XII Math Ch8 Application of Integrals Chapter Notes NovUploaded bySrividya Kondagunta
- CU Syllabus.docxUploaded byShivam Lakhwara
- m425-hw5sols-16aUploaded byOscar Martinez Nuñez
- 2-sem-eeeUploaded byrajkumaresan
- JEE (Main & Advanced) Score Syllabus & Test ScheduleUploaded byPuneetKumarRajput
- Tutorial 9 SolutionUploaded byCK
- NumMeth_Papers4Uploaded byValerio Taddei
- Cse Syllabus First YearUploaded by1balamanian
- Complex Solved Exam 1Uploaded byAbdurrahman Karamancıoğlu
- PID Control ImplementationUploaded byindustronica

- Adsorption Isotherms and Surface Geometry 2001 Fluid Phase EquilibriaUploaded byమత్సా చంద్ర శేఖర్
- Coherence (Physics) - WikipediaUploaded byమత్సా చంద్ర శేఖర్
- 1401.6814.pdfUploaded byమత్సా చంద్ర శేఖర్
- Adsorption of He Gas on the Agn Nanoclusters a Molecular Dynamic Study 2014 Fluid Phase EquilibriaUploaded byమత్సా చంద్ర శేఖర్
- OptUploaded bytictac4136063
- 09 Chapter 2Uploaded byమత్సా చంద్ర శేఖర్
- SSP_Hilke.pdfUploaded byTùng Danh Nguyễn
- Reciprocal Lattice Fcc Bcc ScUploaded bynikhiltembhare_60052
- Eur_J_Inorg_Chem_2010_1717Uploaded byమత్సా చంద్ర శేఖర్
- TorUploaded byమత్సా చంద్ర శేఖర్
- math_qeUploaded byమత్సా చంద్ర శేఖర్
- a1Uploaded byమత్సా చంద్ర శేఖర్
- Std11 Phys EM 1Uploaded bydaamdoom
- Articles of chandra sekhar.docxUploaded byమత్సా చంద్ర శేఖర్
- Kim 2013Uploaded byమత్సా చంద్ర శేఖర్
- Ch 3 MatricesUploaded byAnshuman Singh
- jfigsdgjdthjUploaded byDanilo Pedrelli
- Byron F.W., Fuller R.W. - Mathematics of Classical and Quantum Physics.pdfUploaded byAilbhe Tia'dyn Wray
- fulltext.pdfUploaded byమత్సా చంద్ర శేఖర్
- 1 Vector CalculusUploaded byమత్సా చంద్ర శేఖర్
- Lecture on Vector calculusUploaded byspaul4u
- lykos2004Uploaded byమత్సా చంద్ర శేఖర్
- How to Best Explain Divergence and Curl - QuoraUploaded byమత్సా చంద్ర శేఖర్
- VectorsUploaded byమత్సా చంద్ర శేఖర్
- els-3pdUploaded byమత్సా చంద్ర శేఖర్
- 10.1016@j.chemphys.2016.05.028.pdfUploaded byమత్సా చంద్ర శేఖర్
- 10.1016@j.chemphys.2016.05.028.pdfUploaded byమత్సా చంద్ర శేఖర్
- els2Uploaded byమత్సా చంద్ర శేఖర్
- slv-2Uploaded byAnirban Das
- Lecture-2Uploaded byNeelam Kapoor

- Lecture Notes 4Uploaded byRafflesia Khan
- 1344620936Uploaded bynitin
- The Analysis of Stress and DeformationUploaded byAmir Hosein Salmanpour
- Section 7 OpenerUploaded byKnoll711
- ME 2220_SP15_LEC04 - Position AnalysisUploaded byJose Omar Perez
- Radiation From a Charge Uniformly Accelerated for All TimeUploaded byJohn Bird
- Pipe BranchUploaded byDimitra Meidina
- Extended Elastic Impedance-theory(1).docxUploaded bykodogsakti
- Transverse Vibrations of BeamsUploaded byopnbk
- 1 Baire's Theorem and Its ApplicationsUploaded byJosephPm
- Errata Prayaas MathematicsUploaded byTathagat Thapliyal
- To downloadUploaded byBachBread
- 62426_02Uploaded byLincs lincoln
- Home Work SolutionsUploaded bysamiseech
- Math Concepts Reference GuideUploaded bysshoeburrahman
- Liang Kong and Ingo Runkel- Morita classes of algebras in modular tensor categoriesUploaded byjsdmf223
- 166462067-Solutions-to-Fossen-Structural-Geology.pdfUploaded byRyanYu
- Delaunay Mesh GenerationUploaded byYeonsik Choi
- 6.Polynomials.docUploaded byhaironi
- lee_0119Uploaded byLaily Fauziah
- What Do Engineers and Architects Need to Know About FEMUploaded byvp989
- Math 2015 1516 OutlineUploaded byed
- Trigonometry made EasyUploaded byMihir Sethi
- CHE485_Solutions7_2013Uploaded byHind Abu Ghazleh
- Basics of FemUploaded byPrabakaran Balasubramaniam
- Inverse Algorithm for Optical Processing of Composite MaterialsUploaded byJinsoo Kim
- Users Stable 5.4Uploaded bySandro Ilegor
- Applied Stochastic ProcessesUploaded bySumanth Reddy
- Laplace_Table.pdfUploaded byKim Lloyd A. Barrientos
- 2.Classical Mechanics_GATE 2010 - 2013Uploaded byAbhishek Upadhyay