DOING PHYSICS WITH MATLAB MATHEMATICAL ROUTINES

Similar documents
NUMERICAL INTEGRATION. The inverse process to differentiation in calculus is integration. Mathematically, integration is represented by.

Numerical Integration

Numerical Analysis: Trapezoidal and Simpson s Rule

Z b. f(x)dx. Yet in the above two cases we know what f(x) is. Sometimes, engineers want to calculate an area by computing I, but...

Section 6.1 Definite Integral

Lecture 6: Singular Integrals, Open Quadrature rules, and Gauss Quadrature

NUMERICAL INTEGRATION

Suppose we want to find the area under the parabola and above the x axis, between the lines x = 2 and x = -2.

3.4 Numerical integration

Lecture 14: Quadrature

Definite integral. Mathematics FRDIS MENDELU

Definite integral. Mathematics FRDIS MENDELU. Simona Fišnarová (Mendel University) Definite integral MENDELU 1 / 30

APPROXIMATE INTEGRATION

The Riemann Integral

III. Lecture on Numerical Integration. File faclib/dattab/lecture-notes/numerical-inter03.tex /by EC, 3/14/2008 at 15:11, version 9

Lecture 23: Interpolatory Quadrature

Review of Calculus, cont d

COT4501 Spring Homework VII

1 The Riemann Integral

Lecture 17. Integration: Gauss Quadrature. David Semeraro. University of Illinois at Urbana-Champaign. March 20, 2014

Properties of Integrals, Indefinite Integrals. Goals: Definition of the Definite Integral Integral Calculations using Antiderivatives

Construction of Gauss Quadrature Rules

Lecture 12: Numerical Quadrature

INTRODUCTION TO INTEGRATION

B.Sc. in Mathematics (Ordinary)

Undergraduate Research

Math& 152 Section Integration by Parts

Numerical Analysis. 10th ed. R L Burden, J D Faires, and A M Burden

Chapter 5. Numerical Integration

Goals: Determine how to calculate the area described by a function. Define the definite integral. Explore the relationship between the definite

Midpoint Approximation

CMDA 4604: Intermediate Topics in Mathematical Modeling Lecture 19: Interpolation and Quadrature

Sections 5.2: The Definite Integral

Exam 2, Mathematics 4701, Section ETY6 6:05 pm 7:40 pm, March 31, 2016, IH-1105 Instructor: Attila Máté 1

Numerical Integration. 1 Introduction. 2 Midpoint Rule, Trapezoid Rule, Simpson Rule. AMSC/CMSC 460/466 T. von Petersdorff 1

Section 7.1 Integration by Substitution

Lecture 20: Numerical Integration III

Chapter 7 Notes, Stewart 8e. 7.1 Integration by Parts Trigonometric Integrals Evaluating sin m x cos n (x) dx...

Math 1B, lecture 4: Error bounds for numerical methods

6.5 Numerical Approximations of Definite Integrals

The Fundamental Theorem of Calculus

Numerical Integration

Unit #9 : Definite Integral Properties; Fundamental Theorem of Calculus

The Fundamental Theorem of Calculus. The Total Change Theorem and the Area Under a Curve.

1 Error Analysis of Simple Rules for Numerical Integration

P 3 (x) = f(0) + f (0)x + f (0) 2. x 2 + f (0) . In the problem set, you are asked to show, in general, the n th order term is a n = f (n) (0)

Chapter 6 Notes, Larson/Hostetler 3e

LECTURE 19. Numerical Integration. Z b. is generally thought of as representing the area under the graph of fèxè between the points x = a and

Definite Integrals. The area under a curve can be approximated by adding up the areas of rectangles = 1 1 +

1 The Lagrange interpolation formula

Math 131. Numerical Integration Larson Section 4.6

Orthogonal Polynomials

x = b a n x 2 e x dx. cdx = c(b a), where c is any constant. a b

Best Approximation. Chapter The General Case

n f(x i ) x. i=1 In section 4.2, we defined the definite integral of f from x = a to x = b as n f(x i ) x; f(x) dx = lim i=1

OPEN NEWTON - COTES QUADRATURE WITH MIDPOINT DERIVATIVE FOR INTEGRATION OF ALGEBRAIC FUNCTIONS

Theoretical foundations of Gaussian quadrature

Arithmetic Mean Derivative Based Midpoint Rule

Chapter 2. Numerical Integration also called quadrature. 2.2 Trapezoidal Rule. 2.1 A basic principle Extending the Trapezoidal Rule DRAWINGS

We know that if f is a continuous nonnegative function on the interval [a, b], then b

Lecture 14 Numerical integration: advanced topics

Numerical integration

COSC 3361 Numerical Analysis I Numerical Integration and Differentiation (III) - Gauss Quadrature and Adaptive Quadrature

