The equation is usually written as:whereϕ(r,t) is thedensity of the diffusing material at locationr and timet andD(ϕ,r) is the collectivediffusion coefficient for densityϕ at locationr; and∇ represents the vectordifferential operatordel. If the diffusion coefficient depends on the density then the equation is nonlinear, otherwise it is linear.
The equation above applies when the diffusion coefficient isisotropic; in the case of anisotropic diffusion,D is a symmetricpositive definite matrix, and the equation is written (for three dimensional diffusion) as:The diffusion equation has numerous analytic solutions.[1]
The diffusion equation can be trivially derived from thecontinuity equation, which states that a change in density in any part of the system is due to inflow and outflow of material into and out of that part of the system. Effectively, no material is created or destroyed:wherej is the flux of the diffusing material. The diffusion equation can be obtained easily from this when combined with the phenomenologicalFick's first law, which states that the flux of the diffusing material in any part of the system is proportional to the local density gradient:
If drift must be taken into account, theFokker–Planck equation provides an appropriate generalization.
The diffusion equation is continuous in both space and time. One may discretize space, time, or both space and time, which arise in application. Discretizing time alone just corresponds to taking time slices of the continuous system, and no new phenomena arise.In discretizing space alone, theGreen's function becomes thediscrete Gaussian kernel, rather than the continuousGaussian kernel. In discretizing both time and space, one obtains therandom walk.
Theproduct rule is used to rewrite the anisotropic tensor diffusion equation, in standard discretization schemes, because direct discretization of the diffusion equation with only first order spatial central differences leads to checkerboard artifacts. The rewritten diffusion equation used in image filtering:where "tr" denotes thetrace of the 2nd ranktensor, and superscript "T" denotestranspose, in which in image filteringD(ϕ,r) are symmetric matrices constructed from theeigenvectors of the imagestructure tensors. The spatial derivatives can then be approximated by two first order and a second order centralfinite differences. The resulting diffusion algorithm can be written as an imageconvolution with a varying kernel (stencil) of size 3 × 3 in 2D and 3 × 3 × 3 in 3D.