TL;DR
A test function is a probe. It is a function that is perfectly smooth, with no corners, jumps or sharp spikes, and it is zero everywhere outside some bounded interval. You multiply another function by a test function and integrate. The result is a number that depends on the other function's average behaviour near the probe's location. Test functions let mathematicians talk about rough objects using only integrals. The tool that makes this work is Integration by Parts, which moves a Derivative from the rough function onto the smooth probe.
Where you'll see it: in the definition of a Weak Solution of a differential equation, and in the theory of distributions, which generalises functions to objects like the Dirac delta (an idealised spike with total area 1 concentrated at a single point).
Intuition
A problem the probe solves
You know that the derivative of is for and for , but at there is a corner and no derivative. Physical problems often have such corners and jumps: a shock wave, a switch flipping, a beam with a kink. We still want to say something about their slope. The idea is to stop asking about single points and instead ask about averages, using a smooth weighting function as a probe.
The bump
Think of a smooth bump on a table. It rises from flat ground, reaches a peak, and falls back to flat ground, with no edges. Outside a small patch the table is flat, so the bump is zero there.
Now imagine you want to measure how much a rough function, say one with a jump, is doing around a point. You cannot read its slope at every point, since the slope may not exist. You can instead slide the bump along the line, multiply, and integrate. The integral reports a weighted average of the rough function, weighted by the bump. Corners and single points carry little weight, so the average is well defined. (The integral here is an ordinary definite integral: the area under the product of the two curves.)
The picture below shows one such bump. It is nonzero only inside the interval from to , and it fades smoothly to zero at both ends.
- bump
The bump is the building block. Every test function is a bump in this sense: smooth, and zero outside a bounded region.
The math
Definition
A function on the real line is a test function if it has two properties.
- It is infinitely differentiable. This means its derivatives , , and so on exist at every point and are continuous. In words, the function has no corners, kinks or jumps at any order.
- It has compact support. This means there is a bounded interval such that for every outside it. The support is the set where is not zero (together with its boundary points), and compact means bounded and closed.
The collection of all test functions on the real line is written . The symbol means infinitely differentiable, and the subscript means compact support.
The standard example is
Here is the exponential function, and is the absolute value. Inside the interval the exponent is finite. As approaches the exponent tends to , so tends to (a limit). At the edges vanishes, and so do all its derivatives. The exponential decays to zero faster than any power of the distance from the edge, which is why the bump is smooth across the boundary.
Why the probe is useful
Let be a locally integrable function, meaning its integral over any bounded interval is finite. Its action on a test function is the number
This integral is finite because vanishes outside a bounded interval, so only a bounded part of is ever seen. The integral can be computed even when has jumps, since jumps do not affect an integral.
Two facts make the probe useful. First, if is smooth, integration by parts from Integration by Parts lets the Derivative of move onto , with the boundary terms vanishing because has compact support:
Second, the right-hand side needs no derivative of at all. That is the key to defining weak derivatives.
Shifting and scaling
If is a test function and is any number, then is also a test function. It is the same bump, moved so that it is centred at . Scaling for a small positive number gives a narrower bump. Both operations keep smoothness and compact support, so they keep you inside .
Worked examples
Use for .
- At : , so the exponent is and .
- At : , so the exponent is and .
- At : , so the exponent is and .
- At , outside the interval: by definition.
- Interpretation: the values fall from about 0.37 at the centre to nearly zero close to the edge, and they reach zero exactly at . The fall is gradual, which is why the bump is smooth.
Take the standard bump and any smooth function . Show that and are equal, and that .
- Integrate directly. By the fundamental theorem of calculus, it equals .
- Since is zero outside , both endpoint values are . So .
- Now let , so . Then .
- Integrate by parts: . The bracket is zero because vanishes at both ends.
- So . This is an identity you can check numerically, and it holds for every test function.
The example shows the general rule: moving a derivative from the function onto the probe changes the sign and costs nothing else.
This is the example that connects test functions to real problems. Take the step function for and for . It has a jump at and no derivative there. Average it against a bump of width .
- Let be a bump, normalised so its total area is . Define . This is a narrower, taller bump with area still .
- The smoothed step is . Only the part with contributes, so .
- This is the cumulative area under the bump up to . It rises from to as passes through the bump.
- Because the bump is symmetric about , half its area lies to the left of . So .
- Interpretation: the sharp jump becomes a smooth ramp of width about , and the ramp is infinitely differentiable. As shrinks, the ramp approaches the jump. This averaging with test functions is exactly the procedure that makes weak derivatives well defined.
Recap: a test function is a smooth bump that is exactly zero outside a bounded interval. Pairing it with another function through an integral gives a number, the pairing lets derivatives be moved onto the bump, and so rough functions get a meaning for their derivatives. The next idea built on it is the Weak Solution.
Tradeoffs and failure modes
| Situation | Problem | Better choice |
|---|---|---|
| The function is already smooth and you need its pointwise values | Averaging loses detail at single points | Evaluate the function directly |
| The function is rough and you still need a meaning for its derivative | The pointwise derivative does not exist | Use the weak derivative defined with test functions |
| You need to probe fine detail at one location | A single bump averages over its whole width | Use a narrower bump, scaling by a small |
| You need a probe that is not zero far away | Compact support is required for the boundary terms to vanish | Multiply by a cutoff function, or work on a bounded domain |
A common failure is forgetting compact support. If a probe does not vanish far away, the boundary terms in integration by parts no longer disappear, and the weak derivative definition gives wrong results. Another pitfall is thinking a test function must be sharp. It is the opposite: the smoothness is what lets derivatives move onto it.
History
The idea of testing a function against smooth weights is older than the name. Sergei Sobolev used test functions in the 1930s to define the weak derivatives that now carry his name. Laurent Schwartz gave the full theory in the 1940s and early 1950s, calling the generalised objects distributions. In that theory the test functions form the space , and the distributions are the continuous linear functionals on it. The theory made it possible to treat the Dirac delta as a rigorous object. Later, weak solutions of differential equations, which accept solutions with jumps and kinks, were defined with exactly this machinery.
Check yourself
QuestionWhy must a test function be zero outside some bounded interval?Show answer
If the probe did not vanish far away, the integral of could be infinite, and the boundary terms in integration by parts would not disappear. Compact support keeps every integral finite and lets the boundary terms vanish, so the weak derivative definition works.
QuestionCompute for when .Show answer
The denominator is , so the exponent is . Then .
QuestionA bump is shifted to . Is the shifted function still a test function? Why?Show answer
Yes. Shifting moves the bump but does not change its smoothness, because the derivatives of are the shifted derivatives of . It is still zero outside a bounded interval, now centred at . So it still has compact support.
QuestionWhy does averaging a jump against a bump produce a smooth function, even though the jump itself is not smooth?Show answer
The averaged value at each point is an integral over a neighbourhood. Integrals smooth out sudden changes, because a single point has no weight. The smoothing bump is itself infinitely differentiable, and the average inherits smoothness from it, so the result is a smooth ramp rather than a jump.