5.1 How do we Measure Distance Traveled given Velocity? Student Notes

Numerical integration. Quentin Louveaux (ULiège - Institut Montefiore) Numerical analysis / 10

Advanced Calculus: MATH 410 Notes on Integrals and Integrability Professor David Levermore 17 October 2004

5.7 Improper Integrals

Lab 11 Approximate Integration

7. Numerical evaluation of definite integrals

5: The Definite Integral

THE HANKEL MATRIX METHOD FOR GAUSSIAN QUADRATURE IN 1 AND 2 DIMENSIONS

MA 124 January 18, Derivatives are. Integrals are.

cos 3 (x) sin(x) dx 3y + 4 dy Math 1206 Calculus Sec. 5.6: Substitution and Area Between Curves

Tangent Line and Tangent Plane Approximations of Definite Integral

Numerical Integration. Newton Cotes Formulas. Quadrature. Newton Cotes Formulas. To approximate the integral b

JDEP 384H: Numerical Methods in Business

1 Part II: Numerical Integration

Discrete Least-squares Approximations

AN INTEGRAL INEQUALITY FOR CONVEX FUNCTIONS AND APPLICATIONS IN NUMERICAL INTEGRATION

Harmonic Mean Derivative - Based Closed Newton Cotes Quadrature

Lecture 19: Continuous Least Squares Approximation

Week 10: Riemann integral and its properties

Abstract inner product spaces

APPLICATIONS OF THE DEFINITE INTEGRAL

Numerical Integration

Section 5.4 Fundamental Theorem of Calculus 2 Lectures. Dr. Abdulla Eid. College of Science. MATHS 101: Calculus 1

Lecture Note 4: Numerical differentiation and integration. Xiaoqun Zhang Shanghai Jiao Tong University

QUADRATURE is an old-fashioned word that refers to

The Regulated and Riemann Integrals

Advanced Computational Fluid Dynamics AA215A Lecture 3 Polynomial Interpolation: Numerical Differentiation and Integration.

Trapezoidal Rule, n = 1, x 0 = a, x 1 = b, h = b a. f (x)dx = h 2 (f (x 0) + f (x 1 )) h3

Integration Techniques

Physics 116C Solution of inhomogeneous ordinary differential equations using Green s functions

Anti-derivatives/Indefinite Integrals of Basic Functions

Numerical Methods I Orthogonal Polynomials

The final exam will take place on Friday May 11th from 8am 11am in Evans room 60.

Review of Riemann Integral

Chapter 3 Solving Nonlinear Equations

Riemann Sums and Riemann Integrals

38 Riemann sums and existence of the definite integral.

Transcription:

DOIG PHYSICS WITH MATLAB MATHEMATICAL ROUTIES COMPUTATIO OF OE-DIMESIOAL ITEGRALS In Cooper School of Physics, University of Sydney in.cooper@sydney.edu.u DOWLOAD DIRECTORY FOR MATLAB SCRIPTS mth_integrtion_1d.m Demonstrtion mscript evluting the integrl of two functions using number of different methods simpson1d.m Function to give the integrl of function using Simpson s 1/3 rule. UMERICAL ITEGRATIO COMPUTATIO OF OE-DIMESIOAL ITEGRALS The function simpson1d.m is very verstile, ccurte nd esy to implement function tht cn be used to evlute definite integrl of function between lower bound nd n upper bound. It is esier to use thn the stndrd Mtlb integrtion functions such s qud. The function simpson1d.m is described in detil below. We wnt to compute number expressing the definite integrl of the function f(x) between two specific limits nd b b I f ( x)dx The evlution of such integrls is often clled qudrture. Doing Physics with Mtlb 1

We will consider the following integrnds to test the ccurcy of different integrtion procedures: (1) f ( x) cos( x) (2) ( ) e jx f x The integrls re evluted over qurter cycle in n ttempt to find minimum number of prtitions of the domin tht produce ccurte results within resonble time. For the testing procedures, the following integrls re to be evluted from = to b = /2 /2 I cos( x)dx nd /2 jx I e dx These integrls cn be evluted nlyticlly nd the exct nswers re /2 /2 I cos( x)dx sin( x) sin( / 2) sin() 1 /2 /2 jx 1 jx 1 j /2 j j I e dx e e 1 1 j The numericl procedures ssume tht neither the integrnd f(x) nor ny of its derivtives become infinite t ny point over the domin of the integrtion [, b], nd tht the limits of integrtion nd b re finite. Furthermore, we ssume tht f(x) cn be computed, or its vlues re known t points x c where c = 1, 2,, tht re distributed in some mnner over the domin [, b] with x 1 = nd x = b. The qulifier closed signifies tht the integrtion involves the vlues of the integrnd t both the end-points. If only one or none of the end points re included, the qulifiers used re semi-closed nd open respectively. A mjor problem tht rises with non-dptive methods is tht the number of prtitions of the function required to provide given ccurcy is initilly unknown. One pproch to this problem is to successively double the number of prtitions, nd compre the results s the number of prtitions increse. Doing Physics with Mtlb 2

