Many physical systems can be modeled by a scalar-valued function of space and time. In the case when the second derivative with respect to time (that is the acceleration) is proportional to the second derivative with respect to space (that is the local convexity), the system exhibits wave behavior.
In one dimension, one can write ∂2f/∂t2=c2∂2f/∂x2 . The corresponding (scalar) second derivative with respect to space in higher dimensions is the divergence of the gradient. The gradient has as many dimensions as the domain space of the function in question, while the divergence (of a vector-vector function, such as the gradient) is a scalar (function). Thus, the general wave equation is the following partial differential equation:
∂2f/∂t2=c2div grad f
In the one-dimensional case the general solution is
f(x,t)=A(x-ct)+B(x+ct)where A and B are (twice) differentiable scalar functions. The above formula (the so-called d'Alambert solution) can be easily verified using the chain rule for differentiation.
The exact solution for higher dimensions also exists. It looks as follows:
f(x,t)=∫τ∫y |x-y|r-1D(y,τ+|x-y|/c)dydτwhere r is the dimensionality of x and D is the so-called excitation (or disturbance) function (a scalar function of time and space).
In numerical models, both time and space are (usually uniformly) quantized. Instead of differentials, we use differences. By simple calculations, one can see that the divergence of the gradient becomes the (appropriately scaled) difference between a sample point and the average of its neighbors.
A numeric simulation of the two-dimensional case using Euler's method
would have the following pseudo-code:
A java applet accomplishing the same on a 200 by 200 grid can be found below. Periodic excitation can be added by pressing the mouse button. Note the circular shape of the wavefronts, the reflections, the law of conservation of energy, the doppler effect and the increment of entropy.