“Know how to solve every problem that has been solved.” “What I cannot create, I do not understand.” — Richard Feynman

The trick behind finite elements: let the derivative hop

Micro-lessons

Zoom into any smooth curve far enough and it straightens out — that’s the whole intuition behind finite elements. Rather than chase one exact smooth solution, the method builds its answer out of many short linear pieces, fine enough that together they trace the curve. But stitch linear pieces together and you get a corner wherever two of them meet — a kink where the slope jumps. Here’s the snag: Poisson’s equation is written with a second derivative, and a corner doesn’t have one. So finite elements rewrite the equation first, into a form that only asks for first derivatives — and that rewrite is what makes the linear-pieces picture legal. Full page →

First, the picture

Picture the curve as a row of tent poles, one at each node. You set each pole’s height, and the fabric pulled tight between them is your linear-pieces curve. A hat function is what one pole does on its own: raise a single node to height 1, leave the rest flat, and you get one triangular tent — peaking at that node, dropping to zero by the next node on each side. Every curve is a sum of these tents, each scaled by its pole’s height, so the node heights are the only unknowns. Here are the curve and the tents that build it, together:

The curve, as linear pieces…built from hat functionsΣ tents = the curve aboveφ (one hat)
max error 0.049

The dashed line is the true smooth curve; the solid line traces it with linear pieces through the nodes. Below, that same curve is a sum of hat functions — each a triangle that’s 1 at its own node and 0 at its neighbors (the highlighted one is φ). Set the height of each tent, add them up — that’s the bold line through the peaks — and the curve on top reappears. Those node heights are the only unknowns. Slide Nto refine.

But why bother with tents at all?

Fair question — if the curve is just node heights joined by straight lines, the tents look like pure overhead. Here’s what the picture above hides: in a real problem you don’t know those node heights. They are the answer you’re solving for. You’re handed −u″ = f and asked to find the shape u; the heights fall out at the end, not the start.

So the point of a hat function is this: it lets a single number stand in for a whole piece of an unknown function. A computer can only solve for numbers — a finite list c₁, c₂, c₃, …. But −u″ = f is an equation about a function, with a value at infinitely many points, and you can’t hand a computer a function. So you multiply each fixed, pre-drawn tent by one unknown number and add them up:

u(x) = c₁ φ₁(x) + c₂ φ₂(x) + c₃ φ₃(x) + ⋯

Now the whole unknown function is pinned down by that finite list of numbers. Solve for them — the K c = b system you assemble below — and you have the function, without ever needing infinitely many values. That is the job: the tent is the adapter between the numbers a computer can find and the function the physics is written in. Its coefficient happening to equal the node value, and the matrix coming out sparse, are perks of choosing this shape — but a basis function exists at all because, without one, there is no way to put a PDE on a computer.

So how do you write one down?

A hat is two straight ramps glued at the peak. With nodes at positions x₀, x₁, x₂, …, the hat at node j is:

φⱼ(x) =
    (x − xⱼ₋₁) / (xⱼ − xⱼ₋₁)     for  xⱼ₋₁ ≤ x ≤ xⱼ      ↗ ramp 0→1
    (xⱼ₊₁ − x) / (xⱼ₊₁ − xⱼ)     for  xⱼ ≤ x ≤ xⱼ₊₁      ↘ ramp 1→0
    0                            everywhere else

On a uniform mesh with spacing h, that collapses to a single template — one reference tent shifted to each node:

φⱼ(x) = max(0, 1 − |x − xⱼ| / h)

// evaluate hat j at position x  (uniform mesh, spacing h)
const phi = (j, x) => Math.max(0, 1 - Math.abs(x - j*h) / h);

In real FEM code you don’t even store the global φⱼ. You keep only the two ramps on a reference element [0, 1]N₀(ξ) = 1 − ξ and N₁(ξ) = ξ — and build every hat, and every integral, by mapping those two little functions onto each element. Two lines of algebra, reused everywhere.

So a test function is just a probe. You can’t check −u″ = f at infinitely many points, so instead you multiply it by a probe v and integrate — a single weighted check. Insist that the equation balance against every tent-shaped probe and that is exactly as strong as checking it everywhere — but it only ever needs integrals, never point values. The weak form is that idea written down.

The move

Start from 1D Poisson, −u″ = f. The strong form demands u be twice differentiable at every point. Multiply by a test function v (zero at the boundary), integrate, and integrate by parts once. The boundary term dies because v = 0 at the ends, and you’re left with:

∫ u′ v′ dx  =  ∫ f v dx   for all admissible v.

Look at what happened: the u″ is gone. It became a u′, paired symmetrically with v′. Integration by parts moved the derivative — one hopped off u and onto v.

Why that hop changes what is solvable

Take that same linear-pieces shape from the first board and look at its derivatives. Drag the interior node heights: the first derivative stays fine, but the second blows up at the corners.

u (the function)u′ (its slope)u″ (curvature)

That bottom row (u″) is a train of Dirac spikes at the corners — infinitely tall, not a function. That is exactly why the strong form can’t touch these shapes.

Strong form−u″ = fneeds u″ — undefined at every corner
Weak form∫u′v′ = ∫fvneeds only u′ — finite, corners welcome

Integration by parts moved one derivative off u and onto v. That single hop drops the smoothness demand from u″ to u′ — exactly enough to let these corner-having hat functions into the game.

the half-derivative of slack

A hat function’s slope is piecewise-constant — perfectly square-integrable. But its second derivative is a train of Dirac spikes at the kinks: not a function at all. So −u″ = f is literally undefined for these functions. The weak form only ever asks for ∫u′v′, which stays finite — so it happily admits the corner-having functions the strong form can’t touch. The hop didn’t just tidy the algebra; it enlarged the space of allowed solutions to the exact one FEM needs.

What falls out of it

Because u and v now enter symmetrically, using the same basis for both (Galerkin) gives a symmetric stiffness matrix K_ij = ∫ φ_i′ φ_j′ dx — Poisson is self-adjoint and the weak form keeps it that way. Boundary conditions split too: Dirichlet gets baked into the function space (essential), while Neumann falls out of the very boundary term you dropped (natural). And restricting v to a finite basis turns the whole thing into K c = b. The weak form is the bridge from “a PDE” to “a linear system.”

Seen this before? Sinc functions.

If this rings a bell from signal processing, trust it. A hat function is a cardinal function — 1 at its own node, 0 at every other — so the coefficients are just the sample values and you rebuild the whole thing by summing scaled copies. That is exactly the Shannon sampling story: a band-limited signal is reconstructed from its samples as Σ s(n)·sinc(x − n), and sinc is 1 at its own sample and 0 at all the others — a hat function’s twin.

The difference is reach. A hat is local — zero outside its two elements — so it only bends the curve nearby. That is what keeps FEM’s matrix sparse, but it caps the accuracy at piecewise-linear. A sinc is global — it rings across the whole line — so it reproduces any band-limited function exactly, at the price of every sample coupling to every other (a dense system). Local tents versus global sincs is precisely the divide between finite-element and spectral methods.

Say it, don’t just nod

Why can the weak form use piecewise-linear basis functions when the strong form −u″ = f can’t?

A piecewise-linear function has no second derivative at its kinks — u″ there is a Dirac spike, not a value — so −u″ = f is undefined at every corner.

The weak form only requires ∫u′v′, and u′ is piecewise-constant (square-integrable), so the integral is perfectly finite. Integration by parts bought exactly the one derivative of regularity you needed to trade away.