Closed Rectngle Rule The region from to b is divided into rectngles of equl width x h where x h b 1 with ech rectngle centre occurring t the points x 1 =, x 2 = x 1 + h, x = b. For exmple, the plot below shows the domin divided into 4 rectngles, = 4. However, the sub-division of the domin by this mens extends from - h/2 to b + h/2 nd not simply from to b. 12 1 8 6 4 2 1 2 3 4 The integrl is pproximted by the contribution from ech rectngle, such tht I f ( x ) x i1 i For the cse shown in the plot bove where = 4, the integrl is pproximted by I f ( x ) f ( x ) f ( x ) f ( x ) h where 1 2 3 4 b h. 3 Doing Physics with Mtlb 3

Open Midpoint Rule The mid-point rule is the first member of fmily of open ewton-cotes rules corresponding to qudrtic, cubic nd higher-order interpolting polynomils with evenly spced points. In the open midpoint rule, the re of ech rectngle is dded to find the integrl. The domin to b in divided into prtitions, with the width of ech prtition being h = (b )/. The function is evluted t the midpoint x i of ech rectngle where x i = + (h/2)(2-1). The vlue of the integrl is then given by b I f ( x)d x h f ( xi ) 1 Doing Physics with Mtlb 4

Trpezoidl Rule The function f(x) is pproximted by stright line segment connecting djcent points. The re under the curve is then pproximted by dding the re of ech trpezium. The intervl to b is divided into -1 prtitions of width h (h x) where h = (b )/( - 1). The re of ech prtition is simply the re of trpezium which is its bse times its men height. The re of the i th trpezium is h fi f 2 i1 where f i f(x i ) nd i = 1, 2,..-1 Summing ll the trpezi gives the composite, closed trpezoidl rule 1 f1 f f1 f I h f i h fi 2 2 1 2 For evenly distributed spcings, the composite rule is equivlent to the trpezoidl version of the closed ewton-cotes rule. The Mtlb function, trpz implements procedure to clculte the integrl by the trpezoidl rule. For exmple, the integrtion of the function y 1 w.r.t the vrible x Integrl_1 = trpz(x,y1) % estimte of the integrl Doing Physics with Mtlb 5

Simpson s 1/3 rule This rule is bsed on using qudrtic polynomil pproximtion to the function f(x) over pir of prtitions. -1 is the number of prtitions where must be odd nd h = (b ) / (-1). The integrl is expressed below nd is known s composite Simpson s 1/3 rule. h I f1 f 4( f2 f4... f2 2( f3 f5... f1) 3 Simpson s rule cn be written vector form s h I cf 3 T where f f f c f. 14 2 4... 2 41 nd 1 2... Simpson s rule is n exmple of closed ewton s-cotes formul for integrtion. Other exmples cn be obtined by fitting higher degree polynomils through the pproprite number of points. In generl we fit polynomil of degree through +1 points. The resulting polynomils cn them be integrted to provide n integrtion formul. Becuse of the lurking oscilltions ssocited with the Gibbs effect, higher-order formuls re not used for prcticl integrtion. simpson1d.m The function f nd the lower bound nd the upper bound b re pssed onto the function (in the order f,, b) nd the function returns the vlue of the integrl function integrl = simpson1d(f,,b) % [1D] integrtion - Simpson's 1/3 rule % f function = lower bound b = upper bound % Must hve odd number of dt points % Simpson's coefficients 1 4 2 4... 2 4 1 nums = length(f); % number of dt points sc = 2*ones(numS,1); sc(2:2:nums-1) = 4; sc(1) = 1; sc(nums) = 1; h = (b-)/(nums-1); integrl = (h/3) * f * sc; Doing Physics with Mtlb 6

EXAMPLES (1) /2 I cos( x)dx 1 (2) /2 I e dx 1 j jx Method Estimte Closed Rectngle (1) 1.5 (2) 1.5 + 1.5i (1) 1.8 (2) 1.8 + 1.8i Open-Midpoint (1).78 (2).78 +.78i (1).68 (2).733 +.733i Trpezoidl (1) 1. (2) 1. + 1.i (1) 1. (2) 1. + 1.i Simpson s 1/3 (1) 1. (2) 1. + 1.i All the integrtions took less thn one second on fst Windows computer. Even with only points, the Simpson s 1/3 rule estimte ws equl to the exct vlues. Doing Physics with Mtlb 7