Numerical Integration Numerical Differentiation Richardson Extrapolation Outline
1 Numerical Integration
2 Numerical Differentiation
3 Richardson Extrapolation
Michael T. Heath Scientific Computing 2 / 61 Main Ideas
❑ Quadrature based on polynomial interpolation: ❑ Methods: ❑ Method of undetermined coefficients (e.g., Adams-Bashforth) ❑ Lagrangian interpolation
❑ Rules: ❑ Midpoint, Trapezoidal, Simpson, Newton-Cotes ❑ Gaussian Quadrature
❑ Quadrature based on piecewise polynomial interpolation ❑ Composite trapezoidal rule ❑ Composite Simpson ❑ Richardson extrapolation
❑ Differentiation ❑ Taylor series / Richardson extrapolation ❑ Derivatives of Lagrange polynomials ❑ Derivative matrices Quadrature Examples
b = ecos x dx •I Za Di↵erential equations: n u(x)= u (x) XN j j 2 j=1 X Find u(x)suchthat du r(x)= f(x) XN dx ? Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Integration
For f : R R, definite integral over interval [a, b] ! b I(f)= f(x) dx Za is defined by limit of Riemann sums n R = (x x ) f(⇠ ) n i+1 i i Xi=1 Riemann integral exists provided integrand f is bounded and continuous almost everywhere Absolute condition number of integration with respect to perturbations in integrand is b a Integration is inherently well-conditioned because of its smoothing effect
Michael T. Heath Scientific Computing 3 / 61 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Numerical Quadrature
Quadrature rule is weighted sum of finite number of sample values of integrand function To obtain desired level of accuracy at low cost, How should sample points be chosen? How should their contributions be weighted?
Computational work is measured by number of evaluations of integrand function required
Michael T. Heath Scientific Computing 4 / 61 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Quadrature Rules
An n-point quadrature rule has form
n Qn(f)= wi f(xi) Xi=1 Points xi are called nodes or abscissas
Multipliers wi are called weights Quadrature rule is
open if a closed if a = x1 and xn = b Can also have (x x … x ) a < b (Adams-Bashforth timesteppers) • 1 2 n · Michael T. Heath Scientific Computing 5 / 61 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Quadrature Rules, continued Quadrature rules are based on polynomial interpolation Integrand function f is sampled at finite set of points Polynomial interpolating those points is determined Integral of interpolant is taken as estimate for integral of original function In practice, interpolating polynomial is not determined explicitly but used to determine weights corresponding to nodes If Lagrange is interpolation used, then weights are given by b wi = `i(x),i=1,...,n Za Michael T. Heath Scientific Computing 6 / 61 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Method of Undetermined Coefficients Alternative derivation of quadrature rule uses method of undetermined coefficients To derive n-point rule on interval [a, b], take nodes x1,...,xn as given and consider weights w1,...,wn as coefficients to be determined Force quadrature rule to integrate first n polynomial basis functions exactly, and by linearity, it will then integrate any polynomial of degree n 1 exactly Thus we obtain system of moment equations that determines weights for quadrature rule Michael T. Heath Scientific Computing 7 / 61 Quadrature Overview b n I(f):= f(t) dt w f , =: Q (f) f := f(t ) ⇡ i i n i i a i=1 Z X Idea is to minimize the number of function evaluations. • Small n is good. • Several strategies: • – global rules – composite rules – composite rules + extrapolation – adaptive rules 1 Global (Interpolatory) Quadrature Rules Generally, approximate f(t)bypolynomialinterpolant,p(t). • n f(t) p(t)= l (t) f ⇡ i i i=1 X b b I(f)= f(t) dt p(t) dt =: Q (f) ⇡ n Za Za b n n b n Qn(f)= li(t) fi dt = li(t) dt fi = wi fi. a i=1 ! i=1 a i=1 Z X X ✓Z ◆ X b wi = li(t) dt Za We will see two types of global (interpolatory) rules: • – Newton-Cotes — interpolatory on uniformly spaced nodes. – Gauss rules — interpolatory on optimally chosen point sets. 2 Examples Midpoint rule: l (t)=1 • i b b w = l (t) dt = 1 dt =(b a) 1 1 Za Za Trapezoidal rule: • t b t a l (t)= ,l(t)= 1 a b 2 b a b b w = l (t) dt = 1(b a)= l (t) dt = w 1 1 2 2 2 Za Za Simpson’s rule: • b b b a w1 = l1(t) dt = 6 = l3(t) dt = w3 Za Za b b t a t b 2 w = l (t) dt = dt = (b a) 2 2 b a a b 3 Za Za ✓ ◆✓ ◆ These are the Newton-Cotes quadrature rules for n=1, 2, and 3, • respectively. – The midpoint rule is open. – Trapezoid and Simpson’s rules are closed. 3 Finding Weights: Method of Undetermined Coefficients METHOD OF UNDETERMINED COEFFICIENTS Example 1: Find wi for [a, b]=[1, 2], n =3. First approach: f =1,t,t2. • 3 I(1) = w 1=1 i · i=1 X 3 1 2 I(t)= w t = t2 i · i 2 i=1 1 X 3 1 2 I(t2)= w t2 = t3 i · i 3 i=1 1 X Results in 3 3matrixforthew s. ⇥ i Second approach: Choose f so that some of the coe cients multiplying • the wisvanish. 3 2 3 I = w (1 )(1 2) = (t )(t 2) dt 1 1 2 2 Z1 3 3 2 I = w ( 1)( 2) = (t 1)(t 2) dt 2 2 2 2 Z1 3 2 3 I = w (2 1)(2 )= (t 1)(t ) dt 3 3 2 2 Z1 Corresponds to the Lagrange interpolant approach. 5 METHOD OF UNDETERMINED COEFFICIENTS Example 1: Find wi for [a, b]=[1, 2], n =3. First approach: f =1,t,t2. • 3 I(1) = w 1=1 i · i=1 X 3 1 2 I(t)= w t = t2 i · i 2 i=1 1 X 3 1 2 I(t2)= w t2 = t3 i · i 3 Finding Weights: Method ofi=1 Undetermined 1 Coefficients X Results in 3 3matrixforthew s. ⇥ i Second approach: Choose f so that some of the coe cients multiplying • the wisvanish. 3 2 3 I = w (1 )(1 2) = (t )(t 2) dt 1 1 2 2 Z1 3 3 2 I = w ( 1)( 2) = (t 1)(t 2) dt 2 2 2 2 Z1 3 2 3 I = w (2 1)(2 )= (t 1)(t ) dt 3 3 2 2 Z1 Corresponds to the Lagrange interpolant approach. 5 Method of Undetermined Coefficients Example 2: Find wi for [a, b]=[0, 1], n =3,butusingfi = f(ti)=f(i), with i =-2,-1,and0.(Theti’s are outside the interval (a, b).) Result should be exact for f(t) lP ,lP,andlP. • 2 0 1 2 Take f=1, f=t,andf=t2. • 1 wi =1= 1 dt 0 X Z 1 1 2w 2 w 1 = = tdt 2 Z0 1 1 2 4w 2 + w 1 = = t dt 3 Z0 Find • 5 16 23 w 2 = w 1 = w0 = . 12 12 12 This example is useful for finding integration coe cients for explicit time- • stepping methods that will be seen in later chapters. 6 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Example: Undetermined Coefficients Derive 3-point rule Q3(f)=w1f(x1)+w2f(x2)+w3f(x3) on interval [a, b] using monomial basis Take x1 = a, x2 =(a + b)/2, and x3 = b as nodes First three monomials are 1, x, and x2 Resulting system of moment equations is b w 1+w 1+w 1= 1 dx = x b = b a 1 · 2 · 3 · |a Za b w a + w (a + b)/2+w b = xdx=(x2/2) b =(b2 a2)/2 1 · 2 · 3 · |a Za b w a2 + w ((a + b)/2)2 + w b2 = x2 dx =(x3/3) b =(b3 a3)/3 1 · 2 · 3 · |a Za Michael T. Heath Scientific Computing 8 / 61 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Example, continued In matrix form, linear system is 111w b a 1 a (a + b)/2 b w = (b2 a2)/2 2 3 2 23 2 3 a2 ((a + b)/2)2 b2 w (b3 a3)/3 3 4 5 4 5 4 5 Solving system by Gaussian elimination, we obtain weights b a 2(b a) b a w = ,w= ,w= 1 6 2 3 3 6 which is known as Simpson’s rule Michael T. Heath Scientific Computing 9 / 61 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Method of Undetermined Coefficients More generally, for any n and choice of nodes x1,...,xn, Vandermonde system 11 1 w1 b a ··· 2 2 x1 x2 xn w2 (b a )/2 2 . . ···. . 3 2 . 3 = 2 . 3 ...... 6 n 1 n 1 n 17 6 7 6 n n 7 6x x x 7 6wn7 6(b a )/n7 6 1 2 ··· n 7 6 7 6 7 4 5 4 5 4 5 determines weights w1,...,wn Michael T. Heath Scientific Computing 10 / 61 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Stability of Quadrature Rules Absolute condition number of quadrature rule is sum of magnitudes of weights, n w | i| Xi=1 If weights are all nonnegative, then absolute condition number of quadrature rule is b a, same as that of underlying integral, so rule is stable If any weights are negative, then absolute condition number can be much larger, and rule can be unstable Michael T. Heath Scientific Computing 13 / 61 Conditioning Absolute condition number of integration: • b I(f)= f(t) dt Za b I(fˆ)= fˆ(t) dt Za b I(f) I(fˆ) = (f fˆ) dt b a f fˆ a | ||| ||1 Z Absolute condition number is b a . • | | Absolute condition number of quadrature: • n n Qn(f) Qn(fˆ) wi fi fˆi wi max fi fˆi i i=1 ⇣ ⌘ i=1 X X n wi f fˆ || ||1 i=1 X n C = w | i| i=1 X If Q (f)isinterpolatory,then w =(b a): • n i n P b Q (1) = w 1 1 dt =(b a). n i · ⌘ i=1 a X Z If w 0, then C =(b a). • i Otherwise, C>(b a)andcanbearbitrarilylargeasn . • ! 1 4 Absolute condition number of integration: • b I(f)= f(t) dt Za b I(fˆ)= fˆ(t) dt Za b I(f) I(fˆ) = (f fˆ) dt b a f fˆ a | ||| ||1 Z Absolute condition number is b a . • | | Conditioning Absolute condition number of quadrature: • n n Qn(f) Qn(fˆ) wi fi fˆi wi max fi fˆi i i=1 ⇣ ⌘ i=1 X X n wi f fˆ || ||1 i=1 X n C = w | i| i=1 X If Q (f)isinterpolatory,then w =(b a): • n i n P b Q (1) = w 1 1 dt =(b a). n i · ⌘ i=1 a X Z If w 0, then C =(b a). • i Otherwise, C>(b a)andcanbearbitrarilylargeasn . • ! 1 4 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Newton-Cotes Quadrature Newton-Cotes quadrature rules use equally spaced nodes in interval [a, b] Midpoint rule a + b M(f)=(b a)f 2 ✓ ◆ Trapezoid rule b a T (f)= (f(a)+f(b)) 2 Simpson’s rule b a a + b S(f)= f(a)+4f + f(b) 6 2 ✓ ✓ ◆ ◆ Michael T. Heath Scientific Computing 14 / 61 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Example: Newton-Cotes Quadrature Approximate integral I(f)= 1 exp( x2) dx 0.746824 0 ⇡ M(f)=(1 0) exp( 1/4)R 0.778801 ⇡ T (f)=(1/2)[exp(0) + exp( 1)] 0.683940 ⇡ S(f)=(1/6)[exp(0) + 4 exp( 1/4) + exp( 1)] 0.747180 ⇡ < interactive example > Michael T. Heath Scientific Computing 15 / 61 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Error Estimation Expanding integrand f in Taylor series about midpoint m =(a + b)/2 of interval [a, b], f 00(m) 2 f(x)=f(m)+f 0(m)(x m)+ (x m) 2 f (m) f (4)(m) + 000 (x m)3 + (x m)4 + 6 24 ··· Integrating from a to b, odd-order terms drop out, yielding f (m) f (4)(m) I(f)=f(m)(b a)+ 00 (b a)3 + (b a)5 + 24 1920 ··· = M(f)+E(f)+F (f)+ ··· where E(f) and F (f) represent first two terms in error expansion for midpoint rule Michael T. Heath Scientific Computing 16 / 61 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Error Estimation, continued If we substitute x = a and x = b into Taylor series, add two series together, observe once again that odd-order terms drop out, solve for f(m), and substitute into midpoint rule, we obtain I(f)=T (f) 2E(f) 4F (f) ··· Thus, provided length of interval is sufficiently small and f (4) is well behaved, midpoint rule is about twice as accurate as trapezoid rule Halving length of interval decreases error in either rule by factor of about 1/8 Michael T. Heath Scientific Computing 17 / 61 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Error Estimation, continued Difference between midpoint and trapezoid rules provides estimate for error in either of them T (f) M(f)=3E(f)+5F (f)+ ··· so T (f) M(f) E(f) ⇡ 3 Weighted combination of midpoint and trapezoid rules eliminates E(f) term from error expansion 2 1 2 I(f)= M(f)+ T (f) F (f)+ 3 3 3 ··· 2 = S(f) F (f)+ 3 ··· which gives alternate derivation for Simpson’s rule and estimate for its error Michael T. Heath Scientific Computing 18 / 61 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Example: Error Estimation We illustrate error estimation by computing approximate 1 2 value for integral 0 x dx =1/3 M(f)=(1R 0)(1/2)2 =1/4 1 0 T (f)= (02 +12)=1/2 2 E(f) (T (f) M(f))/3=(1/4)/3=1/12 ⇡ Error in M(f) is about 1/12, error in T (f) is about 1/6 Also, S(f)=(2/3)M(f)+(1/3)T (f)=(2/3)(1/4)+(1/3)(1/2) = 1/3 which is exact for this integral, as expected Michael T. Heath Scientific Computing 19 / 61 Example f(x)=2 x2 1 x3 1 1 I(f)= f(x) dx =2x =3. 1 3 1 3 Z M(f)=2f(0) = 2 2=4. ( error =2/3) · · | | f( 1) + f(1) T (f)=2 =2. ( error =4/3) · 2 | | ❑ Error for midpoint rule is generally ½ that of trapezoidal rule. 1 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Accuracy of Quadrature Rules Quadrature rule is of degree d if it is exact for every polynomial of degree d, but not exact for some polynomial of degree d +1 By construction, n-point interpolatory quadrature rule is of degree at least n 1 Rough error bound 1 n+1 (n) I(f) Qn(f) h f | | 4 k k1 where h = max x x : i =1,...,n 1 , shows that { i+1 i } Q (f) I(f) as n , provided f (n) remains well n ! !1 behaved Higher accuracy can be obtained by increasing n or by decreasing h Michael T. Heath Scientific Computing 11 / 61 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Accuracy of Newton-Cotes Quadrature Since n-point Newton-Cotes rule is based on polynomial interpolant of degree n 1, we expect rule to have degree n 1 Thus, we expect midpoint rule to have degree 0, trapezoid rule degree 1, Simpson’s rule degree 2, etc. From Taylor series expansion, error for midpoint rule depends on second and higher derivatives of integrand, which vanish for linear as well as constant polynomials So midpoint rule integrates linear polynomials exactly, hence its degree is 1 rather than 0 Similarly, error for Simpson’s rule depends on fourth and higher derivatives, which vanish for cubics as well as quadratic polynomials, so Simpson’s rule is of degree 3 Michael T. Heath Scientific Computing 20 / 61 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Accuracy of Newton-Cotes Quadrature In general, odd-order Newton-Cotes rule gains extra degree beyond that of polynomial interpolant on which it is based n-point Newton-Cotes rule is of degree n 1 if n is even, but of degree n if n is odd This phenomenon is due to cancellation of positive and negative errors < interactive example > Michael T. Heath Scientific Computing 21 / 61 Newton-Cotes Weights n j 1 2 3 4 5 6 \ 1 1 2 2 2 1 4 1 3 3 3 3 3 9 9 3 4 8 8 8 8 14 64 8 64 14 5 45 45 15 45 45 95 125 125 125 125 95 6 288 96 144 144 96 288 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Drawbacks of Newton-Cotes Rules Newton-Cotes quadrature rules are simple and often effective, but they have drawbacks Using large number of equally spaced nodes may incur erratic behavior associated with high-degree polynomial interpolation (e.g., weights may be negative) Indeed, every n-point Newton-Cotes rule with n 11 has at least one negative weight, and n w as n , i=1 | i| !1 !1 so Newton-Cotes rules become arbitrarily ill-conditioned P Newton-Cotes rules are not of highest degree possible for number of nodes used Michael T. Heath Scientific Computing 22 / 61 Newton-Cotes Formulae: What Could Go Wrong? ❑ Demo: newton_cotes.m and newton_cotes2.m ❑ Newton-Cotes formulae are interpolatory. ❑ For high n, Lagrange interpolants through uniform points are ill- conditioned. ❑ In quadrature, this conditioning is manifest through negative quadrature weights (bad). Imagine how the gradient of Q responds to fi in this case … Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Gaussian Quadrature Gaussian quadratureNumerical rules Integration areQuadrature Rules based on polynomial Numerical Differentiation Adaptive Quadrature interpolation, but nodesRichardson Extrapolation as wellOther Integration as Problems weights are chosen to Gaussian Quadrature maximize degree of resulting rule Gaussian quadrature rules are based on polynomial interpolation, but nodes as well as weights are chosen to With 2n parameters,maximize degree we of resulting can rule attain degree of 2n 1 With 2n parameters, we can attain degree of 2n 1 Gaussian quadratureGaussian quadrature rules rules can be derived be derived by method of by method of undetermined coefficients, but resulting system of moment undeterminedequations coefficients, that determines nodesbut and resulting weights is nonlinear system of moment Also, nodes are usually irrational, even if endpoints of equations thatinterval determines are rational nodes and weights is nonlinear Although inconvenient for hand computation, nodes and Also, nodes areweights usually are tabulated irrational, in advance and stored even in subroutine if endpoints of for use on computer interval are rational Michael T. Heath Scientific Computing 24 / 61 Although inconvenient for hand computation, nodes and weights are tabulated in advance and stored in subroutine for use on computer Michael T. Heath Scientific Computing 24 / 61 Lagrange Polynomials: Good and Bad Point Distributions N=4 N=7 φ2 φ4 N=8 Uniform Gauss-Lobatto-Legendre • We can see that for N=8 one of the uniform weights is close to becoming negative. 3 5 Lagrange Polynomials: Good and Bad Point Distributions gll_txt.m • All weights are positive. 3 6 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Example: Gaussian Quadrature Rule Derive two-point Gaussian rule on [ 1, 1], G2(f)=w1f(x1)+w2f(x2) where nodes xi and weights wi are chosen to maximize degree of resulting rule We use method of undetermined coefficients, but now nodes as well as weights are unknown parameters to be determined Four parameters are to be determined, so we expect to be able to integrate cubic polynomials exactly, since cubics depend on four parameters Michael T. Heath Scientific Computing 25 / 61 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Example, continued Requiring rule to integrate first four monomials exactly gives moment equations 1 1 w1 + w2 = 1 dx = x 1 =2 1 | Z 1 2 1 w1x1 + w2x2 = xdx=(x /2) 1 =0 1 | Z 1 2 2 2 3 1 w1x1 + w2x2 = x dx =(x /3) 1 =2/3 1 | Z 1 3 3 3 4 1 w1x1 + w2x2 = x dx =(x /4) 1 =0 1 | Z Michael T. Heath Scientific Computing 26 / 61 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Example, continued One solution of this system of four nonlinear equations in four unknowns is given by x = 1/p3,x=1/p3,w=1,w=1 1 2 1 2 Another solution reverses signs of x1 and x2 Resulting two-point Gaussian rule has form G (f)=f( 1/p3) + f(1/p3) 2 and by construction it has degree three In general, for each n there is unique n-point Gaussian rule, and it is of degree 2n 1 Gaussian quadrature rules can also be derived using orthogonal polynomials Michael T. Heath Scientific Computing 27 / 61 Topics for Today ❑ Gaussian quadrature ❑ Composite trapezoidal rule ❑ Richardson extrapolation ❑ Romberg integration ❑ Mechanical integration ❑ Numerical differentiation (start) ❑ Project proposals – almost done (should be out tonight) Gauss Quadrature, I 1 Consider I := f(x) dx. 1 Z Find wi,xi i =1,...,n, to maximize degree of accuracy, M. Cardinality, . : lP = M +1 • | | | M | w + x =2n | i | | i | M +1 = 2n M =2n 1 () Indeed, it is possible to find x and w such that all polynomials of degree • i i M =2n 1areintegratedexactly. The n nodes, x , are the zeros of the nth-order Legendre polynomial. • i The weights, w , are the integrals of the cardinal Lagrange polynomials • i associated with these nodes: 1 wi = li(x) dx, li(x) lP n 1,li(xj)= ij. 1 2 Z f (2n)(⇠) Error scales like I Qn C (Qn exact for f(x) lP 2n 1.) • | | ⇠ (2n)! 2 n nodes are roots of orthogonal polynomials • 2 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Change of Interval Gaussian rules are somewhat more difficult to apply than Newton-Cotes rules because weights and nodes are usually derived for some specific interval, such as [ 1, 1] Given interval of integration [a, b] must be transformed into standard interval for which nodes and weights have been tabulated To use quadrature rule tabulated on interval [↵, ], n f(x) dx wif(xi) ↵ ⇡ Z Xi=1 to approximate integral on interval [a, b], b I(g)= g(t) dt Za we must change variable from x in [↵, ] to t in [a, b] Michael T. Heath Scientific Computing 28 / 61 Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Change of Interval,Numerical continued Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Change of Interval, continued Many transformations are possible, but simple linear transformation (b a)x + a b↵ t = Many transformations are possible,↵ but simple linear transformation has advantage of preserving degree of quadrature rule (b a)x + a b↵ t = Generally, the translation is much↵ simpler: • has advantage of preserving⇠ +1 degree of quadrature rule t = a + i (b a) i 2 When ⇠ = 1,Michaelt = T.a Heath. WhenScientific Computing⇠ =1,t = b. 29 / 61 • Here ⇠ , i=1,...,n, are the Gauss points on (-1,1). • i Michael T. Heath Scientific Computing 29 / 61 1 Use of Gauss Quadrature Generally, the translation is much simpler: • ⇠ +1 t = a + i (b a) i 2 When ⇠ = 1, t = a. When ⇠ =1,t = b. • Here ⇠ , i=1,...,n, are the Gauss points on (-1,1). • i So, you simply look up * the ( ⇠ ,w)pairs, • i i use the formula above to get ti, then evaluate (b a) Q = w f(t ) n 2 i i i X (*that is, call a function) 1 Use of Gauss Quadrature ❑ There is a lot of software, in most every language, for computing the nodes and weights for all of the Gauss, Gauss-Lobatto, Gauss-Radau rules (Chebyshev, Legendre, etc.) Numerical Integration Quadrature Rules Numerical Differentiation Adaptive Quadrature Richardson Extrapolation Other Integration Problems Gaussian Quadrature Gaussian quadrature rules have maximal degree and optimal accuracy for number of nodes used Weights are always positive and approximate integral always converges to exact integral as n !1 Unfortunately, Gaussian rules of different orders have no nodes in common (except possibly midpoint), so Gaussian rules are not progressive (except for Gauss-Chebyshev) Thus, estimating error using Gaussian rules of different order requires evaluating integrand function at full set of nodes of both rules Michael T. Heath Scientific Computing 30 / 61 Gauss Quadrature Example Gauss Quadrature Derivation Gauss Quadrature: I Suppose g(x) lP m with zeros x0,x1,...,xm 1. • 2 m m 1 g(x)=Ax + am 1x + + a1x + a0 ··· = A(x x0)(x x1) (x xm 1). ··· lP 2 m Let n