
Elements of Numerical Integration: Methods and Examples
Learn about numerical integration techniques like the Trapezoidal Rule, Simpson's Rule, and the Midpoint Rule for approximating definite integrals of functions without explicit antiderivatives. Practical examples are provided to demonstrate how to apply these methods effectively.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Sec:4.3 Elements of Numerical Integration
Sec:4.3 Elements of Numerical Integration How to integrate a definite integral of a function that has no explicit antiderivative or whose antiderivative is not easy to obtain. ? ? ? ?? ?
Sec:4.3 Elements of Numerical Integration The Trapezoidal Rule ? ?? ??? ? ? ? ?? =? ?? ?? + ? ?? ? = ? ? Simpson s Rule ? ?? ????? ? ? ?? =? ?? ?? + ?? ?? + ?(??) ? = (? ?)/2 The midpoint Rule ? = ?(?) 1) How to use 2) MATLAB 3) Derivation ? ? ? ?? = ??? ?? +?? ?? ? ? ?0= (? + ?)/2 ?0 = (? ?)/2 ? ?
Sec:4.3 Elements of Numerical Integration Example The Trapezoidal Rule Approximate the integral using the Trapezoidal rule 2 ? ?? ??? ? ? ? ?? =? ?? ?? + ? ?? ? ?2?? = ? ? 0 ? ? = ?2, = 2,? = 0,? = 2 2 ?2?? ? ?? ? ?? + ? ?? 0 ? ?? ? ?? + ? ?? ? ?(?) ? + ? ?
Sec:4.3 Elements of Numerical Integration Example Simpson s Rule Approximate the integral using the Simpson s rule ? ?? ????? ? ? ?? =? ?? ?? + ?? ?? + ?(??) 2 ? ?2?? = (? ?)/2 0 ? ? = ?2, = 1,?0= 0,?1= 1,?2= 2 2 ? ?? ?? + ?? ?? + ? ?? ? ?? ? + ?? ? + ? ? ?2?? 0 ?1= 1 ?2= 2 ?0= 0 ? ?? + ? + ? ? It is exact ?
Sec:4.3 Elements of Numerical Integration Example The midpoint Rule Approximate the integral using the midpoint rule ? ? ? ?? = ??? ?? +?? ?? ? ? 4 ? ?0= (? + ?)/2 sin(?)?? = (? ?)/2 0 ? = ?(?) ? ? = sin(?), =? 8,? = 0,? =? 4 ?0=? 8, ?0 ? ? ? 4 ?(? ? 8 ? =? ?0=? 8) ? sin(?)?? ? = 0 4 8 0 ?.????????
Sec:4.3 Elements of Numerical Integration The Trapezoidal Rule f = @(x) x^2; a=0; b=2; h=b-a; intg = (h/2)*(f(a)+f(b)) ? ?? ??? ? ? ? ?? =? ?? ?? + ? ?? ? = ? ? Simpson s Rule f = @(x) x^2; a=0; b=2; h=(b-a)/2; x=a:h:b; intg = (h/3)*(f(x(1))+4*f(x(2))+f(x(3))) ? ?? ????? ? ? ?? =? ?? ?? + ?? ?? + ?(??) ? = (? ?)/2 The midpoint Rule f = @(x) sin(x); a=0; b=pi/4; h=(b-a)/2; x0= =(b+a)/2; intg = 2*h*f(x0) ? ? ? ?? = ??? ?? +?? ?? ? ? ?0= (? + ?)/2 = (? ?)/2
Sec:4.3 Elements of Numerical Integration Example Simpson s Rule = (? ?)/2 Approximate the integral using the Simpson s rule ? ?? ????? ? ? ?? =? ?? ?? + ?? ?? + ?(??) 2 ? ?2?? Definition 0 The degree of precision (or accuracy) of integral formula is n if and only if the error is zero for all polynomials ?0? = 1,?1? = ?, ?2? = ?2, ,??? = ?? but is not zero for the polynomial ??+1? = ??+1 ? ? = ?2, = 1,?0= 0,?1= 1,?2= 2 2 ? ?? ?? + ?? ?? + ? ?? ?2?? 0 ? ? ?? ? + ?? ? + ? ? It is exact The approximation from Simpson's rule is exact because its truncation error involves ??? , which is identically 0 when ? ? = ?2 ? Remark the degree of precision of Simpson s rule is 3. The integral of any polynomial of degree 3 or less is exact when using Simpson s rule
Sec:4.3 Elements of Numerical Integration Definition Definition Find the degree of precision of the formula ? The degree of precision (or accuracy) of integral formula is n if and only if the error is zero for all polynomials ?0? = 1,?1? = ?, ?2? = ?2, ,??? = ?? but is not zero for the polynomial ??+1? = ??+1 ? ? ?(?)?? ? + ?( ?) ? ? solution Use the formula: Exact: function: ? ? ? ? ? = ? ??? = ? ? + ? = ? + ? = ? ? ? ? How to find degree of precision Exact: function: ? Use the formula: ? ? ? ? ? ? = ? ??? = ? ? + ? = ?+ = ? ? ? ? ? ? ? ? = ? ? ??? ??? ? ???? =? ? ? =? ?+? ?=? ? ? ? ? = ?? ? + ? ? ? ? ? ? ? ? ? ? = ? ??? ??? ? ? ? ? ? ???? = ? ? ? = ?? ? + ? = ?+ = ? ? ? ? ? ? ? ? ? ? ? = ?? ? ???? ???? ???? =? ? ? =? ?+? ?=? ? ? = ?? ?? + ? ? ? ? ? ? ? the degree of precision is 3.
Sec:4.3 Elements of Numerical Integration Derivation Weighted Mean Value Theorem for Integrals The Trapezoidal Rule Suppose f C[a, b], the Riemann integral of g exists on [a, b], and g(x) does not change sign on [a, b]. Then there exists a number c in (a, b) with ? ?? ??? ? ? ? ?? =? ?? ?? + ? ?? ? = ? ? ? ? ? ? ? ? ?? = ?(?) ? ? ?? ? ?
Sec:4.3 Elements of Numerical Integration Derivation for The Trapezoidal Rule ?1= ? using first Lagrange polynomials ?0= ? = ? ? ? ? = ??? + ??(?) ? ? = ? ????(?) + ? ????(?) +? ? (? ??)(? ??) ?! +? ? ? ?? ?? ?? ? ?? ?? ?? ? ? = ? ?? + ? ?? (? ??)(? ??) ?! ? ?? ?? ??? ? (? ??)(? ??) dx ? ? ?? = ? ?? ??? ?? + ? ?? ??? ?? + ?! ? ?? ?? ?? ? ??? ? ? ? ?? =1 (? ??)(? ??) dx 2 ? ?? + ? ?? + ?! ? ?? ?? ??? ?? ?? ???? = ?? ?? ? ? ? ???? = ? ? ?? ? = ? ? ? ???=? ??? ?? = ? ?? ? ? ?? ?? ?? ?? ?? ??? ?? ?? ???? =? ?? ?? ? ? ???? =? ? ?? ? ? ? ? ??? ? =? ??? ?? = ? ?? = ?? ? ?? ?? ??
Sec:4.3 Elements of Numerical Integration Error for The Trapezoidal Rule The Trapezoidal Rule Weighted Mean Value Theorem for Integrals Suppose f C[a, b], the Riemann integral of g exists on [a, b], and g(x) does not change sign on [a, b]. Then there exists a number c in (a, b) with ? ??? ? ? ? ?? =1 (? ??)(? ??) dx 2 ? ?? + ? ?? + ?! ? ?? ??? ? ?? (? ??)(? ??) dx =? ? ? ? ?(?) (? ??)(? ??) dx ? ?? ? ? ? ? ?? = ?(?) ? ? ?? ?! ? ? ?? The Weighted Mean Value Theorem for Integrals ?? =? ? =? ? ?? == ?? (? ??)(? ??) dx ??? ? ? ? ? ?? The Trapezoidal Rule ? ?? ??? ? ? ? ?? =1 2 ? ?? + ? ?? ?
Sec:4.3 Elements of Numerical Integration Derivation Simpson s Rule ? ?? ????? ? ? ?? =? ?? ?? + ?? ?? + ?(??) ? = (? ?)/2
Sec:4.3 Elements of Numerical Integration Simpson s Rule Derivation ?1= ?0+ ?2= ? ?0= ? using second Lagrange polynomials ? ? = ??? + ??(?) ? ? = ? ????(?) + ? ????(?) + ? ????(?) +? ? (? ??)(? ??) (? ??) ?! ? ?? ?? ?? ??? ? (? ??)(? ??)(? ??)dx ? ? ?? = ? ?? ??? ?? + ? ?? ??? ?? + ? ?? ??? ?? + ?! ? ?? ?? ?? ?? ??? ? (? ??)(? ??)(? ??)dx = ??? ?? + ??? ?? + ??? ?? + ?! ?? ?? ?? ?? ??? ?? =? ??? ?? =?? ??? ?? =? ??= ??= ??= ? ? ? ?? ?? ?? Simpson s Rule ? ??? ? ? ? ?? =? (? ??)(? ??)(? ??)dx ?? ?? + ?? ?? + ? ?? + ?! ? ?? Deriving Simpson s rule in this manner, however, provides only an ?( 4) error term involving ? (?).
Sec:4.3 Elements of Numerical Integration approaching the problem in another way, a higher-order term ?1= ?0+ ?2= ? ?0= ? Third Taylor polynomial ? ? = ? ?1 + ? (?1) ? ?1 +? (?1) 2+? (?1) 3+?(?)(?) ? ? ?1 ? ?1 ? ?? 2 6 ?? ?2 ?2 ? ?1 + ? (?1) ? ?1 +? (?1) 2+? (?1) 3?? ? ? ?? = ? ?1 ? ?1 2 6 ?0 ?0 ???(?)(?) ?? ??? + ? ?? ?? ?? ?2? (?1) ? (??) ? ?? ?? = ? 3?? = 0 ? ?1 6 ?? ?0 ?2 ?2 ???(?)(?) ?? ? ?1 +? (?1) 2?? + ??? ? ? ?? = ? ?1 ? ?? 2 ?0 ?0 ??
Sec:4.3 Elements of Numerical Integration ?2 ?2 ???(?)(?) ?? ? ?1 +? (?1) 2?? + ??? ? ? ?? = ? ?1 ? ?? 2 ?0 ?0 ?? ???(?)(?) ?? = 2 ? ?1 + 3 ??? 3? ?1 + ? ?? ?? ?? ????(??) ? ?? =? ?? ?? ?? + ?(??) Using centered difference formaula for ?? ?? ????(??) ???(?)(?) ?? = 2 ? ?1 + 3 ? ?? ?? ?? + ?(??) ?? ??? + ? ?? 3 ?? ?? ????(??) ???(?)(?) ?? = 2 ? ?1 + 3? ?? ?? ?? + ?(??) ??? + ? ?? 3 ?? 3?? ?? + ? ?? ?? ?? + ?(??) ?? ???(?)(?) ?? = ????(??) + ??? ? ?? ?? ?2 4?? = The Weighted Mean Value Theorem for Integrals ? ?1 ?0 ?2 ?? ????(??) + ?(?)(?) = 5 =2 5 ? ?1 5 ?? ??? ? ??+ ?? ??+ ?(??) ?? = ? ?? 3 5 ?? ?0 ?? ??????+ ?? ????? ?? ????? = ? ??+ ?? ??+ ?(??) 3 = ? ??+ ?? ??+ ?(??) 3
Sec:4.3 Elements of Numerical Integration Notice that in each instance Simpson s Rule is significantly superior. Simpson s Rule The Trapezoidal Rule ? ? ? ? ?? =? ? ? ?? =? ?? ?? + ?? ?? + ?(??) ?? ?? + ? ?? ? ? ?? ??? ? ?? ?????
Sec:4.3 Elements of Numerical Integration The Trapezoidal Rule ? ?? ??? ? ? ? ?? =? ?? ?? + ? ?? ? The Trapezoidal and Simpson's rules are examples of a class of methods known as closed Newton-cotes methods. = ? ? Simpson s Rule In the formula information in the endpoints are used ? ?? ????? ? ? ?? =? ?? ?? + ?? ?? + ?(??) ? = (? ?)/2 The midpoint Rule The midpoint rules is an example of a class of methods known as open Newton-cotes methods. ? ? ? ?? = ??? ?? +?? ?? ? ? In the formula information in the endpoints are not used ?0= (? + ?)/2 = (? ?)/2
Sec:4.3 Elements of Numerical Integration The Trapezoidal Rule (2pts) Simpson s Rule (3pts) ? ? ?? ??? ? ?? ????? ? ? ?? =? ? ? ?? =? ?? ?? + ? ?? ?? ?? + ?? ?? + ?(??) ? ? ? =? ? ? ? ? ????(?) + + ? ????(?) ? ? ? ? ? ????(?) ?=0 ? ?? ?? ? ? ?? ? ?? ??(?)?? ?0 ?? ?=0 ? ?? ? ? ?? ??? ?? ?0 ?=0 Closed Newton-Cotes Formulas The (n+1)-point closed Newton-Cotes formula
Sec:4.3 Elements of Numerical Integration Closed Newton-Cotes Formulas The (n+1)-point closed Newton-Cotes formula ? ?? ? ?? ?? (? ??) (?? ??)?? ? where ? ? ?? = ??? ?? + ??= ??(?)?? = ?0 ?? ?? ?=? ? ? ?=0 Theorem 4.2 There exists ? ?,? such that ? is odd ? ? is even ? ? = ?+2??+1(?) ? + 1 ! ? = ?+3??+2(?) ? + 2 ! ? (? 1) ? ? ?? ?2(? 1) ? ? ?? 0 0 the degree of precision is ? the degree of precision is ? + 1 Simpson s Rule (3pts, n=2) The Trapezoidal Rule (2pts, n=1) ? ? ?? ??? ? ?? ????? ? ? ?? =? ? ? ?? =? ?? ?? + ? ?? ?? ?? + ?? ?? + ?(??) ? ?
Sec:4.3 Elements of Numerical Integration n=1 : The Trapezoidal Rule The (n+1)-point closed Newton-Cotes formula ? ? ?? ??? ? ?? ? ? ?? =? ?? ?? + ? ?? ??? ?? +? ? ? ?? = ? ?0 ?=0 n=2 : Simpson s Rule It is called closed because the endpoints are included as nodes. ? ?? ?? + ?? ?? + ?(??) ?? ? ? ?? =? ????? ? n = 3: Simpson s Three-Eighths rule ? ? ?? + ?? ?? + ?? ?? + ?(??) ??? ? ? ?? =?? ????? ? ? n = 4: ? ???? ?? + ??? ?? + ??? ?? + ??? ?? + ??(??) ??? ? ? ?? =?? ?????? ?
Sec:4.3 Elements of Numerical Integration Open Newton-Cotes Formulas ? =? ? ? + ? The open Newton-Cotes formulas do not include the endpoints as nodes. Open Newton-Cotes Formulas ? ? ??+1 ??+? ??+? (? ??) (?? ??)?? ? where ? ? ?? = ??? ?? + ??= ??(?)?? = ? 1 ? ? ? ? ?=? ? ? ?=0
Sec:4.3 Elements of Numerical Integration Open Newton-Cotes Formulas ? ? ??+1 ??+? ??+? (? ??) (?? ??)?? ? where ? ? ?? = ??? ?? + ??= ??(?)?? = ? 1 ? ? ? ? ?=? ? ? ?=0 Theorem 4.2 There exists ? ?,? such that ? is odd ? ? is even ? ?+1 = ?+2??+1(?) ? + 1 ! ?+1 = ?+3??+2(?) ? + 2 ! ? (? 1) ? ? ?? ?2(? 1) ? ? ?? 1 1 n=1 : n=0 : The midpoint Rule ? ? ??? ? ? ?? =?? ? ? ?? = ??? ?? +?? ? ? ? ?? + ? ?? ?? ? ? ? ? ?
Sec:4.3 Elements of Numerical Integration Open Newton-Cotes Formulas n=0 : The midpoint Rule ? ? ??+1 ? ? ?? = ??? ?? +?? ??? ?? +? ?? ? ? ? ?? = ? 1 ? ?=0 n=1 : ? ??? ? ? ?? =?? ? ? ? ?? + ? ?? ? ? ? n = 2: ? ???? ?? ? ? ?? =?? ??? ?? ?? ? ?? + ?? ?? ? ? n = 3: ? ???? ?????? ? ? ?? =?? ????? ?? + ? ?? + ? ?? + ??? ?? ?