#### *Related to [[Antiderivatives]] and [[Integration]]* --- ## Numerical approximation - There are some situations where approximating an integral is more advantageous then evaluating it exactly. To *approximate* an integral we use **Reimann sums, which are outlined in detail on the [[Integration]] page**. This section will discuss some more advanced **Reimann sum techniques that allow us to approximate integrals more accurately.** ##### *Method 1: the midpoint rule* - The midpoint rule is **the second most accurate Reimann sum technique**. It is **always more accurate than the trapezoid rule** and far better than the left/right hand rule. - *Recall the left/right hand rule sets the height of each rectangle in the Reitman sum equal to the height of the function at its upper left or right hand corner.* - The midpoint rule relies on using multiple rectangles that have a height equal to the value of the **evaluated function at their midpoint *(referring to the rectangles)*.** $\newline$ $\text{For }F(x),\text{ integer }n,\;x_i=a+\frac{b-a}{n}\cdot i$ $\int_a^b f(x)\,dx =\sum_{i=1}^n\,f\biggl(\frac{x_{i-1}+x_i}{2}\biggl)\,\cdot\,\frac{b-a}{n}\;\;\;{\color{grey}\longrightarrow}\;\;\Delta x\Biggl[f\Big(x_1-\frac{\Delta x}{2}\Big)+f\Big(x_2-\frac{\Delta x}{2}\Big)...\;\Biggl]$ $\newline$ ##### *Method 2: the trapezoid rule* - The trapezoid rule uses multiple trapezoids instead of rectangles to approximate the area under a curve. - When using the trapezoid rule you multiply every output by 2 except for the **first and last outputs evaluated**. - You will always end up evaluating one more output than the number given by **n** because you have **to evaluate the beginning AND end of every section not just the left or right side.** - The trapezoid rule is less accurate than the midpoint rule and Simpson's rule, but more accurate than the left/right endpoint rules. $\newline$ $\text{For }F(x),\text{ integer }n,\;x_i=a+\frac{b-a}{n}\cdot i$ $\int_a^bf(x)\,dx=\frac{b-a}{n}\cdot\frac{1}{2}\biggl(f(x_0) +2f(x_1)+2f(x_2)+2f(x_3)+2f(x_4)...+f(x_{last})\biggl)$ $\newline$ ##### *Method 3: Simpson's rule* - Simpson's rule uses parabolas to approximate integrals. As you can see in the generalized formula below, **the first and last height sampled should be multiplied by one, every other height *(y value)* should alternate between being multiplied by 4 and 2.** As a result of using parabolas Simpson's rule does not use right, left or middle points for its $x$ values, instead it evaluates the function **at the right AND left endpoints of every section** just like the trapezoid rule. - Approximations using Simpson's rule are equal to the **weighted** average of the approximations you would get from the midpoint and trapezoidal rules. Simpson's rule **is by far the most accurate of any approximation method.** $S_n=\frac{1}{3}T_n+\frac{2}{3}M_n$ - ==n MUST be even when using Simpson's rule.== $\newline$ $\int_a^bf(x)\,dx=\frac{b-a}{n}\cdot \frac{1}{3}\Big[f(x_1)+4f(x_2)+2f(x_3)+4f(x_4)+2f(x_5)... + f(x_{last})\Big]$ $\text{let }x_1=a\text{ and }x_{last}=b\;\;\;\;\;\;\text{let the number of heights evaluated }=n+1$ $\newline$ - **==Its important to remember that when using Simpson's rule you MUST evaluate the function at both the beginning AND end of every *"section"* specified by $n$. This means if n = 2 you will actually evaluate 3 height values, at the begging, middle, and end of the bound because 3 lines are needed to make 2 rectangular sections.==** For example, if the bounds are 0-1 and n = 2 your sum will look like this: $\newline$ $\frac{0.5}{3}\Big[f(0)+4f(0.5)+f(1)\Big]$ $\newline$ ##### *Calculating error* - The variable $E_M$ is the **value** error between the actual value of the integral and the value you get using $n$ rectangles and the **midpoint Reimann sum technique.** Likewise $E_T$ represents the error between the actual value of the integral and the value you get using $n$ rectangles and the **trapezoid Reimann sum technique**. - Note the values you get from these equations represent the **maximum possible error, the actual value error could be less but NEVER more**. - If the derivative of an equation is equal to zero, when solving for k **that shows that your approximation is *perfectly accurate*. - The value of $k$ in the error equation for ==the midpoint and trapezoidal techniques== is any value that is larger than **all outputs on the specified bounds of the function $f(x)s second derivative.** The closer this value is to the *maximum value of $f''(x)$* the **more accurate the approximation equations will be.** *Recall that we can find critical values (this includes max value) by setting the THIRD derivative equal to zero and solving for x.* - The value of $k$ in the error equation for ==Simpson's rule== is any value that is larger than all outputs on the specified bounds of the function's **fourth derivative.** - You can use these equations to help you decide how many rectangles you must use when approximating the integral to ensure that the estimation is within some value $E_M$ or $E_T$. To do this you must re-arrange one of the value error equations to solve for n. - The value n **has to be an integer**. If you are solving for n **and you get an answer that is a decimal you must always round it ==up== to the next whole number**. $\newline$ $\text{Value error equations for different approximation methods}$ $\newline$ $E_M\le\frac{k(b-a)^3}{24n^2}$ $E_T\le\frac{k(b-a)^2}{12n^2}$ $\small\color{grey}\text{where k }\ge f''(x)_{\small\text{global max}}$ $\newline$ $|E_s|\le\frac{k(b-a)^5}{180n^4}$ $\small\color{grey}\text{where k }\ge f''''(x)_{\small\text{global max}}$ --- ## Calculator >[!cite] > >--- ><iframe src="https://www.mathauditor.com/integral-approximation-calculator.html" width="850" height="1200"></iframe>