In the wave equation:

$$c^2 \nabla \cdot \nabla u(x,t) - \frac{\partial^2 u(x,t)}{\partial t^2} = f(x,t)$$

Why do we first multiply by a test function $v(x,t)$ before integrating?

  • 6
    $\begingroup$ Short answer: Because the finite element method is a discretization of the weak formulation, not the strong formulation (which you have given). Medium answer: Because you can't be sure to find a finite-dimensional function such that equation is satisfied; at best you can hope for the residual to be orthogonal to the finite-dimensional solution space -- or equivalently, orthogonal to any element of that space (which is precisely a test function). Integration by parts is not as important, and in your case for the sake of symmetry. Long answer is too long for a comment :) $\endgroup$ Commented Jul 30, 2015 at 16:43
  • 4
    $\begingroup$ Another short explanation: If you just integrate and set to zero, you are asking for the mean to vanish -- not at all what you are looking for, because then the residual could be very large in one part of the domain, as long as it is large with opposite sign in another. The test functions in essence "localize" the residual to each element. $\endgroup$ Commented Jul 30, 2015 at 16:53
  • $\begingroup$ For an alternative explanation, see this answer: scicomp.stackexchange.com/questions/16331/… $\endgroup$
    – Paul
    Commented Jun 12, 2019 at 17:00

2 Answers 2


You're coming at it backwards. The justification is better seen by starting from the variational setting and working towards the strong form. Once you've done this, the concept of multiplying by a test function and integrating can then be applied to problems where you don't start with a minimization problem.

So consider the problem where we want to minimize (and working formally and not rigorously at all here):

$$ I(u) = \frac {1}{2} \int_\Omega (\nabla u(x))^2 \; dx $$

subject to some boundary conditions on $\partial\Omega$. If we want this $I$ to reach a minimum, we need to differentiate it with respect to $u$, which is a function. There are several now well trod ways to consider this kind of derivative, but one way it's introduced is to compute

$$ I'(u(x),v(x))=\lim_{h\rightarrow 0} \frac{d}{dh}I(u(x)+hv(x)) $$

where $h$ is just a scalar. You can see that this is similar to the traditional definition of a derivative for scalar functions of a scalar variable but extended up to functionals like $I$ that give scalars back but have their domain over functions.

If we compute this for our $I$ (mostly using the chain rule), we get

$$ I'(u,v) = \int_\Omega \nabla u \cdot \nabla v \; dx $$

Setting this to zero to find the minimum, we get an equation which looks like the weak statement for Laplace's equation:

$$ \int_\Omega \nabla u \cdot \nabla v \; dx = 0 $$

Now, if we use the Divergence Theorm (aka multi-dimesional integration by parts), we can take a derivative off of $v$ and put it on $u$ to get

$$ -\int_\Omega \nabla \cdot (\nabla u) v \; dx + \text {boundary terms} = 0 $$

Now this really looks where you start when you want to build a weak statement from a partial differential equation. Given this idea now, you can use it for any PDE, just multiply by a test function, integrate, apply the Divergence Theorem, and then discretize.

  • 1
    $\begingroup$ I would prefer explaining it in terms of minimizing the weighted residual. $\endgroup$
    – nicoguaro
    Commented Jul 30, 2015 at 16:41
  • 3
    $\begingroup$ @nicoguaro, OK then you can write that answer, and we'll see which one makes more sense to OP. :) $\endgroup$
    – Bill Barth
    Commented Jul 30, 2015 at 16:46
  • $\begingroup$ +1 for pointing out that the weak form is actually (or at least often) more natural than the strong form. $\endgroup$ Commented Jul 30, 2015 at 16:47
  • 1
    $\begingroup$ Interesting. Kind of a tangent, but regarding "There are several now well trod ways to consider this kind of derivative": the only method I've learned is the one you've mentioned. What other kinds are there? $\endgroup$
    – user541686
    Commented Jul 30, 2015 at 21:38
  • 5
    $\begingroup$ @Mehrdad This method computes a directional derivative and verifies that it is a linear operator (in $h$) and hence a Gâteaux derivative. You can also come from the other direction: Guess a linear operator (e.g., by analogy with real functions) and verify that it satisfies a sort of first-order Taylor approximation property. Then it is a Fréchet derivative (and hence also a Gâteaux derivative). $\endgroup$ Commented Jul 30, 2015 at 23:49

As I mention before, I prefer to think about the weak form as a weighted residual.

We want to find an approximate solution $\hat{u}$. Let us define the residual as

$$R = c^2 \nabla \cdot \nabla \hat{u} - \frac{\partial^2 \hat{u}}{\partial t^2} - f(x,t)$$

for the case of the exact solution the residual is the zero function over the domain. We want to find an approximate solution that is "good", i.e., one that makes $R$ "small". So, we can try to minimize the norm of the residual (Least square methods, for example), or some average of it. One way of doing it is to compute the weighted residual, i.e., minimize the weighted residual

$$\int\limits_\Omega wR d\Omega$$

one important thing about this is that it defines a functional, so you can minimize it. This can work for functions that do not have a variational form. I describe a little bit more in this post. You can choose the function $w$ in different ways, like being of the same space of the function $\hat{u}$ (Galerkin methods), Dirac delta functions (collocation methods), or a fundamental solution (Boundary Elements Method).

If you select the first case, then you will end up with an equation like the one described by @BillBarth.

  • $\begingroup$ Note that what you are describing is more a projection of $R$ on $w$ rather than a minimization because there is no notion of variation of $R$ in your derivations. One way to read the weighted residual method is the following: the only function $R$ whose projections on all possible functions $w$ (that we can see as directions in a functional space) vanish is the "zero" function, as desired since we want to achieve $R=0$. $\endgroup$
    – pluton
    Commented Dec 18, 2023 at 4:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.