# How do you use the trapezoidal rule with n = 4 to estimate the integral int_0^(pi/2)cos(x^2)dx?

May 18, 2018

${\int}_{0}^{\frac{\pi}{2}} \cos \left({x}^{2}\right) \mathrm{dx} \approx 0.83$

#### Explanation:

The trapezoidal rule tells us that:
${\int}_{b}^{a} f \left(x\right) \mathrm{dx} \approx \frac{h}{2} \left[f \left({x}_{0}\right) + f \left({x}_{n}\right) + 2 \left[f \left({x}_{1}\right) + f \left({x}_{2}\right) + \cdots f \left({x}_{n - 1}\right)\right]\right]$ where $h = \frac{b - a}{n}$

$h = \frac{\frac{\pi}{2} - 0}{4} = \frac{\pi}{8}$

So we have:
${\int}_{0}^{\frac{\pi}{2}} \cos \left({x}^{2}\right) \mathrm{dx} \approx \frac{\pi}{16} \left[f \left(0\right) + f \left(\frac{\pi}{2}\right) + 2 \left[f \left(\frac{\pi}{8}\right) + f \left(\frac{\pi}{4}\right) + f \left(\frac{3 \pi}{8}\right)\right]\right]$

$= \frac{\pi}{16} \left[\cos \left({\left(0\right)}^{2}\right) + \cos \left({\left(\frac{\pi}{2}\right)}^{2}\right) + 2 \left[\cos \left({\left(\frac{\pi}{8}\right)}^{2}\right) + \cos \left({\left(\frac{\pi}{4}\right)}^{2}\right) + \cos \left({\left(\frac{3 \pi}{8}\right)}^{2}\right)\right]\right]$

$\approx \frac{\pi}{16} \left[1 - 0.78 + 1.97 + 1.63 + 0.36\right]$

$\approx \frac{\pi}{16} \left[4.23\right]$

$\approx 0.83$