# Approximate $\int\limits_{0}^{\pi} \sin{\left(x^{2} \right)}\, dx$ with $n = 5$ using the midpoint rule

The calculator will approximate the integral of $\sin{\left(x^{2} \right)}$ from $0$ to $\pi$ with $n = 5$ subintervals using the midpoint rule, with steps shown.

Related calculator: Midpoint Rule Calculator for a Table

If the calculator did not compute something or you have identified an error, or you have a suggestion/feedback, please write it in the comments below.

Approximate the integral $\int\limits_{0}^{\pi} \sin{\left(x^{2} \right)}\, dx$ with $n = 5$ using the midpoint rule.

### Solution

The midpoint rule (also known as the midpoint approximation) uses the midpoint of a subinterval for computing the height of the approximating rectangle:

$\int\limits_{a}^{b} f{\left(x \right)}\, dx\approx \Delta x \left(f{\left(\frac{x_{0} + x_{1}}{2} \right)} + f{\left(\frac{x_{1} + x_{2}}{2} \right)} + f{\left(\frac{x_{2} + x_{3}}{2} \right)}+\dots+f{\left(\frac{x_{n-2} + x_{n-1}}{2} \right)} + f{\left(\frac{x_{n-1} + x_{n}}{2} \right)}\right)$

where $\Delta x = \frac{b - a}{n}$.

We have that $f{\left(x \right)} = \sin{\left(x^{2} \right)}$, $a = 0$, $b = \pi$, and $n = 5$.

Therefore, $\Delta x = \frac{\pi - 0}{5} = \frac{\pi}{5}$.

Divide the interval $\left[0, \pi\right]$ into $n = 5$ subintervals of the length $\Delta x = \frac{\pi}{5}$ with the following endpoints: $a = 0$, $\frac{\pi}{5}$, $\frac{2 \pi}{5}$, $\frac{3 \pi}{5}$, $\frac{4 \pi}{5}$, $\pi = b$.

Now, just evaluate the function at the midpoints of the subintervals.

$f{\left(\frac{x_{0} + x_{1}}{2} \right)} = f{\left(\frac{0 + \frac{\pi}{5}}{2} \right)} = f{\left(\frac{\pi}{10} \right)} = \sin{\left(\frac{\pi^{2}}{100} \right)}\approx 0.098535890500574$

$f{\left(\frac{x_{1} + x_{2}}{2} \right)} = f{\left(\frac{\frac{\pi}{5} + \frac{2 \pi}{5}}{2} \right)} = f{\left(\frac{3 \pi}{10} \right)} = \sin{\left(\frac{9 \pi^{2}}{100} \right)}\approx 0.775978167711571$

$f{\left(\frac{x_{2} + x_{3}}{2} \right)} = f{\left(\frac{\frac{2 \pi}{5} + \frac{3 \pi}{5}}{2} \right)} = f{\left(\frac{\pi}{2} \right)} = \sin{\left(\frac{\pi^{2}}{4} \right)}\approx 0.624265952639699$

$f{\left(\frac{x_{3} + x_{4}}{2} \right)} = f{\left(\frac{\frac{3 \pi}{5} + \frac{4 \pi}{5}}{2} \right)} = f{\left(\frac{7 \pi}{10} \right)} = \sin{\left(\frac{49 \pi^{2}}{100} \right)}\approx -0.992356786508554$

$f{\left(\frac{x_{4} + x_{5}}{2} \right)} = f{\left(\frac{\frac{4 \pi}{5} + \pi}{2} \right)} = f{\left(\frac{9 \pi}{10} \right)} = \sin{\left(\frac{81 \pi^{2}}{100} \right)}\approx 0.990160389295942$

Finally, just sum up the above values and multiply by $\Delta x = \frac{\pi}{5}$: $\frac{\pi}{5} \left(0.098535890500574 + 0.775978167711571 + 0.624265952639699 - 0.992356786508554 + 0.990160389295942\right) = 0.940331217218375.$

$\int\limits_{0}^{\pi} \sin{\left(x^{2} \right)}\, dx\approx 0.940331217218375$A