Finite Element & Finite Volume Methods

a test function

Imagine you want to check whether a long ruler is perfectly straight, but you are not allowed to look at it directly — you can only lay differently shaped templates against it and measure the total gap. If every template you try shows zero net gap, the ruler must be straight. A test function plays that template role for a differential equation: it is a 'probe' you multiply the equation by, then integrate, so that satisfying the equation against EVERY probe forces the equation to hold.

In the weak formulation of a PDE you multiply the equation by a test function v and integrate over the domain. The requirement 'this integral identity holds for all admissible v' is what pins down the solution. The space of allowed test functions matters: typically they are required to vanish on the part of the boundary where the solution's value is already prescribed (the essential boundary), because there is nothing left to test there. In the Galerkin method the cleverest choice is to draw the test functions from the SAME finite-dimensional space as the solution's shape functions — so the equation is enforced against each basis function in turn, giving exactly as many equations as unknowns.

The name comes from how the function is used, not what it is. Other communities call it a weight function (you are weighting the residual) or a virtual displacement (in mechanics, an imagined small motion consistent with the constraints — the principle of virtual work). The honest subtlety: choosing test functions different from the trial/shape functions gives Petrov-Galerkin methods, which can be more stable for advection-dominated problems but are trickier to analyse; the plain Galerkin choice (test = trial space) is the default and is what makes the resulting stiffness matrix symmetric for symmetric problems.

On a mesh of hat functions phi_1, ..., phi_N, the Galerkin method takes each test function in turn: setting v = phi_i in the weak form integral(u' v') = integral(f v) for i = 1, ..., N produces N equations, the i-th being the i-th row of the stiffness system K u = F. Same family supplies both the trial expansion of u and the test probes.

Testing the weak form against each basis hat function yields one row of the linear system.

Test functions must vanish where the solution is prescribed (the essential boundary) — they probe only where the solution is genuinely unknown. Confusing the test space with the trial space is fine in Galerkin methods, but they are conceptually distinct roles.

Also called
weight functiontrial probeweighting function權函數檢驗函數