Numerical Integration (Quadrature) Another application for our interpolation tools!

Similar documents
Numerical Integra/on

CS 450 Numerical Analysis. Chapter 8: Numerical Integration and Differentiation

Section 6.6 Gaussian Quadrature

Integration, differentiation, and root finding. Phys 420/580 Lecture 7

Numerical integration and differentiation. Unit IV. Numerical Integration and Differentiation. Plan of attack. Numerical integration.

Numerical Integra/on

Review. Numerical Methods Lecture 22. Prof. Jinbo Bi CSE, UConn

In numerical analysis quadrature refers to the computation of definite integrals.

Ch. 03 Numerical Quadrature. Andrea Mignone Physics Department, University of Torino AA

Applied Numerical Analysis

Numerical Integration of Functions

Exact and Approximate Numbers:

TABLE OF CONTENTS INTRODUCTION, APPROXIMATION & ERRORS 1. Chapter Introduction to numerical methods 1 Multiple-choice test 7 Problem set 9

Chapter 4: Interpolation and Approximation. October 28, 2005

Differentiation and Integration

Numerical Evaluation of Integrals with weight function x k Using Gauss Legendre Quadrature Rules

Scientific Computing: Numerical Integration

Outline. 1 Numerical Integration. 2 Numerical Differentiation. 3 Richardson Extrapolation

Romberg Integration and Gaussian Quadrature

MA1023-Methods of Mathematics-15S2 Tutorial 1

Numerical Methods for Engineers. and Scientists. Applications using MATLAB. An Introduction with. Vish- Subramaniam. Third Edition. Amos Gilat.

One Solution Two Solutions Three Solutions Four Solutions. Since both equations equal y we can set them equal Combine like terms Factor Solve for x

MA2501 Numerical Methods Spring 2015

8.4 Integration of Rational Functions by Partial Fractions Lets use the following example as motivation: Ex: Consider I = x+5

MA 114 Worksheet #01: Integration by parts

Integration. Topic: Trapezoidal Rule. Major: General Engineering. Author: Autar Kaw, Charlie Barker.

Contents. I Basic Methods 13

2D1240 Numerical Methods II / André Jaun, NADA, KTH NADA

Pascal s Triangle on a Budget. Accuracy, Precision and Efficiency in Sparse Grids

Multistage Methods I: Runge-Kutta Methods

Name of the Student: Unit I (Solution of Equations and Eigenvalue Problems)

Bindel, Spring 2012 Intro to Scientific Computing (CS 3220) Week 12: Monday, Apr 16. f(x) dx,

Jim Lambers MAT 460/560 Fall Semester Practice Final Exam

Math 107H Fall 2008 Course Log and Cumulative Homework List

Lecture 4.2 Finite Difference Approximation

Physics 115/242 Romberg Integration

Numerical Analysis Solution of Algebraic Equation (non-linear equation) 1- Trial and Error. 2- Fixed point

GENG2140, S2, 2012 Week 7: Curve fitting

Course. Print and use this sheet in conjunction with MathinSite s Maclaurin Series applet and worksheet.

Research Article The Approximate Solution of Fredholm Integral Equations with Oscillatory Trigonometric Kernels

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

Linear, threshold units. Linear Discriminant Functions and Support Vector Machines. Biometrics CSE 190 Lecture 11. X i : inputs W i : weights

Numerical Methods. King Saud University

A THEORETICAL INTRODUCTION TO NUMERICAL ANALYSIS

Performing well in calculus is impossible without a solid algebra foundation. Many calculus

Preface. 2 Linear Equations and Eigenvalue Problem 22

Slow Growth for Gauss Legendre Sparse Grids

you expect to encounter difficulties when trying to solve A x = b? 4. A composite quadrature rule has error associated with it in the following form

CISE-301: Numerical Methods Topic 1:

Adding and Subtracting Rational Expressions

Engg. Math. II (Unit-IV) Numerical Analysis

Example 1: What do you know about the graph of the function

Review Algebra and Functions & Equations (10 questions)

Accuracy, Precision and Efficiency in Sparse Grids

Numerical Mathematics

Extrapolation in Numerical Integration. Romberg Integration

Gregory's quadrature method

COURSE Numerical integration of functions (continuation) 3.3. The Romberg s iterative generation method

Comparison of Clenshaw-Curtis and Gauss Quadrature

