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

Similar documents
Lecture 14: Quadrature

Numerical Integration

The Regulated and Riemann Integrals

Numerical Analysis: Trapezoidal and Simpson s Rule

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

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

Review of Calculus, cont d

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

Lecture 20: Numerical Integration III

Numerical integration

38 Riemann sums and existence of the definite integral.

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

1. Gauss-Jacobi quadrature and Legendre polynomials. p(t)w(t)dt, p {p(x 0 ),...p(x n )} p(t)w(t)dt = w k p(x k ),

Lecture 14 Numerical integration: advanced topics

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

3.4 Numerical integration

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

Best Approximation. Chapter The General Case

The Riemann Integral

NUMERICAL INTEGRATION

Section 6.1 Definite Integral

Math& 152 Section Integration by Parts

1 The Lagrange interpolation formula

COT4501 Spring Homework VII

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

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

Lecture 23: Interpolatory Quadrature

Theoretical foundations of Gaussian quadrature

Lecture 19: Continuous Least Squares Approximation

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

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

Lecture 12: Numerical Quadrature

Math 8 Winter 2015 Applications of Integration

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

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

Sections 5.2: The Definite Integral

Orthogonal Polynomials

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...

Construction of Gauss Quadrature Rules

Numerical Integration

ACCESS TO SCIENCE, ENGINEERING AND AGRICULTURE: MATHEMATICS 1 MATH00030 SEMESTER /2019

A REVIEW OF CALCULUS CONCEPTS FOR JDEP 384H. Thomas Shores Department of Mathematics University of Nebraska Spring 2007

Chapter 3 Solving Nonlinear Equations

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

DOING PHYSICS WITH MATLAB MATHEMATICAL ROUTINES

Numerical Integration

6.5 Numerical Approximations of Definite Integrals

1 The fundamental theorems of calculus.

1 The Riemann Integral

Riemann is the Mann! (But Lebesgue may besgue to differ.)

Interpreting Integrals and the Fundamental Theorem

Main topics for the First Midterm

7.2 Riemann Integrable Functions

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

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

Orthogonal Polynomials and Least-Squares Approximations to Functions

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

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

Review of basic calculus

APPROXIMATE INTEGRATION

63. Representation of functions as power series Consider a power series. ( 1) n x 2n for all 1 < x < 1

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)

Integration Techniques

Chapter 0. What is the Lebesgue integral about?

Definite integral. Mathematics FRDIS MENDELU

Chapter 5. Numerical Integration

Chapter 6 Notes, Larson/Hostetler 3e

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

Discrete Least-squares Approximations

INTRODUCTION TO INTEGRATION

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

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

W. We shall do so one by one, starting with I 1, and we shall do it greedily, trying

Abstract inner product spaces

Matrices, Moments and Quadrature, cont d

Anti-derivatives/Indefinite Integrals of Basic Functions

Numerical quadrature based on interpolating functions: A MATLAB implementation

4.4 Areas, Integrals and Antiderivatives

f(x i )l i (x)dx = w i f(x i ) := I n [f] where w i = i=0

Riemann Sums and Riemann Integrals

Polynomial Approximations for the Natural Logarithm and Arctangent Functions. Math 230

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

MORE FUNCTION GRAPHING; OPTIMIZATION. (Last edited October 28, 2013 at 11:09pm.)

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

Riemann Sums and Riemann Integrals

Lab 11 Approximate Integration

Lecture 1: Introduction to integration theory and bounded variation

ODE: Existence and Uniqueness of a Solution

Math 131. Numerical Integration Larson Section 4.6

Improper Integrals, and Differential Equations

UNIFORM CONVERGENCE. Contents 1. Uniform Convergence 1 2. Properties of uniform convergence 3

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

Overview of Calculus

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

Overview of Calculus I

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

Chapter 3 Polynomials

5: The Definite Integral

MATH 144: Business Calculus Final Review

Math 554 Integration

