# Diffusion Mathematics

In no particular order, here are some common mathematical concepts often found in diffusion modeling. To simulate and quantify simple diffusion (e.g. 2D Brownian Motion) only requires a working knowledge of basic statistics and trigonometry. Modeling complex forms of diffusion requires the use of integral and vector calculus and differential geometry. There is a thin boundary between simple and complex diffusion and the math becomes dense very quickly. For example, using just a few lines of code, one can easily simulate stochastic diffusion on a flat 2D surface:

```
1 % MATLAB CODE %
2 Ndots = 100; Nsteps = Ndots;
3 D = .5; % Diffusion Rate
4 dm = 2; % dimensions
5 tau = 1; % time step
6 k = sqrt(dm*D*tau); % stdev of step-size distribution
7 xyl = ones(2,Ndots); xyds = xyl;
8
9 for t = 1:Nsteps
10 xyds = (k * randn(2,Ndots));
11 for j = 1:Ndots
12 xyl(:,j) = xyl(:,j)+xyds(:,j);
13 end
14 gscatter(xyl(1,:),xyl(2,:));
15 end
```

On the other hand, simulating stochastic diffusion on a ruffled 2D membrane is often done using parallel-computing systems at your local university's supercomputer center. However, with an understanding of the mathematical concepts that underlie complex diffusion, we can understand diffusion properties without a powerful computing cluster. I am a neuroscientist, not a mathematician or physicist, and based on my own personal trials and tribulations in modeling diffusion as a non-math expert, here are some concepts I needed to brush up on before getting serious about diffusion modeling...

## Partial Derivatives

In mathematics, a partial derivative of a function of several variables is its derivative with respect to one of those variables, with the others held constant (as opposed to the total derivative, in which all variables are allowed to vary). Partial derivatives are used in vector calculus and differential geometry.

The partial derivative of a function f with respect to the variable x is variously denoted by:

Read as: del F with respect to X equals...

Suppose that ƒ is a function of more than one variable. For instance:

The graph of this function defines a surface in Euclidean space. To every point on this surface, there are an infinite number of tangent lines. Partial differentiation is the act of choosing one of these lines and finding its slope. Usually, the lines of most interest are those that are parallel to the xz-plane, and those that are parallel to the yz-plane (which result from holding either y or x constant, respectively.) To find the slope of the line tangent to the function at P(1, 1, 3) that is parallel to the xz-plane, the y variable is treated as constant. The graph and this plane are shown on the right. On the graph below it, we see the way the function looks on the plane y = 1. By finding the derivative of the equation while assuming that y is a constant, the slope of ƒ at the point (x, y, z) is found to be:

So at (1, 1, 3), by substitution, the slope is 3. Therefore

at the point (1, 1, 3). That is, the partial derivative of z with respect to x at (1, 1, 3) is 3.

## Laplace Operator

In mathematics the Laplace operator or Laplacian is a differential operator given by the divergence of the gradient of a function on Euclidean space. It is usually denoted by the nabla symbols ∇·∇, ∇2 or ∆. The Laplacian ∆f(p) of a function f at a point p, up to a constant depending on the dimension, is the rate at which the average value of f over spheres centered at p, deviates from f(p) as the radius of the sphere grows.

more info or media

No additional media

## Gradients

The gradient (or gradient vector field) of a scalar function *f(x1, x2, x3, ..., xn)* is denoted ∇f or ^{→}∇f where ∇ (the nabla symbol) denotes the vector differential operator, del. The notation "grad(f)" is also commonly used for the gradient. The gradient of f is defined as the unique vector field whose dot product with any vector v at each point x is the directional derivative of f along v. That is,

In a rectangular coordinate system, the gradient is the vector field whose components are the partial derivatives of f:

where the ei are the orthogonal unit vectors pointing in the coordinate directions. When a function also depends on a parameter such as time, the gradient often refers simply to the vector of its spatial derivatives only. In the three-dimensional Cartesian coordinate system, this is given by

where i, j, k are the standard unit vectors. For example, the gradient of the function

is:

In some applications it is customary to represent the gradient as a row vector or column vector of its components in a rectangular coordinate system.