The Fundamental Theorem of Calculus Part 3

Numerical Analysis. A Comprehensive Introduction. H. R. Schwarz University of Zürich Switzerland. with a contribution by

MATHEMATICAL FORMULAS AND INTEGRALS

Introduction to Uncertainty Quantification in Computational Science Handout #3

Applied Numerical Analysis (AE2220-I) R. Klees and R.P. Dwight

Limits: How to approach them?

Given the vectors u, v, w and real numbers α, β, γ. Calculate vector a, which is equal to the linear combination α u + β v + γ w.

4. Numerical Quadrature. Where analytical abilities end... continued

CHAPTER 4. Interpolation

Numerical Solution of Linear Volterra-Fredholm Integral Equations Using Lagrange Polynomials

Mathematics for Engineers. Numerical mathematics

Instructions for Matlab Routines

5 Numerical Integration & Dierentiation

Lectures 9-10: Polynomial and piecewise polynomial interpolation

Chapter 5: Numerical Integration and Differentiation

MATH 1325 Business Calculus Guided Notes

(0, 0), (1, ), (2, ), (3, ), (4, ), (5, ), (6, ).

Chebfun and numerical quadrature

MA6452 STATISTICS AND NUMERICAL METHODS UNIT IV NUMERICAL DIFFERENTIATION AND INTEGRATION

QUADRATIC EQUATIONS. + 6 = 0 This is a quadratic equation written in standard form. x x = 0 (standard form with c=0). 2 = 9

Numerical Methods I: Numerical Integration/Quadrature

Math 112 Section 10 Lecture notes, 1/7/04

Numerical Analysis & Computer Programming

Scientific Computing: An Introductory Survey

3.1: 1, 3, 5, 9, 10, 12, 14, 18

Geometric Modeling Summer Semester 2010 Mathematical Tools (1)

2.29 Numerical Fluid Mechanics Fall 2009 Lecture 13

Fixed point iteration and root finding

Quadrature for Uncertainty Analysis Stochastic Collocation. What does quadrature have to do with uncertainty?

The Definite Integral. Day 5 The Fundamental Theorem of Calculus (Evaluative Part)

Daily Lessons and Assessments for AP* Calculus AB, A Complete Course Page 584 Mark Sparks 2012

Page No.1. MTH603-Numerical Analysis_ Muhammad Ishfaq

MAT 460: Numerical Analysis I. James V. Lambers

Applied Mathematics 205. Unit 0: Overview of Scientific Computing. Lecturer: Dr. David Knezevic

(f(x) P 3 (x)) dx. (a) The Lagrange formula for the error is given by

Contents. Preface to the Third Edition (2007) Preface to the Second Edition (1992) Preface to the First Edition (1985) License and Legal Information

4.1 Classical Formulas for Equally Spaced Abscissas. 124 Chapter 4. Integration of Functions

Scientific Computing

Exam 2. Average: 85.6 Median: 87.0 Maximum: Minimum: 55.0 Standard Deviation: Numerical Methods Fall 2011 Lecture 20

MATHEMATICAL METHODS INTERPOLATION

2.29 Numerical Fluid Mechanics Spring 2015 Lecture 4

Transcription:

Numerical Integration (Quadrature) Another application for our interpolation tools!

Integration: Area under a curve Curve = data or function Integrating data Finite number of data points spacing specified Data may be noisy Must interpolate or regress a smooth between points Integrating functions Non-integrable function (usually) As many points as you need Spacing arbitrary y y a a Area Area = f ( ) d a Area b b b Today we will discuss methods that work on both of these problems Lecture 11 2

Numerical Integration: The Big Picture Virtually all numerical integration methods rely on the following procedure: Start from N+1 data points ( i,f i ), i = 0,,N, or sample a specified function f() at N+1 i values to generate the data set Fit the data set to a polynomial, either locally (piecewise) or globally Analytically integrate the polynomial to deduce an integration formula of the general form: w i are the weights i are the abscissas, points, or nodes Numerical integration schemes are further categorized as either: Closed the i data points include the end points a and b of the interval Open the i data points are interior to the interval Lecture 11 3

