Answer :

To solve the integral [tex]\( \int_1^5 \frac{2 \cos (3 x)}{x} \, dx \)[/tex] using numerical methods with [tex]\( n = 8 \)[/tex] subintervals, follow these steps for each method:

### (a) Trapezoidal Rule

The trapezoidal rule approximates the integral by dividing the interval [1, 5] into [tex]\( n = 8 \)[/tex] equally spaced subintervals and summing up the areas of trapezoids under the curve. Here, the interval is divided by points [tex]\( x_i \)[/tex] from [tex]\( a = 1 \)[/tex] to [tex]\( b = 5 \)[/tex] with [tex]\( x_0, x_1, \ldots, x_8 \)[/tex]. The width of each subinterval is

[tex]\[ h = \frac{b - a}{n} = \frac{5 - 1}{8} = 0.5 \][/tex]

The formula for the trapezoidal approximation is:

[tex]\[ \int_a^b f(x) \, dx \approx \frac{h}{2} \left[ f(x_0) + 2 \sum_{i=1}^{n-1} f(x_i) + f(x_n) \right] \][/tex]

Plugging in our function [tex]\( f(x) = \frac{2 \cos (3 x)}{x} \)[/tex] and evaluating it at the points [tex]\( x_0, x_1, \ldots, x_8 \)[/tex]:

[tex]\[ \text{Trapezoidal result} \approx -0.18916600155903196 \][/tex]

### (b) Midpoint Rule

The midpoint rule approximates the integral by dividing the interval into [tex]\( n = 8 \)[/tex] subintervals and using the midpoint of each subinterval to approximate the function:

The width of each subinterval is again [tex]\( h = 0.5 \)[/tex]. The midpoint of each subinterval is

[tex]\[ x_i = a + \left( i + \frac{1}{2} \right)h \][/tex]

for [tex]\( i = 0, 1, \ldots, n-1 \)[/tex]. The midpoint rule formula is:

[tex]\[ \int_a^b f(x) \, dx \approx h \sum_{i=0}^{n-1} f(x_i) \][/tex]

Evaluating each midpoint and the function [tex]\( f(x) \)[/tex] at these points:

[tex]\[ \text{Midpoint result} \approx -0.12401899176539463 \][/tex]

### (c) Simpson's Rule

Simpson’s rule is more accurate than the trapezoidal rule or the midpoint rule under certain conditions. It requires an even number of subintervals (which we have):

[tex]\[ \int_a^b f(x) \, dx \approx \frac{h}{3} \left[ f(x_0) + 4 \sum_{i=1, \, \text{odd}}^{n-1} f(x_i) + 2 \sum_{i=2, \, \text{even}}^{n-2} f(x_i) + f(x_n) \right] \][/tex]

The subinterval width [tex]\( h \)[/tex] remains [tex]\( 0.5 \)[/tex]. Simpson's rule interpretation for our function yields:

[tex]\[ \text{Simpson's result} \approx -0.14670221666727806 \][/tex]

In summary, the results for the integral [tex]\( \int_1^5 \frac{2 \cos (3 x)}{x} \, dx \)[/tex] using [tex]\( n = 8 \)[/tex] are:

(a) Trapezoidal rule: [tex]\( -0.18916600155903196 \)[/tex]

(b) Midpoint rule: [tex]\( -0.12401899176539463 \)[/tex]

(c) Simpson's rule: [tex]\( -0.14670221666727806 \)[/tex]