Transcription:

AMSC/CMSC 46/466 T. von Petersdorff 1 umericl Integrtion 1 Introduction We wnt to pproximte the integrl I := f xdx where we re given, b nd the function f s subroutine. We evlute f t points x 1,...,x n nd construct out of the function vlues n pproximtion Q. We wnt to hve smll qudrture error Q I using s few function evlutions s possible. We cn do this using interpoltion: construct the interpolting polynomil px let Q := pxdx by writing Q in terms of the function vlues we obtin qudrture rule of the form Q = w 1 f x 1 + + w n f x n In the specil cse tht the function f x is polynomil of degree n 1 we obtin px = f x since the interpolting polynomil is unique, nd hence Q = I. Therefore the qudrture rule is exct for ll polynomils of degree n 1. Midpoint Rule, Trpezoid Rule, Simpson Rule We consider some specil cses with n = 1,, points: Midpoint Rule: Let n = 1 nd pick the midpoint x 1 := + b/. Then px = f x 1 constnt function nd Q Midpt = b f x 1 Trpezoid Rule: the trpezoid: Let n = nd pick the endpoints: x 1 :=, x := b. Then px is liner function nd Q is the re of Q Trp = b f + f b Simpson Rule: Let n = nd pick the endpoints nd midpoint: x 1 :=, x := +b/, x := b. Then px is qudrtic function nd we obtin Q Simpson = b f x 1 + 4 f x + f x. 6 Proof: Let us consider the intervl [,b = [,r where r = b /. We know tht Q = pxdx = w 1 f x 1 + w f x + w f x nd we wnt to find w 1,w,w. We lso know tht we must hve Q = I for f x = 1, f x = x, f x = x yielding the equtions r w 1 1 + w 1 + w 1 = 1dx = r w 1 + w + w r = w 1 r + w + w r = r r xdx = x dx = r

AMSC/CMSC 46/466 T. von Petersdorff Solving this system for w 1,w,w yields w 1 = w = r, w = 4 r. The midpoint rule is gurnteed to be exct for polynomils of degree. But ctully it is lso exct for ll polynomils of degree 1: On the intervl [,r consider f x = c + x. Then the term c is exctly integrted by the midpoint rule. For the term x the exct integrl is zero, nd the midpoint rule lso gives zero for this term. The Simpson rule is gurnteed to be exct for polynomils of degree. But ctully it is lso exct for ll polynomils of degree : On the intervl [,r consider f x = c + x + c x + c x. Then the term c + x + c x is exctly integrted by the Simpson rule. For the term c x the exct integrl is zero, nd the Simpson rule lso gives zero for this term..1 Errors for the Midpoint Rule, Trpezoid Rule, Simpson Rule ote tht we hve for the qudrture error I Q = f x pxdx nd we know for the interpolting polynomil tht f x px 1 mx f n x x x 1 x x n n! t [,b yielding I Q 1 n! mx f n x t [,b x x 1 x x n dx. 1 Error for Trpezoid Rule: Here we need to compute x x b dx. Let us consider the intervl [,b = [,r: r r x x b dx = x + rx r dx = r x dx = [ r x 1 x r = 4 r As r = b / nd n = the formul 1 becomes I Q Trp b mx f x 1 t [,b Error for Midpoint Rule: We wnt to exploit tht the Midpoint Rule is exct for polynomils of degree 1 nd consider the interpolting polynomil px which interpoltes f t the nodes x 1,x 1 which is the tngent line: px = f [x + f [x,x x x = px + f [x,x x x pxdx = pxdx + f [x,x x x dx = Q + Hence we hve using the interpoltion error for px I Q = f x pxdx 1! mx t [,b f x x x 1 x x 1 dx } {{ } [ 1 x x 1 b = b yielding I Q Midpt b mx f x 4 t [,b

AMSC/CMSC 46/466 T. von Petersdorff Error for Simpson Rule: We wnt to exploit tht the Simpson Rule is exct for polynomils of degree nd consider the interpolting polynomil px which interpoltes f t the nodes x 1,x,x,x which lso hs the correct slope in the midpoint: px = px + f [x 1,x,x,x x x 1 x x x x pxdx = pxdx + f [x 1,x,x,x x x 1 x x x x dx = Q + since the function x x 1 x x x x is ntisymmetric with respect to the midpoint x. Hence we hve using the interpoltion error for px I Q = f x pxdx 1 mx f 4 b x x x 1 x x x x dx. 4! t [,b We consider the intervl [,b = [,r with r = b /. Then we hve for the integrl x x1 x x x x r dx = x + rx x r r dx = r r x x dx = [r x r5 = 4 5 15 r5 yielding I Q Simpson b 5 9 mx f 4 x. t [,b. Higher Order Rules For given nodes x 1,...,x n we cn construct qudrture rule Q = w 1 f x 1 + + w n f x n with n interpolting polynomil of degree n 1. Using the method from the Simpson rule we cn find the weights w 1,...,w n by solving liner system. For equidistnt nodes this gives for n = 9 nodes weights w j which re lterntingly positive nd negtive, nd for lrger vlues of n the size of the weights w j increses exponentilly: For [,1 we get n n 15 5 5 45 w j. 1 1 5.6 1.5 1 6 1.4 1 9 This mens tht in mchine rithmetic there will be substntil subtrctive cncelltion. The reson for the negtive weights is tht interpolting polynomils of lrge degree tend to hve very lrge oscilltions, s we sw erlier. For interpoltion we hve seen tht one cn void these problems by crefully plcing the nodes in nonuniform wy so tht they re more closely clustered together t the endpoints. For interpoltion good choice re the so-clled Chebyshev nodes which re the zeros of Chebyshev polynomils. This choice of nodes is lso useful for numericl integrtion. Insted of the zeros of Chebyshev polynomils one cn lso choose the extrem of Chebyshev polynomils, nd in this cse there is n efficient lgorithm to compute Q Clenshw-Curtis qudrture. Another choice re the so-clled Guss nodes for Gussin qudrture, see section 5 below. These nodes re lso more closely clustered ner the endpoints, but they re chosen to mximize the polynomil degree for which the rule is exct. Composite Rules For prcticl integrtion problem it is better to increse the ccurcy by first subdividing the intervl into smller subintervls with prtition = x < x 1 < < x < x = b

AMSC/CMSC 46/466 T. von Petersdorff 4 nd intervl sizes h j := x j x j. Then we pply one of the bsic rules midpoint, trpezoid or Simpson rule on ech subintervl nd dd everything together. This is clled composite rule. For exmple, the composite trpezoid rule is defined by Q Trp := Q Trp [x,x 1 + + QTrp [x,x where Q Trp [x j,x j = h j 1 f x j + f x j. Similrly we cn define the composite midpoint rule nd the composite Simpson rule. Work: For the composite trpezoid rule with subintervls we use + 1 function evlutions. For the composite midpoint rule with subintervls we use function evlutions. For the composite Simpson rule with subintervls we use + 1 function evlutions..1 Error for Composite Rules The error of the composite trpezoid rule is the sum of the errors on ech subintervl: I Q Trp = I [x j,x j Q Trp [x j,x j I [x j,x j Q Trp I Q Trp I [x j,x j Q Trp [x j,x j 1 1 [x j,x j [x j,x j mx f t Similrly we cn obtin estimtes for the composite midpoint rule nd the composite Simpson rule. h j. Subintervls of equl size The simplest choice is to choose ll subintervls of the sme size h = b /. In this cse we obtin for the composite trpezoid rule I Q Trp 1 mx f t h 1 mx f t h 1 [x j,x j 1 [,b 1 I Q Trp 1 1 b mx f t [,b If f x is continuous for x [,b we therefore obtin with C = b 1 mx [,b f t tht I Q Trp C. This shows tht the error tends to zero s. Composite midpoint rule: If f x is continuous for x [,b we obtin in the sme wy where we lso hve I Q Midpt C. I Q Midpt 1 4 b mx f t [,b Composite Simpson rule: If f 4 x is continuous for x [,b we obtin in the sme wy I Q Simpson 1 b 5 9 4 mx f 4 t [,b In this cse we hve I Q Simpson C, so the composite Simpson rule will converge fster thn the composite trpezoid or 4 midpoint rule.

AMSC/CMSC 46/466 T. von Petersdorff 5. If we only know tht f x is continuous Wht hppens if f x is not smooth enough, i.e., there does not exist continuous second derivtive f x on [,b? Assume tht f x is continuous on [,b. Then we know from clculus tht we obtin the integrl s the limit of Riemnn sums: Define subdivision = x < x 1 < < x = b with mximl intervl size d := mx,..., x j x j. Then pick points t j [x j,x j in ech subintervl nd define the Riemnn sum R := f t j x j x j If we use sequence of subdivisions with d we hve R I s. For given subdivision define R left s the Riemnn sum where we use the left endpint t j := x j of ech subintervl. Let R right denote the Riemnn sum where we use the right endpoint t j := x j, nd let R mid denote the Riemnn sum where we use the midpoint t j := 1 x j + x j. Ech of these Riemnn sums converges to I for sequence of subdivisions with d. ote tht we hve nd hence Q Midpt = R mid, Q Trp = 1 R left + R right, Q Simpson = 1 6 R left + 4R mid + R right Q Midpt I, Q Trp I, Q Simpson I for sequence of subdivisions with d..4 Subintervls of different size, dptive subdivision For the compositive trpezoid rule Q Trp I Q Trp the qudrture error I [x j,x j Q Trp [x j,x j 1 1 mx [x j,x j f t depends on the size of the nd derivtive mx [x j,x j f t on ech subintervl, multiplied by h j where h j is the length of the subintervl. If f x is smll in one prt of [,b we cn use lrge intervl sizes h j there. If f x is lrge in nother prt of [,b we should compenste for tht with smll intervl sizes h j there. This is clled n dptive subdivision. Exmple: We wnt to find 6 I = f xdx, h j with f x = x x 1 + x 4 Here f is smll for x >, so we cn use lrge subintervls. For smller x nd in prticulr close to x =.5 we hve lrge vlues for f, hence we should use smller subintervls. An dptive subdivision should look like this:...1 -.1 -. -. subdivision for dptive qudrture 1 4 5 6 x

AMSC/CMSC 46/466 T. von Petersdorff 6 4 Adptive qudrture In prctice we do not know f x. We re only given subroutine f x, the intervl [,b nd desired tolernce Tol e.g., Tol = 1 5. We then wnt to find subdivision x < x 1 < < x such tht the composite trpezoid rule gives n pproximtion Q Trp with Q Trp I Tol. How cn we do this? For n dptive lgorithm we need the following ingredients: On ech subintervl [α,β of length h := β α we need n pproximtion for the integrl I [α,β : we use the trpezoid rule Q Trp [α,β = h f α + f β n error estimte for Q Trp [α,β I [α,β : Obviously we don t know the exct integrl I [α,β. But we cn evlute the function in the midpoint γ = α + β/ nd find the Simpson rule pproximtion Q Simp [α,β = h 6 f α + 4 f γ + f β. We know tht Q Trp [α,β, QSimp [α,β stisfy Q Trp [α,β I [α,β h 1 mx f t = C h, t [α,β Q Simp [α,β I [α,β h5 9 mx t [α,β f 4 t = C 4 h 5 Clerly for smll intervl length h the Simpson pproximtion is much closer to I [α,β thn the trpezoid pproximtion. Therefore we cn pproximte the error using Q Trp [α,β I [α,β Q Trp [α,β QSimp [α,β where the right hnd side cn be esily computed. This will be good pproximtion for the error if the subintervl is smll. n ccurcy gol Q Trp [α,β I [α,β Tol [α,β for the subintervl: On the whole intervl we wnt n error Q Trp I Tol. Therefore it seems resonble to require for the subintervl [α, β tolernce proportionl to its length h: We wnt Q Trp [α,β I [α,β h Tol b e.g., for n subintervl of hlf the length we wnt hlf of the qudrture error. We cn implement these ides using recursive Mtlb function Q=dptintf,,b,Tol s follows: function Q = dptintf,,b,tol f = f; fb = fb; QT = b-/*f+fb; % Trpezoid rule c = +b/; fc = fc; % evlute f in midpoint QS = b-/6*f+4*fc+fb; % Simpson rule % for smll intervls we cn pproximte error QT-I by QT-QS if bsqt-qs<=tol % if estimted error is <= Tol Q = QT; % ccept trpezoid rule vlue else Q = dptintf,,c,tol/ + dptintf,c,b,tol/; % use lgorithm for [,c nd [c,b with Tol/ end We sve this s n m-file dptint.m. Then we cn pproximte the integrl in our exmple using >> f = @x x^-x/1+x^4 >> Q = dptintf,,6,1e- Q = 1.14455841

AMSC/CMSC 46/466 T. von Petersdorff 7 The ctul error is Q I 9.85 1 4. Here dptint uses the subdivision shown in the figure on pge 5 with = 1 subintervls. ote tht we evlute the function lso in the midpoints of these intervls, so the totl number of function evlutions needed is 6. Remrks: 1. The recursion will terminte: Assume tht f x is continuous on [,b. Then for ny given ε > there exists δ > such tht s,t [,b with s t < δ = f s f t < ε 4 We re given tolernce Tol. After k levels of recursion we hve subintervls [α,β of length β α = k b. We need to show tht the condition Q Trp [α,β QSimp [α,β Tol β α 5 b is stisfied if k is sufficiently lrge. We hve with γ := 1 α + β Therefore 5 holds if we hve Q Trp Q Trp [α,β QSimp [α,β = 1 β α[ f α f γ + [ f β f γ [α,β QSimp [α,β 1 β α f α f γ + f β f γ! Tol β α b We now use ε := Tol b nd obtin δ > such tht 4 holds. Therefore 5 will hold if k stisfies k b < δ.. During the recursion the bove code ctully re-evlutes the lredy computed vlues f nd fb gin. We cn fix this using function Q = dptintf,,b,tol,f,fb if nrgin==4 % if function is clled s dptintf,,b,tol f = f; fb = fb; % compute f,fb end % otherwise we get f,fb pssed s rguments... Q = dptintf,,c,tol/,f,fc + dptintf,c,b,tol/,fc,fb; end. The lgorithm is bsed on the ssumption tht QS is better pproximtion thn QT. Hence we should get more ccurte result by chnging the line Q = QT to Q = QS. For the bove exmple we then get Q = 1.4471656 with the smller error Q I.47 1 5. ote tht we re now using composite Simpson rule pproximtion for Q, but using subdivision bsed on error bounds for the trpezoid rule. In order to obtin good error estimte for the Simpson rule we would need dditionl function evlutions to compute vlue Q which is more precise thn QS so tht we cn pproximte QS I by QS Q. 4. ote tht dptive qudrture cn give completely wrong results: f = @xexp-1*x^ Q = dptintf,-1,,1e-4 Q = 9.799859549697e-5 The correct vlue is I = nd is lmost zero outside of [.8,.8: e x dx.56497. Wht hppened? The function f x hs shrp pek ner x =

AMSC/CMSC 46/466 T. von Petersdorff 8 1.8.6.4. exp - 1 x -1 -.5.5 1 1.5.5 x The dptive qudrture evlutes for = nd b = the vlues f, f yielding QT. At the midpoint c = 1 we get f 1, so lso QS nd hence QT QS 6 1 5 which is less thn our tolernce 1 4. Hence our progrm ccepts the trpezoid rule vlue QT, bsed on only three function vlues t x =,1,, completely missing the pek ner x =. A qudrture method cn never gurntee tht the error is less thn the tolernce: The only informtion we hve re finitely mny function vlues, nd the function could hve some crzy behvior between those vlues. If function hs fetures like shrp peks or singulrities which the qudrture my miss we cn help the qudrture method by subdividing the integrl: In our exmple we cn split the integrl t x = : Q = dptintf,-1,,1e-4 + dptintf,,,1e-4 Q =.5659881647 1 which gives n error Q I 4. 1 5. 5. Adptive qudrture works efficiently even for functions with singulrities We sw in section.: For functions f x where f x is continuous we cn use subintervls of equl size, nd the qudrture error decys like Q Trp I c. For integrls like I = x 1/ dx this does not work since for f x = x 1/ the nd derivtive f x = 9 x 5/ becomes infinite ner. We now use our dptive lgorithm: fx = x 1/ : subdivision for dptive qudrture.8.6.4..1...4.5.6.7.8.9 1 x f = @x x^1/; Tol = 1e-; Q = dptintf,,1,tol; err = bsq - /4 % given tolernce % qudrture error, exct integrl is I=/4

AMSC/CMSC 46/466 T. von Petersdorff 9 For Tol=1e-,1e-4,1e-6, etc. we get for the number of function evlutions nd the error Q I Tol Q I 1 9 6.5 1 1 4 4 5.8 1 5 1 6.7 1 5.5 1 7 1 8.4 1 4 5.6 1 9 1.5 1 5 5.6 1 1 1.7 1 6 5. 1 1 4.5 1 7 5.5 1 5 We see tht ech time gets multiplied by bout 1, nd the error gets multiplied by bout 1, hence we hve Q I C. Therefore our lgorithm gives dptive subdivisions where the composite trpezoid rule Q I decys with the sme rte O we cn chieve for smooth functions. 5 Gussin qudrture 5.1 Introduction Sometimes we wnt to find integrls of functions with singulrities, e.g. I = x 1/ e x dx ote tht the function x 1/ hs infinite derivitives t x =. Therefore composite rules with subintervls of equl size will perform poorly however, dptive qudrture works well. Assume tht we wnt to compute mny integrls of the form I = x 1/ f xdx where f x is smooth function. Then it mkes sense to design custom qudrture rule x 1/ f xdx w 1 f x 1 + + w n f x n where we try to find the optiml plcement of the nodes x 1,...,x n. 5. Guss rule I = f xρxdx w 1 f x 1 + + w n f x n We wnt to pproximte integrls of the form I[ f := f xρxdx where the function ρx > except for finitely mny points where ρ = or ρ. We ssume tht pxρxdx < for ll polynomils px. In the previous section we hd the intervl [,b = [,1 nd the function ρx = x 1/. ote tht we cn lso use ρx = 1 or ρx = x /. We wnt to pproximte the integrl with qudrture rule I[ f Q[ f := w 1 f x 1 + + w n f x n For ny choice of nodes x 1,...,x n we cn construct the interpolting polynomil px nd pproximte I[ f = f xρxdx by Q[ f := pxρxdx = w 1 f x 1 + + w n f x n

AMSC/CMSC 46/466 T. von Petersdorff 1 This rule is exct for ll polynomils of degree n 1. Our gol is to choose the nodes x 1,...,x n such tht Q[ f = I[ f for ll polynomils of degree n 1. The node polynomil is given by ω n x = x x 1 x x n. Assume we re given n polynomil p n x of degree n 1. We cn divide p n x by ω n x nd obtin quotient polynomil q n x nd reminder polynomil r n x where q n x, r n x re of degree n 1: p n x = q n x ω n x + r n x Hence I [p n = I [q n ω n + I [r n Q[p n = Q[q n ω n + Q[r n Since the rule Q is exct for polynomils of degree n 1 we hve Q[r n = I [r n. Since q n x ω n x is zero in ll nodes x 1,...,x n we hve Q[q n ω n =. Hence we hve Q[p n = I [p n if nd only if I [q n ω n =. Result: Our qudrture rule Q is exct for ll polynomils p n x of degree n 1 iff ω n x stisfies I [q n ω n = for ll polynomils q n x of degree n 1, i.e., x k ω n xρxdx = for k =,...,n 1 6 Step 1: Find node polynomil ω n x = x x 1 x x n = x n + c n x n + + x + c stisfying 6. I.e., find n unknowns c,...,c n stisfying n liner equtions given by 6. After we hve found the integrls [ α k := I x k = x k ρxdx for k =,...,n 1 we cn write the liner system 6 s α α 1 α n α 1 α..... αn α n α n α n c. c n = Solving this liner system gives us the node polynomil ωx = x n + c n x n + + c = x x 1 x x n. This liner system hs lwys unique solution. Step : find the nodes x 1,...,x n by solving ωx =. This lwys gives n distinct roots x 1,...,x n in the open intervl,b. α n α n+1. α n Step : find the weights w 1,...,w n such tht Q [ x k = I [ x k for k =,...,n 1: This gives the liner system x1 xn.. x1 n xn n w 1. w n = α. α n 7 8 This liner system hs lwys unique solution. The weights w j re ll positive. Therefore evluting Q[ f = w 1 f x 1 + + w n f x n in mchine rithmetic is numericlly stble if f x does not chnge sign.

AMSC/CMSC 46/466 T. von Petersdorff 11 5. Exmple 1: x 4/7 f xdx w 1 f x 1 + w f x Here ρx = x 4/7, [,b = [,1 nd n =. We first compute the integrls α = x 4/7 1dx = 7 11, α 1 = x 4/7 xdx = 7 18, α = x 4/7 x dx = 7 5, α = x 4/7 x dx = 7 Step 1: find node polynomil ωx = x + x + c such tht which gives the liner system [ α α 1 α 1 α which hs the solution [ c [ c [.475 =.15 x 4/7 x k x + x + c dx = for k =,1 [ α = α, i.e., [ 7 11 7 18 7 18 7 5 [ c [ 7 = 5 7, hence ωx = x 1.15x +.475 = x x 1 x x. Step : find the nodes x 1,x by solving ωx = : The qudrtic formul gives x 1 =., x =.85. Step : find the weights w 1,w such tht Q [ x k = I [ x k for k =,1: [ [ [ [ 1 1 w1 α 1 1 =, i.e., x 1 x w α 1..85 which hs the solution w 1 = 7 7, w = 11 97. Our qudrture rule is exct for ll polynomils of degree n 1 =. Let us try out this rule for I = error is Q I 1 4. [ w1 w = [ 7 11 7 18 x 4/7 e x dx: We obtin Q = w 1 e x 1 + w e x = 1.147, the exct vlue is I = 1.166, the 5.4 Exmple : f xdx w 1 f x 1 + w f x + w f x Here ρx = 1, [, b = [, 1 nd n =. We first compute the integrls α = 1dx =, α 1 = xdx =, α = x dx =, α = x dx =, α 4 = x 4 dx = 5, α 5 = x 5 dx = Step 1: find node polynomil ωx = x + c x + x + c such tht which gives the liner system α α 1 α α 1 α α α α α 4 c which hs the solution = 5 c x k x + c x + x + c dx = for k =,1, c c = α α 4 α 5, i.e., 5 c c, hence ωx = x 5 x = x x 1x x x x. Step : find the nodes x 1,x,x by solving ωx = x x 5 =. This gives x 1 = 5, x =, x = 5 = 5

AMSC/CMSC 46/466 T. von Petersdorff 1 Step : find the weights w 1,w,w such tht Q [ x k = I [ x k for k =,1: which hs the solution 1 1 1 x 1 x x x1 x x w 1 w w = α α 1 α, i.e., 1 1 1 5 5 5 5 w 1 = 5 9, w = 8 9, w = 5 9 Our qudrture rule is exct for ll polynomils of degree n 1 = 5. Let us try out this rule for I = the error is Q I = 6.5 1 5. w 1 w w = e x dx: We obtin Q = w 1 e x 1 + w e x + w e x =.57, the exct vlue is I =.54, 5.5 Exmple : f xe x dx w 1 f x 1 + w f x Here ρx = e x,,b =, nd n =. The infinite intervl, is llowed since px. We first compute the integrls pxe x dx < for ll polynomils α = e x 1dx = 1, α 1 = e x xdx = 1, α = e x x dx =, α = e x x dx = 6 Step 1: find node polynomil ωx = x + x + c such tht which gives the liner system [ α α 1 α 1 α which hs the solution [ c [ = 4 [ c e x x k x + x + c dx = for k =,1 [ α = α, i.e., [ 1 1 1 [ c, hence ωx = x 4x + = x x 1 x x. Step : find the nodes x 1,x by solving ωx = : The qudrtic formul gives x 1 =, x = + [ = 6 Step : find the weights w 1,w such tht Q [ x k = I [ x k for k =,1: [ 1 1 x 1 x [ w1 w [ α = α 1, i.e., [ 1 1 + [ w1 w [ 1 = 1 which hs the solution w 1 = 1 + 1 4, w = 1 1 4 Our qudrture rule is exct for ll polynomils of degree n 1 =. Let us try out this rule for I = e x sinxdx: We obtin Q = w 1 sinx 1 + w sinx =.446, the exct vlue is I =.5, the error is Q I = 6.8 1. As we increse n the qudrture error goes to zero: n 1 6 1 Q n I 1 7 1 4 1 5 1 5 1 7

AMSC/CMSC 46/466 T. von Petersdorff 1 5.6 Proofs for Guss qudrture We hve to prove tht ll the steps work s climed. Step 1: find node polynomil ωx = x n + c n x n + + c such tht x k ωxρxdx = for k =,...,n 1 9 This gives the liner system 7. We clim tht this liner system hs unique solution. Proof: The liner system with zero right hnd side vector corresponds to finding px = c n x n + + c such tht But then = x k pxρxdx = for k =,...,n 1 cn x n + + c x pxρxdx = px ρxdx Since ρx > except for finitely mny points we must hve px =. Hence the liner system with zero right hnd side vector hs only the solution c = = c n =, nd the mtrix is nonsingulr. We cn define for two functions u,v on,b the inner product u,v := uxvxρxdx The condition 9 sys tht ωx is polynomil of degree n which is orthogonl on ll lower degree polynomil. Such polynomil is clled n orthogonl polynomil. Step : find the nodes x 1,...,x n by solving ωx =. We clim tht the function ωx hs n distinct simple roots in the open intervl,b. Proof: Let t 1,...,t r denote ll points in,b where ωx chnges sign. We wnt to show tht r = n. Assume tht r < n. As x t 1 x t r ωx lwys hs for x t j lwys the sme sign, sy positive, we must hve x t 1 x t r ωxρxdx > On the other hnd this integrl must be zero by the orthogonlity 9. Step : find the weights w 1,...,w n by solving the liner system 8. We clim tht this liner system hs unique solution. Proof: Finding n interpolting polynomil c + + c n x n leds to liner system with the trnspose mtrix. The interpoltion problem hs unique solution, hence the mtrix is nonsingulr. The weights w 1,...,w n re ll positive: For j {1,...,n} define the polynomil of degree n 1 p j x := k=1,...,n k j x x k then p j x is of degree n nd therefore exctly integrted by the Guss rule: < I [ p [ j = Q p j = w j p j x j }{{} >