![Page 1: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/1.jpg)
Numerical Integration
Spring 2019
Numerical Integration Spring 2019 1 / 11
![Page 2: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/2.jpg)
Objective
Approximate
∫ b
af (x) dx
A jog down Calc I/II lane
The integral is the area under the curve, i.e between the curve andx-axis
However, analytical anti-derivatives are not always easy to writedown, making evaluation of some basic definite integrals difficult.∫ b
aex
2dx
In some practical cases, we do not have an analytical representationof f but we still want to approximate the integral
Numerical integration techniques are necessary to approximate theintegral
Numerical Integration Spring 2019 2 / 11
![Page 3: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/3.jpg)
Objective
Approximate
∫ b
af (x) dx
A jog down Calc I/II lane
The integral is the area under the curve, i.e between the curve andx-axis
However, analytical anti-derivatives are not always easy to writedown, making evaluation of some basic definite integrals difficult.∫ b
aex
2dx
In some practical cases, we do not have an analytical representationof f but we still want to approximate the integral
Numerical integration techniques are necessary to approximate theintegral
Numerical Integration Spring 2019 2 / 11
![Page 4: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/4.jpg)
Objective
Approximate
∫ b
af (x) dx
A jog down Calc I/II lane
The integral is the area under the curve, i.e between the curve andx-axis
However, analytical anti-derivatives are not always easy to writedown, making evaluation of some basic definite integrals difficult.∫ b
aex
2dx
In some practical cases, we do not have an analytical representationof f but we still want to approximate the integral
Numerical integration techniques are necessary to approximate theintegral
Numerical Integration Spring 2019 2 / 11
![Page 5: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/5.jpg)
Objective
Approximate
∫ b
af (x) dx
A jog down Calc I/II lane
The integral is the area under the curve, i.e between the curve andx-axis
However, analytical anti-derivatives are not always easy to writedown, making evaluation of some basic definite integrals difficult.∫ b
aex
2dx
In some practical cases, we do not have an analytical representationof f but we still want to approximate the integral
Numerical integration techniques are necessary to approximate theintegral
Numerical Integration Spring 2019 2 / 11
![Page 6: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/6.jpg)
Objective
Approximate
∫ b
af (x) dx
A jog down Calc I/II lane
The integral is the area under the curve, i.e between the curve andx-axis
However, analytical anti-derivatives are not always easy to writedown, making evaluation of some basic definite integrals difficult.∫ b
aex
2dx
In some practical cases, we do not have an analytical representationof f but we still want to approximate the integral
Numerical integration techniques are necessary to approximate theintegral
Numerical Integration Spring 2019 2 / 11
![Page 7: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/7.jpg)
Approximating
∫ b
a
f (x) dx (basic idea)
Approximate the “area” under the curve on [a, b] using simple sub-regions
Sub-divide the interval [a, b] into n subintervals of equal width
∆x =b − a
n
More sophisticated methods use adaptive widths of subintervaldepending on the behavior of the function
As the number of sub-intervals increases, we obtain a more accurateapproximation of the area under the curve
Desmos demo
Numerical Integration Spring 2019 3 / 11
![Page 8: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/8.jpg)
Approximating
∫ b
a
f (x) dx (basic idea)
Approximate the “area” under the curve on [a, b] using simple sub-regions
Sub-divide the interval [a, b] into n subintervals of equal width
∆x =b − a
n
More sophisticated methods use adaptive widths of subintervaldepending on the behavior of the function
As the number of sub-intervals increases, we obtain a more accurateapproximation of the area under the curve
Desmos demo
Numerical Integration Spring 2019 3 / 11
![Page 9: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/9.jpg)
Approximating
∫ b
a
f (x) dx (basic idea)
Approximate the “area” under the curve on [a, b] using simple sub-regions
Sub-divide the interval [a, b] into n subintervals of equal width
∆x =b − a
n
More sophisticated methods use adaptive widths of subintervaldepending on the behavior of the function
As the number of sub-intervals increases, we obtain a more accurateapproximation of the area under the curve
Desmos demo
Numerical Integration Spring 2019 3 / 11
![Page 10: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/10.jpg)
Approximating
∫ b
a
f (x) dx (basic idea)
Approximate the “area” under the curve on [a, b] using simple sub-regions
Sub-divide the interval [a, b] into n subintervals of equal width
∆x =b − a
n
More sophisticated methods use adaptive widths of subintervaldepending on the behavior of the function
As the number of sub-intervals increases, we obtain a more accurateapproximation of the area under the curve
Desmos demo
Numerical Integration Spring 2019 3 / 11
![Page 11: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/11.jpg)
Approximating
∫ b
a
f (x) dx (Implementation)
Rectangles1 Divide [a, b] so that
a = x1 < x2 < · · · < xn < xn+1 = b, k = 1, 2, . . . , n
with xk = a + (k − 1)∆x
2 On each sub-interval [xk , xk+1] select a sample point, x∗k ∈ [xk , xk+1]3 Define the height of each sub-rectangle as f (x∗k ) so that the area of
each sub-rectangle is
f (x∗)∆x
4 Summing up for the n sub-intervals∫ b
af (x) dx ≈
n∑k=1
f (x∗k )∆x
Numerical Integration Spring 2019 4 / 11
![Page 12: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/12.jpg)
Approximating
∫ b
a
f (x) dx (Implementation)
Rectangles1 Divide [a, b] so that
a = x1 < x2 < · · · < xn < xn+1 = b, k = 1, 2, . . . , n
with xk = a + (k − 1)∆x2 On each sub-interval [xk , xk+1] select a sample point, x∗k ∈ [xk , xk+1]
3 Define the height of each sub-rectangle as f (x∗k ) so that the area ofeach sub-rectangle is
f (x∗)∆x
4 Summing up for the n sub-intervals∫ b
af (x) dx ≈
n∑k=1
f (x∗k )∆x
Numerical Integration Spring 2019 4 / 11
![Page 13: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/13.jpg)
Approximating
∫ b
a
f (x) dx (Implementation)
Rectangles1 Divide [a, b] so that
a = x1 < x2 < · · · < xn < xn+1 = b, k = 1, 2, . . . , n
with xk = a + (k − 1)∆x2 On each sub-interval [xk , xk+1] select a sample point, x∗k ∈ [xk , xk+1]3 Define the height of each sub-rectangle as f (x∗k ) so that the area of
each sub-rectangle is
f (x∗)∆x
4 Summing up for the n sub-intervals∫ b
af (x) dx ≈
n∑k=1
f (x∗k )∆x
Numerical Integration Spring 2019 4 / 11
![Page 14: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/14.jpg)
Approximating
∫ b
a
f (x) dx (Implementation)
Trapeziods
1 Each trapezoid has a base of [xk , xk+1] with parallel sides of lengthf (xk) and f (xk+1)
2 The area of the k-th Trapezoid is
∆x
2
(f (xk) + f (xk+1)
)3 Summing up for the n sub-intervals
∫ b
af (x) dx ≈ ∆x
2
n∑k=1
(f (xk) + f (xk+1)
)
Numerical Integration Spring 2019 5 / 11
![Page 15: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/15.jpg)
Approximating
∫ b
a
f (x) dx (Implementation)
Trapeziods
1 Each trapezoid has a base of [xk , xk+1] with parallel sides of lengthf (xk) and f (xk+1)
2 The area of the k-th Trapezoid is
∆x
2
(f (xk) + f (xk+1)
)
3 Summing up for the n sub-intervals
∫ b
af (x) dx ≈ ∆x
2
n∑k=1
(f (xk) + f (xk+1)
)
Numerical Integration Spring 2019 5 / 11
![Page 16: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/16.jpg)
Approximating
∫ b
a
f (x) dx (Implementation)
Trapeziods
1 Each trapezoid has a base of [xk , xk+1] with parallel sides of lengthf (xk) and f (xk+1)
2 The area of the k-th Trapezoid is
∆x
2
(f (xk) + f (xk+1)
)3 Summing up for the n sub-intervals
∫ b
af (x) dx ≈ ∆x
2
n∑k=1
(f (xk) + f (xk+1)
)
Numerical Integration Spring 2019 5 / 11
![Page 17: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/17.jpg)
Approximating
∫ b
a
f (x) dx (Implementation)
Trapezoids
∫ b
af (x) dx ≈
∆x
2
n∑k=1
(f (xk ) + f (xk+1)
)=
∆x
2
([f (x1) + f (x2)] + [(f (x2) + f (x3)] + · · ·+ [f (xn−1) + f (xn)] + [f (xn) + f (xn+1)]
)=
∆x
2
(f (x1) + 2f (x2) + · · ·+ 2f (xn) + f (xn+1)
)
∫ b
af (x) dx =
∆x
2
(f (x1) + 2
n∑k=2
f (xk) + f (xn+1)
)
Numerical Integration Spring 2019 6 / 11
![Page 18: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/18.jpg)
Error Analysis (MA 428)
Theorem
Assuming maxa≤x≤b
|f ′′(x)| ≤ M. Then the midpoint method has error
M(b − a)(∆x)2
24
and the Trapezoidal method has error
M(b − a)(∆x)2
12
Numerical Integration Spring 2019 7 / 11
![Page 19: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/19.jpg)
Simpson’s Method for approximating
∫ b
a
f (x) dx
Approximate the area under the function using second order curves
1 Divide [a, b] into n sub-intervals of width ∆x = b−an , where n is even.
2 On each pair of sub-intervals [xk−1, xk ] and [xk , xk+1] (k = 2, · · · , n)approximate the area under the curve with a quadratic function passingthrough the points:(
xk−1, f (xk−1)),(xk , f (xk)
)and (xk+1, f (xk+1))
3 The area under each parabola on [xk−1, xk ] and [xk , xk+1] is
∆x
3
(f (xk−1) + 4f (xk) + f (xk+1)
)4 Summing up over all sub-intervals∫ b
a
f (x) dx ≈ ∆x
3
(f1 + 4f2 + 2f3 + 4f4 + · · ·+ 2fn−1 + 4fn + fn+1
)
Numerical Integration Spring 2019 8 / 11
![Page 20: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/20.jpg)
Simpson’s Method for approximating
∫ b
a
f (x) dx
Approximate the area under the function using second order curves
1 Divide [a, b] into n sub-intervals of width ∆x = b−an , where n is even.
2 On each pair of sub-intervals [xk−1, xk ] and [xk , xk+1] (k = 2, · · · , n)approximate the area under the curve with a quadratic function passingthrough the points:(
xk−1, f (xk−1)),(xk , f (xk)
)and (xk+1, f (xk+1))
3 The area under each parabola on [xk−1, xk ] and [xk , xk+1] is
∆x
3
(f (xk−1) + 4f (xk) + f (xk+1)
)4 Summing up over all sub-intervals∫ b
a
f (x) dx ≈ ∆x
3
(f1 + 4f2 + 2f3 + 4f4 + · · ·+ 2fn−1 + 4fn + fn+1
)
Numerical Integration Spring 2019 8 / 11
![Page 21: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/21.jpg)
Simpson’s Method for approximating
∫ b
a
f (x) dx
Approximate the area under the function using second order curves
1 Divide [a, b] into n sub-intervals of width ∆x = b−an , where n is even.
2 On each pair of sub-intervals [xk−1, xk ] and [xk , xk+1] (k = 2, · · · , n)approximate the area under the curve with a quadratic function passingthrough the points:(
xk−1, f (xk−1)),(xk , f (xk)
)and (xk+1, f (xk+1))
3 The area under each parabola on [xk−1, xk ] and [xk , xk+1] is
∆x
3
(f (xk−1) + 4f (xk) + f (xk+1)
)4 Summing up over all sub-intervals∫ b
a
f (x) dx ≈ ∆x
3
(f1 + 4f2 + 2f3 + 4f4 + · · ·+ 2fn−1 + 4fn + fn+1
)
Numerical Integration Spring 2019 8 / 11
![Page 22: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/22.jpg)
Simpson’s Method for approximating
∫ b
a
f (x) dx
Approximate the area under the function using second order curves
1 Divide [a, b] into n sub-intervals of width ∆x = b−an , where n is even.
2 On each pair of sub-intervals [xk−1, xk ] and [xk , xk+1] (k = 2, · · · , n)approximate the area under the curve with a quadratic function passingthrough the points:(
xk−1, f (xk−1)),(xk , f (xk)
)and (xk+1, f (xk+1))
3 The area under each parabola on [xk−1, xk ] and [xk , xk+1] is
∆x
3
(f (xk−1) + 4f (xk) + f (xk+1)
)
4 Summing up over all sub-intervals∫ b
a
f (x) dx ≈ ∆x
3
(f1 + 4f2 + 2f3 + 4f4 + · · ·+ 2fn−1 + 4fn + fn+1
)
Numerical Integration Spring 2019 8 / 11
![Page 23: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/23.jpg)
Simpson’s Method for approximating
∫ b
a
f (x) dx
Approximate the area under the function using second order curves
1 Divide [a, b] into n sub-intervals of width ∆x = b−an , where n is even.
2 On each pair of sub-intervals [xk−1, xk ] and [xk , xk+1] (k = 2, · · · , n)approximate the area under the curve with a quadratic function passingthrough the points:(
xk−1, f (xk−1)),(xk , f (xk)
)and (xk+1, f (xk+1))
3 The area under each parabola on [xk−1, xk ] and [xk , xk+1] is
∆x
3
(f (xk−1) + 4f (xk) + f (xk+1)
)4 Summing up over all sub-intervals∫ b
a
f (x) dx ≈ ∆x
3
(f1 + 4f2 + 2f3 + 4f4 + · · ·+ 2fn−1 + 4fn + fn+1
)Numerical Integration Spring 2019 8 / 11
![Page 24: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/24.jpg)
Error Analysis (MA 428)
Theorem
Assuming maxa≤x≤b
|f (4)(x)| ≤ M. Then the Simpson’s method has error
M(b − a)(∆x)4
180
Composite Simpson’s method has a convergence rate of O(∆x)4
compared to Midpoint and Trapezoidal that are O(∆x)2.
Numerical Integration Spring 2019 9 / 11
![Page 25: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/25.jpg)
Error comparison
log10(∆x)-4-3.5-3-2.5-2-1.5-1
log10(error)
-16
-14
-12
-10
-8
-6
-4
-2Comparison
Simpsons
Midpoint
Trapeziod
Bisection and Trapezoidal methods are second order in ∆x i.e. O((∆x)2)
Simpsons method is fourth order in ∆x i.e. O((∆x)4)
Numerical Integration Spring 2019 10 / 11
![Page 26: Numerical Integration - Loyola University Marylandmath.loyola.edu/~chidyagp/sp19/numerical_integration.pdfNumerical integration techniques are necessary to approximate the integral](https://reader036.vdocuments.us/reader036/viewer/2022070213/610dbe504c306a2ef43be55b/html5/thumbnails/26.jpg)
Generalized formula
Higher order methods of the form∫ b
af (x) dx =
N∑i=1
f (xi )wi
These methods can be extended to 2D and 3D integrals (see MA428).
Numerical Integration Spring 2019 11 / 11