am 205 lecture 10
play

AM 205: lecture 10 Last time: Principal Component Analysis Today: - PowerPoint PPT Presentation

AM 205: lecture 10 Last time: Principal Component Analysis Today: Numerical integration and differentiation Error Estimates: Another Perspective Theorem: If Q n integrates polynomials of degree n exactly, then C n > 0 such that | E n


  1. AM 205: lecture 10 ◮ Last time: Principal Component Analysis ◮ Today: Numerical integration and differentiation

  2. Error Estimates: Another Perspective Theorem: If Q n integrates polynomials of degree n exactly, then ∃ C n > 0 such that | E n ( f ) | ≤ C n min p ∈ P n � f − p � ∞ Proof: For p ∈ P n , we have | I ( f ) − Q n ( f ) | ≤ | I ( f ) − I ( p ) | + | I ( p ) − Q n ( f ) | = | I ( f − p ) | + | Q n ( f − p ) | � n � b � � ≤ d x � f − p � ∞ + | w k | � f − p � ∞ a k =0 ≡ C n � f − p � ∞ where n � C n ≡ b − a + | w k | k =0

  3. Error Estimates Hence a convenient way to compare accuracy of quadrature rules is to compare the polynomial degree they integrate exactly Newton–Cotes of order n is based on polynomial interpolation, hence in general integrates polynomials of degree n exactly 1 1 Also follows from the M n +1 term in the error bound

  4. Runge’s Phenomenon Again... But Newton–Cotes formulae are based on interpolation at equally spaced points Hence they’re susceptible to Runge’s phenomenon, and we expect them to be inaccurate for large n Question: How does this show up in our bound | E n ( f ) | ≤ C n min p ∈ P n � f − p � ∞ ?

  5. Runge Phenomenon Again... Answer: In the constant C n � b Recall that C n ≡ b − a + � n k =0 | w k | , and that w k ≡ a L k ( x )d x 4 1.5 x 10 L 10 1 L 15 0.5 0 −0.5 −1 −1.5 −2 −1 −0.5 0 0.5 1 If the L k “blow up” due to equally spaced points, then C n can also “blow up”

  6. Runge Phenomenon Again... In fact, we know that � n k =0 w k = b − a , why? This tells us that if all the w k are positive, then n n � � C n = b − a + | w k | = b − a + w k = 2( b − a ) k =0 k =0 Hence positive weights = ⇒ C n is a constant, independent of n and hence Q n ( f ) → I ( f ) as n → ∞

  7. Runge Phenomenon Again... But with Newton–Cotes, quadrature weights become negative for n > 8 ( e.g. in example above L 15 ( x ) would clearly yield w 15 < 0) Key point: Newton–Cotes is not useful for large n However, there are two natural ways to get quadrature rules that converge as n → ∞ : ◮ Integrate piecewise polynomial interpolant ◮ Don’t use equally spaced interpolation points We consider piecewise polynomial-based quadrature rules first

  8. Composite Quadrature Rules Integrating piecewise polynomial interpolant = ⇒ composite quadrature rule Suppose we divide [ a , b ] into m subintervals, each of width h = ( b − a ) / m , and x i = a + ih , i = 0 , 1 , . . . , m Then we have: � b � x i m � I ( f ) = f ( x )d x = f ( x )d x a x i − 1 i =1

  9. Composite Trapezoid Rule Composite trapezoid rule: Apply trapezoid rule to each interval, � x i x i − 1 f ( x )d x ≈ 1 i.e. 2 h [ f ( x i − 1 ) + f ( x i )] Hence, m 1 � Q 1 , h ( f ) ≡ 2 h [ f ( x i − 1 ) + f ( x i )] i =1 � 1 2 f ( x 0 ) + f ( x 1 ) + · · · + f ( x m − 1 ) + 1 � = h 2 f ( x m )

  10. Composite Trapezoid Rule Composite trapezoid rule error analysis: E 1 , h ( f ) ≡ I ( f ) − Q 1 , h ( f ) �� x i m � f ( x )d x − 1 � = 2 h [ f ( x i − 1 ) + f ( x i )] x i − 1 i =1 Hence, � x i m � � f ( x )d x − 1 � � � | E 1 , h ( f ) | ≤ 2 h [ f ( x i − 1 ) + f ( x i )] � � � � x i − 1 � � i =1 m h 3 � θ ∈ [ x i − 1 , x i ] | f ′′ ( θ ) | ≤ max 12 i =1 h 3 12 m � f ′′ � ∞ ≤ h 2 12( b − a ) � f ′′ � ∞ =

  11. Composite Simpson Rule We can obtain the composite Simpson rule in the same way Suppose that [ a , b ] is divided into 2 m intervals by the points x i = a + ih , i = 0 , 1 , . . . , 2 m , h = ( b − a ) / 2 m Applying Simpson rule on each interval 2 [ x 2 i − 2 , x 2 i ], i = 1 , . . . , m yields h Q 2 , h ( f ) ≡ 3[ f ( x 0 ) + 4 f ( x 1 ) + 2 f ( x 2 ) + 4 f ( x 3 ) + · · · +2 f ( x 2 m − 2 ) + 4 f ( x 2 m − 1 ) + f ( x 2 m )] 2 Interval of width 2 h

  12. Adaptive Quadrature Composite quadrature rules are very flexible, e.g. we need not choose equally sized intervals Intuitively, we should use smaller intervals where f varies rapidly, and larger intervals where f varies slowly This can be achieved by adaptive quadrature: 1. Initialize to m = 1 (one interval) 2. On each interval, evaluate quadrature rule and estimate quadrature error 3. If error estimate > TOL on interval i , subdivide to get two smaller intervals and return to step 2. Question: How can we estimate the quadrature error on an interval?

  13. Adaptive Quadrature One straightforward way to estimate quadrature error on interval i is to compare to a more refined result for interval i Let I i ( f ) and Q i h ( f ) denote the exact integral and quadrature approximation on interval i , respectively Let ˆ Q i h ( f ) denote a more refined quadrature approximation on interval i , e.g. obtained by subdividing interval i Then for the error on interval i , we have: | I i ( f ) − Q i h ( f ) | ≤ | I i ( f ) − ˆ Q i h ( f ) | + | ˆ Q i h ( f ) − Q i h ( f ) | Then, we suppose we can neglect | I i ( f ) − ˆ Q i h ( f ) | so that we use | ˆ Q i h ( f ) − Q i h ( f ) | as a computable estimator for | I i ( f ) − Q i h ( f ) |

  14. Adaptive Quadrature Python and MATLAB both have quad functions, although with different implementations. MATLAB’s quad function implements an adaptive Simpson rule: >> help quad QUAD Numerically evaluate integral, adaptive Simpson quadrature. Q = QUAD(FUN,A,B) tries to approximate the integral of scalar-valued function FUN from A to B to within an error of 1.e-6 using recursive adaptive Simpson quadrature. Next we consider the second approach to developing more accurate quadrature rules: unevenly spaced quadrature points

  15. Gauss Quadrature Recall that we can compare accuracy of quadrature rules based on the polynomial degree that is integrated exactly So far, we haven’t been very creative with our choice of quadrature points: Newton–Cotes ⇐ ⇒ equally spaced More accurate quadrature rules can be derived by choosing the x i to maximize poly. degree that is integrated exactly Resulting family of quadrature rules is called Gauss quadrature

  16. Gauss Quadrature Intuitively, with n + 1 quadrature points and n + 1 quadrature weights we have 2 n + 2 parameters to choose Hence we might hope to integrate a poly. with 2 n + 2 parameters, i.e. of degree 2 n + 1 It can be shown that this is possible = ⇒ Gauss quadrature Again the idea is to integrate a polynomial interpolant, but we choose a specific set of interpolation points: Gauss quad. points are roots of a Legendre polynomial 3 3 Adrien-Marie Legendre, 1752-1833, French mathematician

  17. Gauss Quadrature Briefly, Legendre polynomials { P 0 , P 1 , . . . , P n } form an orthogonal basis for P n in the “ L 2 inner-product” � 1 � 2 2 n +1 , m = n P m ( x ) P n ( x )d x = 0 , m � = n − 1

  18. Gauss Quadrature As with Chebyshev polys, Legendre polys satisfy a 3-term recurrence relation P 0 ( x ) = 1 P 1 ( x ) = x ( n + 1) P n +1 ( x ) = (2 n + 1) xP n ( x ) − nP n − 1 ( x ) 1 0.8 0.6 0.4 0.2 0 −0.2 −0.4 −0.6 −0.8 −1 −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 The first six Legendre polynomials

  19. Gauss Quadrature Hence, can find the roots of P n ( x ) and derive the n -point Gauss quad. rule in the same way as for Newton–Cotes: Integrate the Lagrange interpolant! Gauss quadrature rules have been extensively tabulated for x ∈ [ − 1 , 1]: Number of points Quadrature points Quadrature weights 1 0 2 √ √ 2 − 1 / 3 , 1 / 3 1 , 1 � � 3 3 / 5 , 0 , 3 / 5 5 / 9 , 8 / 9 , 5 / 9 − . . . . . . . . . Key point: Gauss quadrature weights are always positive, hence Gauss quadrature converges as n → ∞ !

  20. Gauss Quadrature Points Points cluster toward ± 1, prevents Runge’s phenomenon! 1 1 0.8 0.8 0.6 0.6 0.4 0.4 0.2 0.2 0 0 −0.2 −0.2 −0.4 −0.4 −0.6 −0.6 −0.8 −0.8 −1 −1 −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 5 points 10 points 1 1 0.8 0.8 0.6 0.6 0.4 0.4 0.2 0.2 0 0 −0.2 −0.2 −0.4 −0.4 −0.6 −0.6 −0.8 −0.8 −1 −1 −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 15 points 20 points

  21. Generalization Suppose we wish to evaluate exactly integrals of the form � 1 w ( x ) f ( x ) dx . − 1 Then we can calculate quadrature based on polynomials u k that are orthogonal with respect to the inner product � 1 � u j , u k � = w ( x ) u j ( x ) u k ( x ) dx . − 1 A typical example case is 1 w ( x ) = √ 1 − x 2 . Orthogonality relation is then � 1 � u j , u k � = w ( x ) u j ( x ) u k ( x ) dx . − 1 Try the Chebyshev polynomials u j ( x ) = T j ( x ) = cos( j cos − 1 x ).

  22. Generalization Using the substitution x = cos θ , � 1 1 1 − x 2 cos( j cos − 1 x ) cos( k cos − 1 x ) dx � T j , T k � = √ (1) − 1 � π 1 √ = cos j θ cos k θ (sin θ d θ ) (2) 1 − cos 2 θ 0 � π = cos j θ cos k θ d θ. (3) 0 Using the Fourier orthogonality relations, � T j , T k � = 0 for j � = k , so the Chebyshev polynomials are orthogonal with respect to this weight function. Hence the roots of the Chebyshev polynomials can be used to construct a quadrature formula for this w ( x ). This is just one example of many possible generalizations to Gauss quadrature.

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend