\(\newcommand{\bx}{\textbf{x}} \newcommand{\bo}{\textbf{0}} \newcommand{\bv}{\textbf{v}} \newcommand{\bu}{\textbf{u}} \newcommand{\bq}{\textbf{q}} \newcommand{\by}{\textbf{y}} \newcommand{\bb}{\textbf{b}} \newcommand{\ba}{\textbf{a}} \newcommand{\grad}{\boldsymbol{\nabla}} \newcommand{\pd}[2]{\frac{\partial #1}{\partial #2}} \newcommand{\pdd}[2]{\frac{\partial^2 #1}{\partial #2^2}} \newcommand{\pddm}[3]{\frac{\partial^2 #1}{\partial #2 \partial #3}} \newcommand{\deriv}[2]{\frac{d #1}{d #2}} \newcommand{\lt}{ < } \newcommand{\gt}{ > } \newcommand{\amp}{ & } \)

Section4.2Numerical Integration

We want to build methods for approximating integrals. Two of the most common are the Trapezoidal rule and Simpson's rule. Each of these integration approximation techniques requires us to partition the domain into small bit and then to approximate the function with either linear or curved polynomial functions. We will use polynomials since the exact area can be worked out analytically.

The trapezoidal rule does a decent job approximating integrals, but ultimately you are using linear functions to approximate \(f(x)\) and the accuracy may suffer if the step size is too large or the function too non-linear. You likely notice that the trapezoidal rule will give an exact answer if you were to integrate a linear or constant function. An potentially better approach would be to get an integral that evaluates quadratic functions exactly. In order to do this we need to evaluate the function at three points (not two like the trapezoidal rule). Let's to integrate a function \(f(x)\) on the interval \([a,b]\) by using the three points \( (a,f(a)), \, (m,f(m)),\) and \((b,f(b))\) where \(m = \frac{a+b}{2}\) is the midpoint of the two boundary points. We want to find constants \(A_1, A_2, A_3\) such that the integral \begin{equation*} \int_a^b f(x) dx = A_1 f(a) + A_2 f\left( \frac{a+b}{2}\right) + A_3 f(b) \end{equation*} is exact for all constant, linear, and quadratic functions. This would guarantee that we have an exact method for all polynomials of order 2 or less but should serve as a decent approximation if the function is not quadratic.

To find the constants \(A_1, A_2, A_3\) we can write the following system of three equations \begin{equation*} \int_a^b 1 dx = b-a = A_1 + A_2 + A_3 \\ \int_a^b x dx = \frac{b^2-a^2}{2} = A_1 \cdot a + A_2 \cdot \left( \frac{a+b}{2} \right) + A_3 \cdot b \\ \int_a^b x^2 dx =\frac{b^3-a^3}{3} = A_1 \cdot a^2 + A_2 \cdot \left( \frac{a+b}{2} \right)^2 + A_3 \cdot b^2. \end{equation*} Solving the linear system gives \begin{equation*} A_1 = \frac{b-a}{6} \quad A_2 = \frac{4(b-a)}{6} \quad \text{and} \quad A_3 = \frac{b-a}{6}. \end{equation*} At this point we can see that the integral can be approximated as \begin{equation*} \int_a^b f(x) dx \approx \frac{b-a}{6} \left( f(a) + 4 f\left( \frac{a+b}{2} \right) + f(b) \right) \end{equation*} and the technique will give an exact answer for any polynomial of order 2 or below. To improve upon this idea we now examine the problem of partitioning the interval \([a,b]\) into small pieces and running this process on each piece.