Integral Approximation 7B0B4E
1. **Problem Statement:** Approximate the integral $$\int_0^{0.35} \frac{2}{x^2 - 4} \, dx$$ using three numerical methods: (a) Gaussian quadrature with $n=3$, (b) Closed Newton-Cotes formula with $n=2$, and (c) Open Newton-Cotes formula with $n=2$. Then compare these approximations to the exact value.
2. **Exact Integral Calculation:** The integral is $$\int \frac{2}{x^2 - 4} dx = \int \frac{2}{(x-2)(x+2)} dx.$$ Using partial fractions:
$$\frac{2}{x^2 - 4} = \frac{A}{x-2} + \frac{B}{x+2}.$$ Solving for $A$ and $B$:
$$2 = A(x+2) + B(x-2).$$ Setting $x=2$ gives $2 = A(4)$ so $A=\frac{1}{2}$.
Setting $x=-2$ gives $2 = B(-4)$ so $B=-\frac{1}{2}$.
Thus,
$$\int \frac{2}{x^2 - 4} dx = \int \left( \frac{1/2}{x-2} - \frac{1/2}{x+2} \right) dx = \frac{1}{2} \ln|x-2| - \frac{1}{2} \ln|x+2| + C = \frac{1}{2} \ln \left| \frac{x-2}{x+2} \right| + C.$$
Evaluate from 0 to 0.35:
$$\text{Exact} = \frac{1}{2} \left[ \ln \left| \frac{0.35 - 2}{0.35 + 2} \right| - \ln \left| \frac{0 - 2}{0 + 2} \right| \right] = \frac{1}{2} \left[ \ln \left| \frac{-1.65}{2.35} \right| - \ln 1 \right] = \frac{1}{2} \ln \left( \frac{1.65}{2.35} \right).$$
Calculate numeric value:
$$\frac{1.65}{2.35} \approx 0.7021,$$
$$\ln(0.7021) \approx -0.3535,$$
so
$$\text{Exact} \approx \frac{1}{2} \times (-0.3535) = -0.17675.$$
3. **Gaussian Quadrature (n=3):**
Gaussian quadrature on $[a,b]$ uses nodes $x_i$ and weights $w_i$ for $i=1,2,3$ on $[-1,1]$:
Nodes: $x = \{-\sqrt{3/5}, 0, \sqrt{3/5}\} \approx \{-0.7746, 0, 0.7746\}$
Weights: $w = \{5/9, 8/9, 5/9\}$
Transform nodes to $[0,0.35]$:
$$x_i' = \frac{b-a}{2} x_i + \frac{b+a}{2} = 0.175 x_i + 0.175.$$
Calculate $x_i'$:
- $x_1' = 0.175 \times (-0.7746) + 0.175 = 0.0405$
- $x_2' = 0.175 \times 0 + 0.175 = 0.175$
- $x_3' = 0.175 \times 0.7746 + 0.175 = 0.3095$
Calculate function values:
$$f(x) = \frac{2}{x^2 - 4}.$$
- $f(0.0405) = \frac{2}{0.0405^2 - 4} = \frac{2}{-3.9984} = -0.5002$
- $f(0.175) = \frac{2}{0.175^2 - 4} = \frac{2}{-3.9694} = -0.5032$
- $f(0.3095) = \frac{2}{0.3095^2 - 4} = \frac{2}{-3.904} = -0.5123$
Approximate integral:
$$I \approx \frac{b-a}{2} \sum_{i=1}^3 w_i f(x_i') = 0.175 \times \left( \frac{5}{9}(-0.5002) + \frac{8}{9}(-0.5032) + \frac{5}{9}(-0.5123) \right).$$
Calculate sum inside parentheses:
$$= \frac{5}{9}(-0.5002) + \frac{8}{9}(-0.5032) + \frac{5}{9}(-0.5123) = -0.278 + -0.447 + -0.285 = -1.01.$$
So,
$$I \approx 0.175 \times (-1.01) = -0.1767.$$
4. **Closed Newton-Cotes (Trapezoidal Rule, n=2):**
Nodes: $x_0=0$, $x_1=0.35$
$$I \approx \frac{b-a}{2} [f(x_0) + f(x_1)] = 0.175 [f(0) + f(0.35)].$$
Calculate:
- $f(0) = \frac{2}{0 - 4} = -0.5$
- $f(0.35) = -0.5123$ (from above)
Approximation:
$$I \approx 0.175 (-0.5 - 0.5123) = 0.175 \times (-1.0123) = -0.1772.$$
5. **Open Newton-Cotes (Midpoint Rule, n=2):**
For open formula with $n=2$, midpoint is at $x = \frac{a+b}{2} = 0.175$.
Approximate:
$$I \approx (b-a) f(0.175) = 0.35 \times (-0.5032) = -0.1761.$$
6. **Comparison:**
- Exact value: $-0.17675$
- Gaussian quadrature (n=3): $-0.1767$
- Closed Newton-Cotes (n=2): $-0.1772$
- Open Newton-Cotes (n=2): $-0.1761$
All methods give close approximations with Gaussian quadrature being the most accurate.