On this page
The finite element method (FEM) turns a differential equation into a small system of linear equations by building the answer out of simple pieces. Wikipedia's finite element method article traces its development to work by Alexander Hrennikoff and Richard Courant in the early 1940s.
We will solve one problem end to end by hand: −u″ = 1 on [0, 1] with u(0) = u(1) = 0. Its exact solution is u(x) = x(1 − x)/2, the same model problem used in Per-Olof Persson's finite element lecture notes, so you can check every number.
What is the finite element method in one dimension?
Cut [0, 1] into elements of width h. Here we use three, so h = 1/3 and the nodes are 0, 1/3, 2/3 and 1. Look for an answer that is straight on each element and continuous at the nodes.
Any such function can be written with hat functions. The hat φᵢ equals 1 at node xᵢ, 0 at every other node, and is linear in between, so it looks like a tent of width 2h. The approximation is uₕ(x) = U₁φ₁(x) + U₂φ₂(x), and each coefficient Uᵢ is simply the value of uₕ at node i.
How do you get the weak form of −u″ = 1?
Multiply the equation by a test function v that is zero at both ends, integrate over [0, 1], and integrate by parts. The boundary term vanishes because v(0) = v(1) = 0, and you are left with the weak form:
∫ u′v′ dx = ∫ v dx, for every allowed v.
This asks for one derivative of u instead of two, which is why kinked hat functions are allowed. The Galerkin step is to demand this only for v = φ₁ and v = φ₂, which gives two equations for two unknowns.
How are the stiffness matrix and load vector built?
Each hat has slope +1/h on its left element and −1/h on its right element. That gives three integrals worth knowing:
Diagonal entry: ∫ (φᵢ′)² dx = (1/h²) × 2h = 2/h.
Neighbour entry: ∫ φᵢ′φᵢ₊₁′ dx = (1/h)(−1/h) × h = −1/h, because the two hats overlap on one element only.
Any pair further apart: 0, because the hats never overlap.
So the stiffness matrix is K = tridiag(−1, 2, −1)/h. The load vector has entries Fᵢ = ∫ φᵢ dx, the area of a tent with base 2h and height 1, which is h. Persson's notes give the same element matrix (1/h)[1 −1; −1 1] and the same load for f = 1, and note that this discretisation exactly matches the second-order three-point finite difference stencil.
A worked 3-element solve
With h = 1/3, the matrix entries are 2/h = 6 and −1/h = −3, and each load entry is 1/3:
Write the system: 6U₁ − 3U₂ = 1/3 and −3U₁ + 6U₂ = 1/3.
Use symmetry: the problem is symmetric about x = 1/2, so U₁ = U₂.
Solve: 6U₁ − 3U₁ = 1/3 gives U₁ = U₂ = 1/9.
Compare with the exact answer: u(1/3) = (1/3)(2/3)/2 = 1/9, and u(2/3) = 1/9.
Both nodal values are exact. Between the nodes they are not: at x = 1/2 the finite element answer is 1/9 while the true value is 1/8, a gap of 1/72.
Why are the nodal values exact here?
In a 2021 paper, Cristina Bacuta and Constantin Bacuta show that for −u″ = f on (0, 1) with zero end values, the piecewise-linear finite element solution coincides with the linear interpolant of the true solution at the nodes, with nodes spaced evenly or not. They describe it as an extension of the Green's function formula.
The idea: the value of u at a node can be written using the Green's function for that node. For −u″ that Green's function is a tent with its kink at the node, so it lies in the hat space. The finite element error is orthogonal to that space, so it vanishes at every node. In two or three dimensions this exactness is generally lost.
With four elements (h = 1/4), Persson's notes give U = (3/32, 1/8, 3/32), again equal to x(1 − x)/2 at the nodes. Larger tridiagonal systems are easier once you know LU decomposition with a worked 3×3 example or Jacobi and Gauss–Seidel iteration, and the finite difference method for the heat equation uses the same tridiagonal matrix.
If integration by parts or Green's functions are the shaky step, the Fermi Concept Library has a lesson for each concept in mathematics and shows where it sits on the map. For practice, the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning rather than printing an answer.



