---
title: "Galerkin and collocation solution of an ODE"
subject: "Finite Element Method"
chapter: 4
key: "semester_8/finite_element_method:galerkin-collocation-ode"
source: https://www.bctengineer.com/q/semester_8/finite_element_method/galerkin-collocation-ode
site: BCT Engineering
---

# Galerkin and collocation solution of an ODE

Finite Element Method · Chapter 4: Continuum Problems

- Asked in: year not given, 8 marks
- Video: [Solve Galerkin's Method and compare with Exact Solution](https://www.youtube.com/watch?v=aZR3XieEYlc) — KanithaPezhai
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_8/finite_element_method/galerkin-collocation-ode
- Whole chapter: https://www.bctengineer.com/md/semester_8/finite_element_method/chapter-4

## Question

Solve the boundary value problem
$$
\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)$ by (a) the Galerkin method and (b) the point collocation method at $x = 0.5$. Compare $u(0.5)$ with the exact solution $u = \dfrac{\sin x}{\sin 1} - x$.

## 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.

## Answer

#### Residual

With $u = a\,x(1-x)$: $u'' = -2a$. The trial function satisfies $u(0) = u(1) = 0$.
$$
R(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)$, and $\int_0^1 W R\,dx = 0$.

Needed integrals: $\int_0^1 x(1-x)dx = \dfrac{1}{6}$, $\int_0^1 x^2(1-x)^2dx = \dfrac{1}{30}$, $\int_0^1 x^2(1-x)dx = \dfrac{1}{12}$.
$$
\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 = \frac{10}{36} = \frac{5}{18} = 0.2778
$$
$u(0.5) = 0.2778(0.5)(0.5) = 0.06944$.

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

$$
R(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.07143$.

#### Comparison

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

| Method | $a$ | $u(0.5)$ | Error |
|---|---|---|---|
| Galerkin | 0.2778 | 0.06944 | -0.4 % |
| Collocation | 0.2857 | 0.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.5) = 0.0694$; collocation $u = 0.2857\,x(1-x)$, $u(0.5) = 0.0714$; exact $0.0698$.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. For u = a x(1-x), what is the residual R?
   A. -2a + a x(1-x) + x
   B. 2a + a x(1-x) + x
   C. -2a + x
   D. a x(1-x) + x
   Answer: A. u'' = -2a, so R = u'' + u + x = -2a + a x(1-x) + x. (Key point: Residual)

2. What weight function does the Galerkin method use?
   A. Dirac delta at x = 0.5
   B. The trial function shape x(1-x)
   C. R itself
   D. Unity
   Answer: B. Galerkin uses weight equal to the trial function and sets the integral of W R to zero. (Key point: Galerkin weight)

3. What is a from the Galerkin method?
   A. 2/7
   B. 1/6
   C. 5/18
   D. 1/2
   Answer: C. -3a/10 + 1/12 = 0 gives a = 10/36 = 5/18 = 0.2778. (Key point: Galerkin value)

4. What is a from point collocation at x = 0.5?
   A. 5/18
   B. 0.5
   C. 1/4
   D. 2/7 = 0.2857
   Answer: D. R(0.5) = -1.75a + 0.5 = 0 gives a = 2/7. (Key point: Collocation)

## Related in Finite Element Method

- [Ritz solution of beam under uniform load](https://www.bctengineer.com/question.md?key=semester_8%2Ffinite_element_method%3Aritz-simply-supported-beam) — Finite Element Method, chapter 4
- [Compare weighted residual methods](https://www.bctengineer.com/question.md?key=semester_8%2Ffinite_element_method%3Aweighted-residual-methods-compare) — Finite Element Method, chapter 4
- [Simply supported beam with two elements](https://www.bctengineer.com/question.md?key=semester_8%2Ffinite_element_method%3Asimply-supported-beam-two-elements) — Finite Element Method, chapter 3
- [Gauss quadrature numerical integration](https://www.bctengineer.com/question.md?key=semester_8%2Ffinite_element_method%3Agauss-quadrature-integration) — Finite Element Method, chapter 7

## Related in other subjects

- [Solve ODE by Laplace transform y''+3y'+2y=e^(−t)](https://www.bctengineer.com/question.md?key=semester_3%2Fmathematics_iii%3Asolve-ode-by-laplace-transform-y-two) — Mathematics III, chapter 3, asked 18×
- [Solve ODE by Laplace transform y''+4y'+3y=0](https://www.bctengineer.com/question.md?key=semester_3%2Fmathematics_iii%3Asolve-ode-by-laplace-transform-y-four) — Mathematics III, chapter 3, asked 18×
- [Solve ODE by Laplace transform x''+2x'+5x=e^(−t)sint](https://www.bctengineer.com/question.md?key=semester_3%2Fmathematics_iii%3Asolve-ode-by-laplace-transform-x) — Mathematics III, chapter 3, asked 17×
- [Solve ODE by Laplace transform y''+2y'+2y=5sinx](https://www.bctengineer.com/question.md?key=semester_3%2Fmathematics_iii%3Asolve-ode-by-laplace-transform-y-17) — Mathematics III, chapter 3, asked 17×
