The diffusion equation is a partial differential equation which describes density dynamics in a material undergoing diffusion. It is also used to describe processes exhibiting diffusive-like behaviour, for instance the 'diffusion' of alleles in a population in population genetics.
The equation is usually written as:
where ϕ(r, t) is the density of the diffusing material at location r and time t and D(ϕ, r) is the collective diffusion coefficient for density ϕ at location r; and ∇ represents the vector differential operator del. If the diffusion coefficient depends on the density then the equation is nonlinear, otherwise it is linear.
If D is constant, then the equation reduces to the following linear differential equation:
also called the heat equation.
Historical origin 
The diffusion equation can be derived in a straightforward way from the continuity 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:
where j is the flux of the diffusing material. The diffusion equation can be obtained easily from this when combined with the phenomenological Fick's first law, which assumes that the flux of the diffusing material in any part of the system is proportional to the local density gradient:
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, the Green's function becomes the discrete Gaussian kernel, rather than the continuous Gaussian kernel. In discretizing both time and space, one obtains the random walk.
Discretization (Image) 
The product 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 the trace of the 2nd rank tensor, and superscript "T" denotes transpose, in which in image filtering D(ϕ, r) are symmetric matrices constructed from the eigenvectors of the image structure tensors . The spatial derivatives can then be approximated by two first order and a second order central finite differences. The resulting diffusion algorithm can be written as an image convolution with a varying kernel (stencil) of size 3 × 3 in 2D and 3 × 3 × 3 in 3D.
See also 
- Heat equation
- Fokker-Planck equation
- Fick's law of diffusion: Fick's Second Law
- Maxwell-Stefan equation
- Radiative transfer equation and diffusion theory for photon transport in biological tissue
- A. Fick, Ueber Diffusion, Pogg. Ann. Phys. Chem. 170 (4. Reihe 94), 59-86 (1855).
2. Carslaw, H. S. and Jager, J. C. (1959). Conduction of Heat in Solids. Oxford: Clarendon Press
3. Crank, J. (1956). The Mathematics of Diffusion. Oxford: Clarendon Press
4. Thambynayagam, R. K. M (2011). The Diffusion Handbook: Applied Solutions for Engineers: McGraw-Hill