Further classification of numerical integration schemes Newton-Cotes Formulas Use equally spaced abscissas Fit data to local order N polynomial approimants Eamples: Trapezoidal rule, N=1 Simpson s 1/3 rule, N=2 Errors are algebraic in the spacing h between points Clenshaw-Curtis Quadrature Uses the Chebyshev abscissas Fit data to global order N polynomial approimants Errors can be spectral, ~ep(-n) ~ ep (-1/h), for smooth functions Gaussian Quadrature Unequally spaced abscissas determined optimally Fit data to global order N polynomial approimants Errors can be spectral, and smaller than Clenshaw-Curtis Lecture 11 4

Trapezoid rule: 1 interval, 2 points Approimate the function by a linear interpolant between the two end points, then integrate that degree-1 polynomial f () f () f( a) 1 ( ) ( ) 2 f a f b a b a b f() b Area = f ( ) d a b Area = 1 ( ) ( ) ( ) 2 f a f b b a average height Lecture 11 5

Trapezoid rule: 2 intervals, 3 points We should be able to improve accuracy by increasing the number of intervals: this leads to composite integration formulas f () f () a b 0 1 2 Area = f ( ) d a b h h Area = 2 2 h f ( 0) 2 f ( 1) f ( 2) 2 f ( ) f ( ) f ( ) f ( ) 0 1 1 2 Lecture 11 6

Composite Trapezoid rule: 8 n intervals, n +1 points f () N=1 linear interpolation within each interval: more intervals to improve accuracy f () a b 0 1 2 3 4 5 6 7 8 h h h h Area = 2 2 2 2 h f ( 0) 2 f ( 1) 2 f ( 2) 2 f ( 7) f ( 8) 2 f ( ) f ( ) f ( ) f ( ) f ( ) f ( ) f ( ) f ( ) 0 1 1 2 1 2 7 8 7 n 1 h h b a f ( 0) 2 f ( i ) f ( 8) f ( 0) 2 f ( i) f ( n) ; h n 2 i 1 2 i 1 n Lecture 11 7

Composite Trapezoidal Rule Notice that this composite formula can be written in the generic form: where the weights are given by The truncation error of the composite trapezoidal rule is of order Error per interval times number of intervals Lecture 11 8

Simpson s 1/3 rule Basic idea: interpolate between 3 points using a parabola (N=2 polynomial) rather than a straight line (as in trapezoid rule) f () f () Simpson trapezoid f () f () red parabola blue parabola Lecture 11 9

Simpson s 1/3 rule: derivation f () p ( ) Interpolation: find equation for a parabola (N=2 polynomial) passing through 3 points 0 1 2 p() is a parabola (quadratic in ) p() goes through 3 desired points Use Lagrange form for convenience: 0 at 0 at f ( ) at 1 2 0 0 0 at 0 at f ( ) at 1 1 0 2 0 at 0 at f ( ) at 0 1 2 2 Lecture 11 10

Simpson s 1/3 rule: derivation for 2 intervals, 3 points f () p ( ) Area 0 2 p( ) d Remember from calculus: 0 1 2 Area h 1 p( ) d f ( ) 4 f ( ) f ( ) ; E f ( ) h 3 90 2 0 1 2 t 0 (4) 5 h 2 1 1 0 Lecture 11 11

Composite Simpson s 1/3 rule: (n intervals, n+1 points, n even) The formula is thus: The error is: compare with trapezoidal rule Lecture 11 12

Closed Newton-Cotes Formulas We have just derived the first two closed Newton-Cotes formulas for equally spaced points that include the end points of the interval [a,b] Basic truncation errors Trapezoidal (1 interval, 2 points): O(h 3 ) Simpson s 1/3 (2 intervals, 3 points): O(h 5 ) Composite formula truncation errors (n intervals, n+1 points) Trapezoidal ( first-order accurate ): O(h 2 (b-a)) = O(1/n 2 ) Simpson s 1/3 ( third-order accurate ): O(h 4 (b-a)) = O(1/n 4 ) Higher order formulas can evidently be developed by using local polynomials with N>2 to interpolate with a larger number of points It is also easy to adapt these formulas to composite formulas with unequally spaced intervals, h 1 h 2 h 3 if the data is unevenly spaced Lecture 11 13

Eample: Simpson s 1/3 Rule Let s try out the composite Simpson s 1/3 rule on the integral: Eact result is 2[sin(1)-cos(1)] =0.602337 See SimpsonL11.m n error Errors consistent with ~1/n 4 scaling 4 2.20 10-3 8 1.35 10-4 16 8.34 10-6 Lecture 11 14

