Given differential equation $ \frac{d^2 \phi}{dx^2} + cos\pi x = 0 $ where $ 0 \leq x \leq 1 $ with boundary conditions $ \phi (0) = 0; \phi (1) = 0 $
Approximate solution is given by,
$ \phi = C_0 + \sum [C_i sin (\frac{\pi}{2}(2i-1)x)] $ ......(0)
At x = 0, $\phi = 0, \,\,\, \therefore C_0 = 0 \\
\therefore \phi = \sum [C_i sin (\frac{\pi}{2}(2i-1)x)] $
Since the order of D.E is 2, so i will be of order 3
$ \therefore \phi = C_1 sin (\frac{\pi x}{2}) + C_2 sin (\frac{3\pi x}{2}) + C_3 sin (\frac{5\pi x}{2}) $
At x = 1, $\phi = 0 $
$ \therefore 0 = C_1 - C_2 + C_3 \\
\therefore C_2 = C_1 + C_3 $
Equation (1) becomes,
$ \phi = C_1 sin (\frac{\pi x}{2}) + (C_1 + C_3) sin (\frac{3\pi x}{2}) + C_3 sin (\frac{5\pi x}{2}) \\
\phi = C_1[ sin (\frac{\pi x}{2}) + sin (\frac{3\pi x}{2})] + C_3 [sin (\frac{3\pi x}{2}) + sin (\frac{5\pi x}{2})] $
Differentiating the above equation, we get,
$ \frac{d\phi}{dx} = C_1\frac{\pi}{2}[cos(\frac{\pi x}{2}) + 3 cos(\frac{3\pi x}{2}) + C_3\frac{\pi}{2}[3cos(\frac{3\pi x}{2}) + 5cos(\frac{5\pi x}{2}) $
Again differentiating above equation, we get,
$ \frac{d^2\phi}{dx^2} = -C_1 \frac{\pi^4}{4}(sin\frac{\pi x}{2} + 9sin\frac{3 \pi x}{2}) - C_3 \frac{\pi^2}{4}(9sin\frac{3 \pi x}{2} + 25sin\frac{5 \pi x}{2}) $
Residual function is given by,
$ - \frac{d^2\phi}{dx^2} - cos\pi x = R $
Substituting the value of $ (- \frac{d^2\phi}{dx^2}) $ in above equation, we get,
$ \frac{\pi^4}{4} [C_1 (sin\frac{\pi x}{2} + 9sin\frac{3 \pi x}{2}) + C_3 (9sin\frac{3 \pi x}{2} + 25sin\frac{5 \pi x}{2})] - cos \pi x = R $
Weighted Integral form,
$ \int_0^1 w_i R \,\, dx = 0 $
w$_i$ = coefficient of constant from $\phi$
For i = 1, $ w_1 = sin \frac{\pi x}{2} + sin \frac{3 \pi x}{2} \\
\therefore \frac{\pi^2}{4} \int_0^1 (sin \frac{\pi x}{2} + sin \frac{3 \pi x}{2}) [C_1 (sin\frac{\pi x}{2} + 9sin\frac{3 \pi x}{2}) + C_3 (9sin\frac{3 \pi x}{2} + 25sin\frac{5 \pi x}{2}) - cos \pi x] \,\, dx = 0 \\
5C_1 + 2.84C_3 - 0.069 = 0 \\
5C_1 + 2.84C_3 = 0.069 \,\,\,\,\, .....(A)$
For i = 2, $ w_2 = sin \frac{3 \pi x}{2} + sin \frac{5 \pi x}{2} \\
C_1 \int_0^1 (sin\frac{3 \pi x}{2} + sin\frac{5 \pi x}{2}) (sin \frac{\pi x}{2} + sin \frac{3 \pi x}{2}) \,\, dx + C_3 \int_0^1 (sin\frac{3 \pi x}{2} + sin\frac{5 \pi x}{2}) (9 sin\frac{3 \pi x}{2} + 25 sin\frac{5 \pi x}{2}) \,\, dx - \int_0^1 (sin\frac{3 \pi x}{2} + sin\frac{5 \pi x}{2}) cos \pi x \,\, dx = 0 \\
3.9C_1 +14.75C_3 - 0.207 = 0 \\
\therefore 3.9C_1 +14.75C_3 = 0.207 \,\,\,\,\,\, .....(B) $
Solving (A) and (B), we get,
C$_1$ = 0.0069 and C$_3$ = 0.0122
Approximate solution is given by,
$ \phi = 0.0069 (sin \frac{\pi x}{2} + sin \frac{3 \pi x}{2}) + 0.0122(sin \frac{3 \pi x}{2} + sin \frac{5 \pi x}{2}) $
i) At x = 0.25; $\phi$ = 0.02210
ii) At x = 0.5; $\phi$ = 0.03155
iii) At x = 0.75; $\phi$ = 0.0249
Exact solution:
$ - \frac{d^2 \phi}{dx^2} - cos \pi x = 0 \\
i.e. - \frac{d^2 \phi}{dx^2} = cos \pi x $
Integrating above equation, we get,
$ - \frac{d \phi}{dx} = - sin \frac{\pi x}{\pi} + C_1 $
Again integrating, we get,
$ - \phi = - cos \frac{\pi x}{\pi^2} + C_1x + C_2 \\
C_2 = \frac{1}{\pi^2} $
Imposing boundary condition
At x = 0; $\phi$ = 0
$ 0 = - \frac{1}{\pi^2} + C_2 \\
\frac{1}{\pi^2} = C_2 $
$ \therefore - \phi = - cos \frac{\pi x}{\pi^2} + C_1x + \frac{1}{\pi^2} $
At x = 1; $\phi_1$ = 0
$ \therefore 0 = \frac{1}{\pi^2} + C_1 + \frac{1}{\pi^2} \\
C_1 = - \frac{2}{\pi^2} \\
\therefore - \phi = - cos \frac{\pi x}{\pi^2} - \frac{2x}{\pi^2} + \frac{1}{\pi^2} \\
\therefore \phi = cos \frac{\pi x}{\pi^2} + \frac{2x}{\pi^2} - \frac{1}{\pi^2} $
At x = 0.25; $\phi$ = 0.0207
At x = 0.5; $\phi$ = 0
At x = 0.75; $\phi$ = - 0.02098