Finite Element Weak Form Explained with Worked Examples

The weak form of (or ) with on the boundary is for every test function in the finite-element space . Choosing and from piecewise linear "hat" functions gives a matrix system.

Write 2x or 2*x to multiply, ^ for powers, and ; between simultaneous equations. You can also type factor, expand, derivative of, integrate … from a to b, limit … as x->0 or 15% of 80.

Try an example

Before you start

This page is easier if you are comfortable with:

What Finite element weak form means

Multiplying by and integrating by parts (integration by parts) moves one derivative onto , so only first derivatives appear; this is the setting of the Lax–Milgram theorem, which guarantees a solution. On with two elements of size the single interior hat function has , so for the load is and , , which equals the exact .

With four elements () the matrix is and the load is at each node, giving , again the exact values. For with two elements, the load is , so , equal to the exact at . In 1D the nodal values are exact; in higher dimensions they are approximate.

The matrix has the same structure as the one from the five-point stencil, and solves Poisson's equation; the weak form is the Euler–Lagrange form of an energy minimisation (the Euler–Lagrange equation).

What is it used for?

The weak form turns a differential equation into integrals that can be solved with simple piecewise functions.

How to use finite element weak form

  1. Multiply the equation by a test function and integrate by parts.
  2. Choose hat functions on the mesh.
  3. Assemble the stiffness matrix and the load vector .
  4. Solve the linear system for the nodal values.

Graph

Solution u = x(1 − x)/2 of −u″ = 1, with the element valuesu(0.5) = 0.125u(0.25) = 0.0937500.10.20.30.40.50.60.70.80.9100.020.040.060.080.10.120.14Solution u = x(1 − x)/2 of −u″ = 1, with the element valuesxuexact u = x(1 − x)/2Graph with x from 0 to 1 and y from 0 to 0.15. Shows the curve exact u = x(1 − x)/2; point u(0.5) = 0.125 at (0.5, 0.125); point u(0.25) = 0.09375 at (0.25, 0.09375).

The finite-element nodal values equal the exact values here.

Worked examples

These examples are worked by hand, step by step, so you can compare your own working.

Example 1: two elements

Solve , with two elements ().

Worked example
Answer
0.1250.125
  1. Stiffness
  2. Load
  3. u₁

Example 2: four elements

With four elements find the middle value from .

Worked example
Answer
0.1250.125
  1. Solution

Example 3: a different load

Solve with two elements; the load at the node is 0.25.

Worked example
Answer
0.06250.0625
  1. u₁

Special cases

A few situations come up again and again. Knowing them saves time and helps you spot answers that cannot be right.

Weak form

∫ u′v′ dx = ∫ f v dx for all v with v(0) = v(1) = 0

Multiply by v and integrate by parts.

Stiffness (h = 0.25)

K_ii = 2/h = 8, K_i,i±1 = −1/h = −4

Hat functions.

Load (f = 1)

F_i = h = 0.25

Integral of a hat.

Solution

u(0.25) = 0.09375, u(0.5) = 0.125

Exact at the nodes: x(1 − x)/2.

Word problems

For −u″ = f with u(0) = u(1) = 0, the weak form is ∫₀¹ u′v′ dx = ∫₀¹ fv dx. With piecewise-linear hat functions on a uniform mesh of width h, the stiffness matrix has 2/h on the diagonal and −1/h off it, and the load is hf for f = 1.

Stiffness

Find K_ii and K_i,i+1 for h = 0.25.

  1. 2/h8
  2. −1/h−4
  3. Check: ✓8 and −4.

Load

Find F_i for f = 1 and h = 0.25.

  1. h × 1
  2. Check: ✓0.25.

Check a row Higher

Check row 1 with u = (0.09375, 0.125, 0.09375): 8u₁ − 4u₂.

  1. 0.75 − 0.5
  2. Check: 0.25 = F₁ ✓0.25.

Exact comparison Higher

Compare u(0.5) with the exact x(1 − x)/2.

  1. 0.5 × 0.5 ÷ 2
  2. Check: 0.125 ✓0.125.

Common mistakes

Using h instead of 1/h

K_ii = 2h ✗

K_ii = 2/h ✓

Derivative squared gives 1/h.

Forgetting boundary values

including v(0) and v(1) ✗

test functions vanish there ✓

Dirichlet conditions.

Weak form with u″

keeping u″ ✗

integrate by parts to u′v′ ✓

That reduces smoothness.

Wrong load

F_i = f ✗

F_i = hf ✓

Integral of the hat.

Exam tips

  1. Multiply by v, integrate.
  2. Integrate by parts.
  3. K: 2/h, −1/h.
  4. F = hf for constant f.
  5. Nodes exact in 1D.

Practice questions

Try each one on paper, then open the answer. Use the solver above to see the full working.

1. K_ii for h = 0.5 Foundation

4

2. K_i,i+1 for h = 0.5 Foundation

-2

3. F_i for h = 0.1, f = 1 Foundation

0.1

4. 2/h for h = 0.2 Higher

10

5. Exact u(0.25) = x(1 − x)/2 Higher

0.09375

6. Row check 8 × 0.125 − 4 × 0.09375 × 2 Higher

0.25

Practice generator

Unlimited fresh questions with instant marking. Choose a level, work it out on paper, then type your answer.

Solve: …

Key terms

Weak form
Integral formulation of a PDE.
Test function (v)
Weighting function.
Hat function
Piecewise linear basis.
Stiffness matrix (K)
Matrix of ∫ φᵢ′φⱼ′.
Load vector (F)
Vector of ∫ fφᵢ.
Mesh width (h)
Element size.

Frequently asked questions

What is the weak form?

The integral equation obtained by multiplying by a test function and integrating by parts.

What is the stiffness matrix?

K_ij = ∫ φᵢ′φⱼ′ dx.

What are its entries on a uniform mesh?

2/h on the diagonal, −1/h off it.

What is the load vector for f = 1?

hf = h at each node.

Which page covers integration by parts?

integration by parts.

Which page covers the Laplacian stencil?

five-point Laplacian stencil.

More in Numerical methods and optimisation and the formula sheets.