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?
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?
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.
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.