348. Using the rectangle method, compute $\int_{0}^{\pi / 4} \cos x d x$
Solution. Divide the interval of integration into 5 parts (Fig. 196). Then $n=5 ; \quad b-a=\pi / 4 ; \quad \Delta x=(b-a) / n=\pi / 20 \approx 0.1571$. The corresponding values of the integrand function will be found using tables: $y_{0}=\cos 0^{\circ}=1 ; y_{1}=\cos (\pi / 20)=\cos 9^{\circ}==0.9877 ; y_{2}=$ $=\cos (\pi / 10)=\cos 18^{\circ}=0.9511 ; \quad y_{3}=\cos (3 \pi / 20)=\cos 27^{\circ}=0.8910 ; \quad y_{4}=$ $=\cos (\pi / 5)=\cos 36^{\circ}=0.8090 ; y_{5}=\cos (\pi / 4)=\cos 45^{\circ}=0.7071$.

By the formula of rectangles (with a deficiency) we have

$$
A_{\text {rect }}=\int_{0}^{\pi / 4} \cos x d x \approx 0.1571(1+0.9877+0.9511+0.8910+0.8090)=0.7288
$$

On the other hand, by the Newton-Leibniz formula

$$
A_{\text {exact }}=\int_{0}^{\pi / 4} \cos x d x=\sin x \int_{0}^{\pi / 4}=\sin (\pi / 4)-\sin 0=0.5 \sqrt{2}
$$

Let's find the relative error of the calculation:

$$
\delta=\frac{\left|A_{\text {approx }}-A_{\text {exact }}\right|}{A_{\text {exact }}} 100 \%=\frac{|0.7288-0.5 \sqrt{2}|}{0.5 \sqrt{2}} \cdot 100 \% \approx 3.06 \%
$$