Elements of Numerical Integration 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 𝑎 𝑏 𝑥 0 𝒚=𝒇(𝒙) How to use MATLAB Derivation 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 =𝟐𝒉𝒇 𝒙 𝟎 + 𝒉 𝟑 𝟑 𝒇 ′′ 𝝃 ℎ=(𝑏−𝑎)/2 𝑥 0 =(𝑏+𝑎)/2
Sec:4.3 Elements of Numerical Integration Example The Trapezoidal Rule Approximate the integral using the Trapezoidal rule 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 = 𝒉 𝟐 𝒇 𝒙 𝟎 +𝒇 𝒙 𝟏 − 𝒉 𝟑 𝟏𝟐 𝒇 ′′ 𝝃 0 2 𝑥 2 𝑑𝑥 ℎ=𝑏−𝑎 𝑓 𝑥 = 𝑥 2 ,ℎ=2, 𝑎=0,𝑏=2 0 2 𝑥 2 𝑑𝑥 ≈ 𝟏 𝟐 𝒉 𝒇 𝒙 𝟎 +𝒇 𝒙 𝟏 ≈ 𝟏 𝟐 𝒉 𝒇 𝒙 𝟎 +𝒇 𝒙 𝟏 ≈ 𝟏 𝟐 (𝟐) 𝟎+𝟒 ≈𝟒
Sec:4.3 Elements of Numerical Integration Example Simpson’s Rule Approximate the integral using the Simpson’s rule 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 = 𝒉 𝟑 𝒇 𝒙 𝟎 +𝟒𝒇 𝒙 𝟏 +𝒇( 𝒙 𝟐 ) − 𝒉 𝟓 𝟗𝟎 𝒇 𝟒 𝝃 ∗ 0 2 𝑥 2 𝑑𝑥 ℎ=(𝑏−𝑎)/2 𝑓 𝑥 = 𝑥 2 ,ℎ=1, 𝑥 0 =0, 𝑥 1 =1, 𝑥 2 =2 0 2 𝑥 2 𝑑𝑥 ≈ 𝒉 𝟑 𝒇 𝒙 𝟎 +𝟒𝒇 𝒙 𝟏 +𝒇 𝒙 𝟐 ≈ 𝟏 𝟑 𝒇 𝟎 +𝟒𝒇 𝟏 +𝒇 𝟐 𝑥 0 =0 𝑥 1 =1 𝑥 2 =2 ≈ 𝟏 𝟑 𝟎+𝟒+𝟒 ≈ 𝟖 𝟑 It is exact
Sec:4.3 Elements of Numerical Integration Example The midpoint Rule Approximate the integral using the midpoint rule 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 =𝟐𝒉𝒇 𝒙 𝟎 + 𝒉 𝟑 𝟑 𝒇 ′′ 𝝃 0 𝜋 4 sin(𝑥) 𝑑𝑥 ℎ=(𝑏−𝑎)/2 𝑥 0 =(𝑏+𝑎)/2 𝑎 𝑏 𝑥 0 𝒚=𝒇(𝒙) 𝑓 𝑥 =sin(𝑥),ℎ= 𝜋 8 , 𝑎=0, 𝑏= 𝜋 4 𝑥 0 = 𝜋 8 , 0 𝜋 4 sin(𝑥)𝑑𝑥 ≈ 𝟐( 𝜋 8 ) 𝒇 𝜋 8 𝑎=0 𝑥 0 = 𝜋 8 𝑏= 𝜋 4 ≈𝟎.𝟑𝟎𝟎𝟓𝟓𝟖𝟖𝟕
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) 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 =𝟐𝒉𝒇 𝒙 𝟎 + 𝒉 𝟑 𝟑 𝒇 ′′ 𝝃 ℎ=(𝑏−𝑎)/2 𝑥 0 =(𝑏+𝑎)/2
Sec:4.3 Elements of Numerical Integration Example Simpson’s Rule ℎ=(𝑏−𝑎)/2 Approximate the integral using the Simpson’s rule 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 = 𝒉 𝟑 𝒇 𝒙 𝟎 +𝟒𝒇 𝒙 𝟏 +𝒇( 𝒙 𝟐 ) − 𝒉 𝟓 𝟗𝟎 𝒇 𝟒 𝝃 ∗ 0 2 𝑥 2 𝑑𝑥 Definition 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 0 2 𝑥 2 𝑑𝑥 ≈ 𝒉 𝟑 𝒇 𝒙 𝟎 +𝟒𝒇 𝒙 𝟏 +𝒇 𝒙 𝟐 ≈ 𝟏 𝟑 𝒇 𝟎 +𝟒𝒇 𝟏 +𝒇 𝟐 ≈ 𝟖 𝟑 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
How to find degree of precision Sec:4.3 Elements of Numerical Integration Definition Definition 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 Find the degree of precision of the formula −𝟏 𝟏 𝒇(𝒙) 𝒅𝒙≈𝒇 − 𝟑 𝟑 +𝒇( 𝟑 𝟑 ) solution function: Exact: Use the formula: −𝟏 𝟏 𝟏 𝒅𝒙=𝟐 𝒇 − 𝟑 𝟑 +𝒇 𝟑 𝟑 =𝟏+𝟏=𝟐 𝒇 𝒙 =𝟏 How to find degree of precision function: Exact: Use the formula: −𝟏 𝟏 𝒙 𝒅𝒙=𝟎 𝒇 − 𝟑 𝟑 +𝒇 𝟑 𝟑 =− 𝟑 𝟑 + 𝟑 𝟑 =𝟎 𝒇 𝒙 =𝒙 𝒇 𝒙 =𝟏 𝒂 𝒃 𝟏 𝒅𝒙 𝒂 𝒃 𝟏 𝒅𝒙 −𝟏 𝟏 𝒙 𝟐 𝒅𝒙 = 𝟐 𝟑 𝒇 − 𝟑 𝟑 +𝒇 𝟑 𝟑 = 𝟏 𝟑 + 𝟏 𝟑 = 𝟐 𝟑 𝒇 𝒙 = 𝒙 𝟐 𝒇 𝒙 =𝒙 𝒂 𝒃 𝒙 𝒅𝒙 𝒂 𝒃 𝒙 𝒅𝒙 −𝟏 𝟏 𝒙 𝟑 𝒅𝒙 =𝟎 𝒇 − 𝟑 𝟑 +𝒇 𝟑 𝟑 =− 𝟑 𝟗 + 𝟑 𝟗 =𝟎 𝒇 𝒙 = 𝒙 𝟑 𝒇 𝒙 = 𝒙 𝟐 𝒂 𝒃 𝒙 𝟐 𝒅𝒙 𝒂 𝒃 𝒙 𝟐 𝒅𝒙 −𝟏 𝟏 𝒙 𝟒 𝒅𝒙 = 𝟐 𝟓 𝒇 − 𝟑 𝟑 +𝒇 𝟑 𝟑 = 𝟏 𝟗 + 𝟏 𝟗 = 𝟐 𝟗 𝒇 𝒙 = 𝒙 𝟒 ⋮ ⋮ ⋮ the degree of precision is 3.
Derivation Sec:4.3 Elements of Numerical Integration 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 The Trapezoidal Rule 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 = 𝒉 𝟐 𝒇 𝒙 𝟎 +𝒇 𝒙 𝟏 − 𝒉 𝟑 𝟏𝟐 𝒇 ′′ 𝝃 ℎ=𝑏−𝑎 𝑎 𝑏 𝑓 𝑥 𝑔 𝑥 𝑑𝑥=𝒇(𝒄) 𝑎 𝑏 𝑔 𝑥 𝑑𝑥
Sec:4.3 Elements of Numerical Integration Derivation for The Trapezoidal Rule using first Lagrange polynomials 𝑥 0 =𝑎 𝑥 1 =𝑏 ℎ=𝑏−𝑎 𝑓 𝑥 = 𝒑 𝟏 𝒙 + 𝑹 𝟏 (𝒙) 𝑓 𝑥 =𝒇 𝒙 𝟎 𝑳 𝟎 (𝒙)+𝒇 𝒙 𝟏 𝑳 𝟏 (𝒙)+ 𝒇 ′′ 𝝃 𝟐! (𝒙− 𝒙 𝟎 )(𝒙− 𝒙 𝟏 ) 𝑓 𝑥 =𝒇 𝒙 𝟎 𝒙− 𝒙 𝟏 𝒙 𝟎 − 𝒙 𝟏 +𝒇 𝒙 𝟏 𝒙− 𝒙 𝟎 𝒙 𝟏 − 𝒙 𝟎 + 𝒇 ′′ 𝝃 𝟐! (𝒙− 𝒙 𝟎 )(𝒙− 𝒙 𝟏 ) 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 =𝒇 𝒙 𝟎 𝒙 𝟎 𝒙 𝟏 𝑳 𝟎 𝒙 𝒅𝒙 +𝒇 𝒙 𝟏 𝒙 𝟎 𝒙 𝟏 𝑳 𝟏 𝒙 𝒅𝒙+ 𝒙 𝟎 𝒙 𝟏 𝒇 ′′ 𝝃 𝟐! (𝒙− 𝒙 𝟎 )(𝒙− 𝒙 𝟏 ) dx 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 = 1 2 ℎ 𝒇 𝒙 𝟎 +𝒇 𝒙 𝟏 + 𝒙 𝟎 𝒙 𝟏 𝒇 ′′ 𝝃 𝟐! (𝒙− 𝒙 𝟎 )(𝒙− 𝒙 𝟏 ) dx 𝒙 𝟎 𝒙 𝟏 𝑳 𝟎 𝒙 𝒅𝒙= 𝒙 𝟎 𝒙 𝟏 𝒙− 𝒙 𝟏 𝒙 𝟎 − 𝒙 𝟏 𝒅𝒙= 𝟏 −𝒉 𝒙 𝟎 𝒙 𝟏 𝒙− 𝒙 𝟏 𝒅𝒙= − 𝟏 𝒉 𝒙− 𝒙 𝟏 𝟐 𝟐 𝒙 𝟎 𝒙 𝟏 = − 𝟏 𝒉 𝟎− 𝟏 𝟐 𝒉 𝟐 = 𝟏 𝟐 𝒉 𝒙 𝟎 𝒙 𝟏 𝑳 𝟏 𝒙 𝒅𝒙= 𝒙 𝟎 𝒙 𝟏 𝒙− 𝒙 𝟎 𝒙 𝟏 − 𝒙 𝟎 𝒅𝒙= 𝟏 𝒉 𝒙 𝟎 𝒙 𝟏 𝒙− 𝒙 𝟎 𝒅𝒙= 𝟏 𝒉 𝒙− 𝒙 𝟎 𝟐 𝟐 𝒙 𝟎 𝒙 𝟏 = 𝟏 𝒉 𝟏 𝟐 𝒉 𝟐 −𝟎 = 𝟏 𝟐 𝒉
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 2 ℎ 𝒇 𝒙 𝟎 +𝒇 𝒙 𝟏 + 𝒙 𝟎 𝒙 𝟏 𝒇 ′′ 𝝃 𝟐! (𝒙− 𝒙 𝟎 )(𝒙− 𝒙 𝟏 ) dx 𝒙 𝟎 𝒙 𝟏 𝒇 ′′ 𝝃 𝟐! (𝒙− 𝒙 𝟎 )(𝒙− 𝒙 𝟏 ) dx = 𝟏 𝟐 𝒙 𝟎 𝒙 𝟏 𝒇 ′′ 𝝃(𝒙) (𝒙− 𝒙 𝟎 )(𝒙− 𝒙 𝟏 ) dx 𝑎 𝑏 𝑓 𝑥 𝑔 𝑥 𝑑𝑥=𝑓(𝑐) 𝑎 𝑏 𝑔 𝑥 𝑑𝑥 The Weighted Mean Value Theorem for Integrals = 𝒇 ′′ 𝝃 𝟐 𝒙 𝟎 𝒙 𝟏 (𝒙− 𝒙 𝟎 )(𝒙− 𝒙 𝟏 ) dx = 𝒇 ′′ 𝝃 𝟐 − 𝒉 𝟑 𝟔 ==− 𝒉 𝟑 𝟏𝟐 𝒇 ′′ 𝝃 The Trapezoidal Rule 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 = 1 2 ℎ 𝒇 𝒙 𝟎 +𝒇 𝒙 𝟏 − 𝒉 𝟑 𝟏𝟐 𝒇 ′′ 𝝃
Derivation Sec:4.3 Elements of Numerical Integration Simpson’s Rule 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 = 𝒉 𝟑 𝒇 𝒙 𝟎 +𝟒𝒇 𝒙 𝟏 +𝒇( 𝒙 𝟐 ) − 𝒉 𝟓 𝟗𝟎 𝒇 𝟒 𝝃 ∗ ℎ=(𝑏−𝑎)/2
Sec:4.3 Elements of Numerical Integration Simpson’s Rule Derivation using second Lagrange polynomials 𝑥 0 =𝑎 𝑥 1 = 𝑥 0 +ℎ 𝑥 2 =𝑏 𝑓 𝑥 = 𝒑 𝟏 𝒙 + 𝑹 𝟏 (𝒙) 𝑓 𝑥 =𝒇 𝒙 𝟎 𝑳 𝟎 (𝒙)+𝒇 𝒙 𝟏 𝑳 𝟏 (𝒙)+𝒇 𝒙 𝟐 𝑳 𝟐 (𝒙)+ 𝒇 ′′′ 𝝃 𝟑! (𝒙− 𝒙 𝟎 )(𝒙− 𝒙 𝟏 ) (𝒙− 𝒙 𝟐 ) 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 =𝒇 𝒙 𝟎 𝒙 𝟎 𝒙 𝟐 𝑳 𝟎 𝒙 𝒅𝒙 +𝒇 𝒙 𝟏 𝒙 𝟎 𝒙 𝟐 𝑳 𝟏 𝒙 𝒅𝑥+𝒇 𝒙 𝟐 𝒙 𝟎 𝒙 𝟐 𝑳 𝟐 𝒙 𝒅𝒙+ 𝒙 𝟎 𝒙 𝟐 𝒇 ′′′ 𝝃 𝟑! (𝒙− 𝒙 𝟎 )(𝒙− 𝒙 𝟏 )(𝒙− 𝒙 𝟐 )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 𝑥 0 =𝑎 𝑥 1 = 𝑥 0 +ℎ 𝑥 2 =𝑏 Third Taylor polynomial 𝑓 𝑥 =𝑓 𝑥 1 + 𝑓 ′ ( 𝑥 1 ) 𝑥− 𝑥 1 + 𝑓 ′ ′( 𝑥 1 ) 2 𝑥− 𝑥 1 2 + 𝑓 ′ ′′( 𝑥 1 ) 6 𝑥− 𝑥 1 3 + 𝒇 (𝟒) (𝝃) 𝟐𝟒 𝒙− 𝒙 𝟏 𝟒 𝑥 0 𝑥 2 𝑓 𝑥 𝑑𝑥 = 𝑥 0 𝑥 2 𝑓 𝑥 1 + 𝑓 ′ ( 𝑥 1 ) 𝑥− 𝑥 1 + 𝑓 ′ ′( 𝑥 1 ) 2 𝑥− 𝑥 1 2 + 𝑓 ′ ′′( 𝑥 1 ) 6 𝑥− 𝑥 1 3 𝑑𝑥 + 𝒙 𝟎 𝒙 𝟐 𝒇 (𝟒) (𝝃) 𝟐𝟒 𝒙− 𝒙 𝟏 𝟒 𝒅𝒙 𝒙 𝟎 𝒙 𝟐 𝒇 ′ ( 𝒙 𝟏 ) 𝒙− 𝒙 𝟏 𝒅𝒙 =𝟎 𝑥 0 𝑥 2 𝑓 ′ ′′( 𝑥 1 ) 6 𝑥− 𝑥 1 3 𝑑𝑥=0 𝑥 0 𝑥 2 𝑓 𝑥 𝑑𝑥 = 𝑥 0 𝑥 2 𝑓 𝑥 1 + 𝑓 ′ ′( 𝑥 1 ) 2 𝑥− 𝑥 1 2 𝑑𝑥 + 𝒙 𝟎 𝒙 𝟐 𝒇 (𝟒) (𝝃) 𝟐𝟒 𝒙− 𝒙 𝟏 𝟒 𝒅𝒙
Sec:4.3 Elements of Numerical Integration 𝑥 0 𝑥 2 𝑓 𝑥 𝑑𝑥 = 𝑥 0 𝑥 2 𝑓 𝑥 1 + 𝑓 ′ ′( 𝑥 1 ) 2 𝑥− 𝑥 1 2 𝑑𝑥 + 𝒙 𝟎 𝒙 𝟐 𝒇 (𝟒) (𝝃) 𝟐𝟒 𝒙− 𝒙 𝟏 𝟒 𝒅𝒙 =2ℎ𝑓 𝑥 1 + ℎ 3 3 𝑓′′ 𝑥 1 + 𝒙 𝟎 𝒙 𝟐 𝒇 (𝟒) (𝝃) 𝟐𝟒 𝒙− 𝒙 𝟏 𝟒 𝒅𝒙 𝒇 ′′ 𝒙 𝟏 = 𝒇 𝒙 𝟎 −𝟐𝒇 𝒙 𝟏 +𝒇( 𝒙 𝟐 ) 𝒉 𝟐 − 𝒉 𝟐 𝟏𝟐 𝒇 𝟒 ( 𝝃 𝟐 ) Using centered difference formaula for =2ℎ𝑓 𝑥 1 + ℎ 3 3 𝒇 𝒙 𝟎 −𝟐𝒇 𝒙 𝟏 +𝒇( 𝒙 𝟐 ) 𝒉 𝟐 − 𝒉 𝟐 𝟏𝟐 𝒇 𝟒 ( 𝝃 𝟐 ) + 𝒙 𝟎 𝒙 𝟐 𝒇 (𝟒) (𝝃) 𝟐𝟒 𝒙− 𝒙 𝟏 𝟒 𝒅𝒙 =2ℎ𝑓 𝑥 1 + ℎ 3 𝒇 𝒙 𝟎 −𝟐𝒇 𝒙 𝟏 +𝒇( 𝒙 𝟐 ) − ℎ 3 𝒉 𝟒 𝟏𝟐 𝒇 𝟒 ( 𝝃 𝟐 ) + 𝒙 𝟎 𝒙 𝟐 𝒇 (𝟒) (𝝃) 𝟐𝟒 𝒙− 𝒙 𝟏 𝟒 𝒅𝒙 = ℎ 3 𝟔𝒇 𝒙 𝟏 +𝒇 𝒙 𝟎 −𝟐𝒇 𝒙 𝟏 +𝒇( 𝒙 𝟐 ) − 𝒉 𝟓 𝟑𝟔 𝒇 𝟒 ( 𝝃 𝟐 ) + 𝒙 𝟎 𝒙 𝟐 𝒇 (𝟒) (𝝃) 𝟐𝟒 𝒙− 𝒙 𝟏 𝟒 𝒅𝒙 𝑥 0 𝑥 2 𝑥− 𝑥 1 4 𝑑𝑥 = = 𝑥− 𝑥 1 5 5 𝑥 0 𝑥 2 = 2 ℎ 5 5 The Weighted Mean Value Theorem for Integrals = ℎ 3 𝒇 𝒙 𝟎 +𝟒𝒇 𝒙 𝟏 +𝒇( 𝒙 𝟐 ) − 𝒉 𝟓 𝟑𝟔 𝒇 𝟒 ( 𝝃 𝟐 ) + 𝒇 (𝟒) (𝝃) 𝟐𝟒 𝒙 𝟎 𝒙 𝟐 𝒙− 𝒙 𝟏 𝟒 𝒅𝒙 = ℎ 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 ℎ=(𝑏−𝑎)/2 𝑥 0 =(𝑏+𝑎)/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 𝑥 0 𝑥 𝑛 𝑓 𝑥 𝑑𝑥 = 𝑖=0 𝑛 𝒂 𝒊 𝒇 𝒙 𝒊 + 𝑹 𝒂 𝒊 = 𝒙 𝟎 𝒙 𝒏 𝑳 𝒊 (𝒙)𝒅𝒙 = 𝒙 𝟎 𝒙 𝒏 𝒋=𝟎 𝒋≠𝒊 𝒏 (𝒙− 𝒙 𝒋 ) ( 𝒙 𝒊 − 𝒙 𝒋 ) 𝒅𝒙 where Theorem 4.2 There exists 𝜉∈ 𝑎,𝑏 such that 𝒏 is odd 𝒏 is even 𝑹 = ℎ 𝑛+2 𝑓 𝑛+1 (𝜉) 𝑛+1 ! 0 𝑛 𝑡 (𝑡−1)⋯ 𝑡−𝑛 𝑑𝑡 𝑹 = ℎ 𝑛+3 𝑓 𝑛+2 (𝜉) 𝑛+2 ! 0 𝑛 𝑡 2 (𝑡−1)⋯ 𝑡−𝑛 𝑑𝑡 the degree of precision is 𝑛 the degree of precision is 𝑛+1 The Trapezoidal Rule (2pts, n=1) Simpson’s Rule (3pts, n=2) 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 = 𝒉 𝟐 𝒇 𝒙 𝟎 +𝒇 𝒙 𝟏 − 𝒉 𝟑 𝟏𝟐 𝒇 ′′ 𝝃 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 = 𝒉 𝟑 𝒇 𝒙 𝟎 +𝟒𝒇 𝒙 𝟏 +𝒇( 𝒙 𝟐 ) − 𝒉 𝟓 𝟗𝟎 𝒇 𝟒 𝝃 ∗
𝑹 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 𝑥 𝑛+1 𝑓 𝑥 𝑑𝑥 = 𝑖=0 𝑛 𝒂 𝒊 𝒇 𝒙 𝒊 + 𝒂 𝒊 = 𝒙 −𝟏 𝒙 𝒏+𝟏 𝑳 𝒊 (𝒙)𝒅𝒙 = 𝒙 −𝟏 𝒙 𝒏+𝟏 𝒋=𝟎 𝒋≠𝒊 𝒏 (𝒙− 𝒙 𝒋 ) ( 𝒙 𝒊 − 𝒙 𝒋 ) 𝒅𝒙 𝑹 where
𝑹 𝑹 𝑹 Sec:4.3 Elements of Numerical Integration Open Newton-Cotes Formulas 𝑥 −1 𝑥 𝑛+1 𝑓 𝑥 𝑑𝑥 = 𝑖=0 𝑛 𝒂 𝒊 𝒇 𝒙 𝒊 + 𝒂 𝒊 = 𝒙 −𝟏 𝒙 𝒏+𝟏 𝑳 𝒊 (𝒙)𝒅𝒙 = 𝒙 −𝟏 𝒙 𝒏+𝟏 𝒋=𝟎 𝒋≠𝒊 𝒏 (𝒙− 𝒙 𝒋 ) ( 𝒙 𝒊 − 𝒙 𝒋 ) 𝒅𝒙 𝑹 where Theorem 4.2 There exists 𝜉∈ 𝑎,𝑏 such that 𝒏 is odd 𝒏 is even 𝑹 = ℎ 𝑛+2 𝑓 𝑛+1 (𝜉) 𝑛+1 ! −1 𝑛+1 𝑡 (𝑡−1)⋯ 𝑡−𝑛 𝑑𝑡 𝑹 = ℎ 𝑛+3 𝑓 𝑛+2 (𝜉) 𝑛+2 ! −1 𝑛+1 𝑡 2 (𝑡−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: 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 = 𝟓𝒉 𝟐𝟒 𝟏𝟏𝒇 𝒙 𝟎 +𝒇 𝒙 𝟏 +𝒇 𝒙 𝟐 +𝟏𝟏𝒇 𝒙 𝟑 − 𝟗𝟓𝒉 𝟕 𝟏𝟒𝟒 𝒇 𝟔 𝝃
Sec:4.3 Elements of Numerical Integration Example
Sec:4.3 Elements of Numerical Integration Example
Sec:4.3 Elements of Numerical Integration
Sec:4.3 Elements of Numerical Integration summary