Skip to main content

Galerkin and collocation solution of an ODE

Short answer

Galerkin: weight x(1−x) gives a=5/18≈0.2778, u(0.5)=0.0694. Collocation at x=0.5: R(0.5)=0 gives a=2/7≈0.2857, u(0.5)=0.0714. Exact u(0.5)=0.06975. Galerkin, which averages the residual over the domain, is more accurate than single-point collocation.

Solve the boundary value problem

d2udx2+u+x=0,0≤x≤1,u(0)=u(1)=0\frac{d^2u}{dx^2} + u + x = 0,\qquad 0 \le x \le 1,\quad u(0) = u(1) = 0

using the trial function u=a x(1−x)u = a\,x(1-x) by (a) the Galerkin method and (b) the point collocation method at x=0.5x = 0.5. Compare u(0.5)u(0.5) with the exact solution u=sin⁡xsin⁡1−xu = \dfrac{\sin x}{\sin 1} - x.

Residual

With u=a x(1−x)u = a\,x(1-x): u′′=−2au'' = -2a. The trial function satisfies u(0)=u(1)=0u(0) = u(1) = 0.

R(x)=u′′+u+x=−2a+a x(1−x)+xR(x) = u'' + u + x = -2a + a\,x(1-x) + x

(a) Galerkin method

The weight function equals the trial function shape, W=x(1−x)W = x(1-x), and ∫01WR dx=0\int_0^1 W R\,dx = 0.

Needed integrals: ∫01x(1−x)dx=16\int_0^1 x(1-x)dx = \dfrac{1}{6}, ∫01x2(1−x)2dx=130\int_0^1 x^2(1-x)^2dx = \dfrac{1}{30}, ∫01x2(1−x)dx=112\int_0^1 x^2(1-x)dx = \dfrac{1}{12}.

∫01x(1−x) R dx=−2a(16)+a(130)+112=−3a10+112=0\begin{aligned} \int_0^1 x(1-x)\,R\,dx &= -2a\left(\frac{1}{6}\right) + a\left(\frac{1}{30}\right) + \frac{1}{12} \\ &= -\frac{3a}{10} + \frac{1}{12} = 0 \end{aligned} a=1036=518=0.2778a = \frac{10}{36} = \frac{5}{18} = 0.2778

u(0.5)=0.2778(0.5)(0.5)=0.06944u(0.5) = 0.2778(0.5)(0.5) = 0.06944.

(b) Point collocation at x=0.5x = 0.5

R(0.5)=−2a+a(0.25)+0.5=−1.75a+0.5=0⇒a=27=0.2857R(0.5) = -2a + a(0.25) + 0.5 = -1.75a + 0.5 = 0 \Rightarrow a = \frac{2}{7} = 0.2857

u(0.5)=0.2857(0.25)=0.07143u(0.5) = 0.2857(0.25) = 0.07143.

Comparison

Exact: u(0.5)=sin⁡0.5sin⁡1−0.5=0.479430.84147−0.5=0.06975u(0.5) = \dfrac{\sin 0.5}{\sin 1} - 0.5 = \dfrac{0.47943}{0.84147} - 0.5 = 0.06975.

Methodaau(0.5)u(0.5)Error
Galerkin0.27780.06944-0.4 %
Collocation0.28570.07143+2.4 %
Exact-0.06975-

Galerkin averages the residual over the whole domain, so it is more accurate than collocation, which forces zero residual only at one point.

Answer: Galerkin u=0.2778 x(1−x)u = 0.2778\,x(1-x), u(0.5)=0.0694u(0.5) = 0.0694; collocation u=0.2857 x(1−x)u = 0.2857\,x(1-x), u(0.5)=0.0714u(0.5) = 0.0714; exact 0.06980.0698.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Finite Element Method chapter 4 questions →