From b95095e4278ccda691c721bcd902a6d0b5492486 Mon Sep 17 00:00:00 2001 From: Christian Kolset Date: Wed, 3 Sep 2025 11:04:45 -0600 Subject: Finished up mod 3, numierical integration --- tutorials/module_3/numerical_integration.md | 123 ++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/tutorials/module_3/numerical_integration.md b/tutorials/module_3/numerical_integration.md index e3dcbcf..86ce015 100644 --- a/tutorials/module_3/numerical_integration.md +++ b/tutorials/module_3/numerical_integration.md @@ -15,3 +15,126 @@ ### Simpsons 1/3 ### Simpsons 3/8 + + + + +# Numerical Integration +## Introduction and Importance +Integration is one of the fundamental tools in engineering analysis. Mechanical engineers frequently encounter integrals when computing work from force–displacement data, determining heat transfer from a time-dependent signal, or calculating lift and drag forces from pressure distributions over an airfoil. While some integrals can be evaluated analytically, most practical problems involve functions that are either too complex or are available only as experimental data. As engineering we choose numerical integration—also known as quadrature—provides a systematic approach to approximate the integral of a function over a finite interval. + +In this tutorial, we will study several standard methods of numerical integration, compare their +accuracy, and implement them in Python. By the end, you will understand not only how to apply +each method, but also when one method may be more suitable than another. + +--- + +## Section 2 — Core Concepts and Numerical Methods + +### General Form of Numerical Integration +We wish to approximate a definite integral of the form: +$$ +I = \int_a^b f(x) \, dx +$$ +by a weighted sum of function values: +$$ +I \approx \sum_{i=0}^m w_i f(x_i). +$$ +Here, $x_i$ are the chosen evaluation points and $w_i$ are their associated weights. + +### Midpoint Rule +The midpoint rule divides the interval into $n$ subintervals of equal width $h = (b-a)/n$ and +evaluates the function at the midpoint of each subinterval: +$$ +I \approx \sum_{i=0}^{n-1} h \, f\!\left(x_i + \tfrac{h}{2}\right). +$$ +This method achieves second-order accuracy (error decreases with \(h^2\)). + +### Trapezoidal Rule +The trapezoidal rule approximates the area under the curve as a series of trapezoids: +$$ +I \approx \frac{h}{2}\Big[f(x_0) + 2\sum_{i=1}^{n-1} f(x_i) + f(x_n)\Big]. +$$ +It is simple to implement and works especially well for tabulated data. Like the midpoint rule, +its accuracy is of order \(O(h^2)\). + +### Simpson’s Rule +Simpson’s rules use polynomial interpolation to achieve higher accuracy. + +- **Simpson’s 1/3 Rule (order \(O(h^4)\))** + Requires an even number of subintervals \(n\): + $$ + I \approx \frac{h}{3}\Big[f(x_0) + 4\sum_{\text{odd } i} f(x_i) + + 2\sum_{\text{even } i