Open Newton-Cotes formulas Same idea as closed formulas, but end points 0 = a, n = b are not included These are useful if Data is not supplied at the edges of the interval [a,b] The integrand has a singularity at the edges (see later) A simple and useful eample the composite midpoint rule: where 1/2 is located at the midpoint between 0 and 1, etc. Same accuracy as composite TR Lecture 11 15

Options for higher accuracy If we want highly accurate results for an integral, we have various options: Use more points n in Simpson s rule (since error ~ 1/n 4 ) computationally costly Derive a higher-order Newton-Cotes formula that fits more points to a polynomial with N>2 analytically cumbersome for small gains Use repeated Richardson etrapolation to develop higher order approimations Romberg integration Switch to a method based on global approimants: Clenshaw-Curtis Quadrature Gauss Quadrature Lecture 11 16

Clenshaw-Curtis Quadrature Clenshaw-Curtis quadrature is based on integrating a global Chebyshev polynomial interpolant through all N+1 points The abscissas are fied at the Chebyshev points: If we integrate p(): Finally, the weights are obtained by substituting the solution of the collocation equations [T] {c} = {f} into this epression for the c i values The M-file clencurt.m from L.N. Trefethen, Spectral Methods in MatLab (SIAM, 2000) encapsulates these weight calculations Lecture 11 17

Eample: Clenshaw-Curtis See ClenCurtL11.m Compares the error vs. N for integrals of 4 functions: Spectral accuracy for the two smooth functions: Error below machine precision for N > 10! c.f. Simpson s rule error of 10-5 at N=16 Lecture 11 18

Gauss Quadrature: Global like Clenshaw-Curtis, but also optimally choose abscissas 2 point case: -1 0 1-1 0 1 I 1 1 f ( ) d 1 2 poor approimation much better approimation obtained by adjusting 1 & 2 values and w 1 and w 2 values Lecture 11 19

Finding optimal choice of parameters Note that there are 4 unknowns to be determined. Gauss procedure: we choose the 4 unknowns so that the integral gives an eact answer whenever f () is a polynomial of order 3 or less -1 0 1 1 2 it would have to give the eact answer for the following four cases: f f f f 2 3 ( ) 1, ( ), ( ), ( ). Lecture 11 20

Determining the unknowns: Gauss- Legendre Quadrature (N=2 case) More generally, for an N point formula, the abscissas are the N roots of the Legendre Polynomial P N (). The weights can be obtained by solving a linear system with a tridiagonal matri. Notice that Gauss-Legendre is an open formula, unlike Clenshaw-Curtis Lecture 11 21

Eample: Gauss-Legendre See gauss.m (for abscissas and weights) and GaussL11.m Compares the error vs. N for integrals of same 4 functions: Spectral accuracy for the two smooth functions: Error below machine precision for N > 6! Faster convergence than even Clenshaw- Curtis for smooth functions c.f. Simpson s rule error of 10-5 at N=16 Gauss eactly integrates a polynomial of degree 2N-1! Lecture 11 22

Adjusting the limits of integration The spectral accuracy of the Gauss-Legendre and Clenshaw-Curtis methods can be traced to the fact that they employ global polynomial interpolation and cluster their abscissas at the edges of the interval Remember that the Clenshaw-Curtis and Gauss-Legendre formulas apply only for integrals with limits of -1 and +1! The limits need to be rescaled for other integrals: Lecture 11 23

Integrals with Singularities Occasionally you will encounter integrals with weak (integrable) singularities, e.g. In this case there is an inverse square root singularity at the endpoint =0. We obviously cannot apply a closed integration formula in this case! Alternatives are: Apply an open formula, like composite midpoint rule or Gauss-Legendre quadrature Use an open formula that eplicitly includes the -1/2 factor (better option) Rescale variable as = t 2, so the singularity is removed (best option, if available): Lecture 11 24

Indefinite (improper) integrals Often you will encounter integrals with infinite limits, e.g. There are several alternatives: Apply a Newton-Cotes formula to a similar integral, but with 1 replaced with a large number R Rescale variable as = - ln t, (assuming resulting integral not singular): A better approach is to use a Gaussian quadrature formula appropriate for the interval [0,1), such as the Gauss-Laguerre formula: Don t forget to factor the ep(-) out of your function! Lecture 11 25