Solving the diffusion equation

I am trying to clarify the relation between random walk and diffusion, and the source book proposes the following which I can't get. Starting from the diffusion equation

$$\frac{\partial C}{\partial t} = D \frac{\partial^2 C}{\partial x^2},$$

how can this be solved to get

$$C = \frac{A}{\sqrt{t}} \mathrm{e}^{-x^2 / 4 D t} ?$$

-
What do you mean "differentiated"? If the diffusion coefficient $D(c)$ is a constant then the second expression is a solution of the diffusion equation with some simple boundary & initial conditions, which you can check by substituting it in. Are you asking how the diffusion equation is solved in the first place? –  Michael Brown Mar 2 '13 at 10:51
Also there are some changes in notation from the first line to the second: $C\rightarrow c$, $D(c)\rightarrow d$, $x\rightarrow z$. What source(s) are you using? –  Michael Brown Mar 2 '13 at 10:53
@MichaelBrown yes D(c) should be assumed as a constant. I am asking to how can i get the second expression as a solution to first equation. –  user21535 Mar 2 '13 at 10:57
@MichaelBrown sorry for the notation faults. x=z C=c and D(c)=d in the equations. –  user21535 Mar 2 '13 at 10:59
Ok. I've fixed up the question a bit (note that this site supports MathJax for equation rendering). So what have you tried so far? –  Michael Brown Mar 2 '13 at 11:16

The diffusion equation is a partial differential equation. The unknown quantity is a function $C(x,t)$. To complete the problem statement you need to specify an initial condition (at $t=0$) and boundary conditions. I'm guessing that your boundary conditions are at infinity, so we take

$$C(x,t) \rightarrow 0,\ x\rightarrow \pm \infty.$$

We take a delta function initial condition:

$$C(x, 0) = \delta(x).$$

The equation can be solved by using the Fourier transform:

$$C(x, t) = \int_{-\infty}^{\infty} \frac{\mathrm{d}k}{2\pi}\ \mathrm{e}^{i k x} C_k(t).$$

The inverse transform is

$$C_k(t) = \int_{-\infty}^{\infty} \mathrm{d}x\ \mathrm{e}^{-i k x} C(x, t).$$

So the transform of the initial condition is

$$C_k(0) = 1.$$

Substituting $C(x,t)$ in the diffusion equation gives

$$\int_{-\infty}^{\infty} \frac{\mathrm{d}k}{2\pi}\ \mathrm{e}^{i k x} \left( \dot{C}_k(t) + D k^2 C_k(t) \right) = 0.$$

This simplifies to

$$\dot{C}_k(t) + D k^2 C_k(t) = 0,$$

with the solution

$$C_k(t) = C_k(0) \mathrm{e}^{- D k^2 t} = \mathrm{e}^{- D k^2 t}.$$

Putting it all together

$$C(x, t) = \int_{-\infty}^{\infty} \frac{\mathrm{d}k}{2\pi}\ \mathrm{e}^{i k x} \mathrm{e}^{- D k^2 t},$$

and all that's left is to do the $k$ integral. Note that the $k$ integral is a Gaussian so, with a little massaging, you can do it with the formula

$$\int_{-\infty}^\infty \mathrm{d}y\ \mathrm{e}^{-y^2} = \sqrt{\pi}.$$

You should get

$$C(x,t) = \frac{1}{\sqrt{4 \pi D t}} \mathrm{e}^{-\frac{x^2}{4 D t}}.$$

-

Another technique of solving this would be through self-similarity as explained here: 1D Heat equation: method of self-similar solutions. The only thing you need to recognize is that the math for heat and concentration is the same here.

-
+1: Good stuff. Just to expand a bit for the OP's sake: scaling solutions are only applicable to some equations, but these include quite important equations, even nonlinear ones. When scaling works it can give great insight to the underlying phenomena. Fourier/Laplace transform techniques are broadly applicable to linear equations but do not necessarily give insightful solutions or rapid convergence. When in doubt both techniques are worth trying. –  Michael Brown Mar 2 '13 at 12:48

The other respondents have answered with math, so I'm going to try and express what they've said in words.

The solution you've written is called the impulse response. It shows what happens if you suddenly deposit a concentrated amount of heat at a single point. The heat spreads out into a Gaussian distribution which gets wider as it gets smaller. The product of the height and the width is a constant, because there is a constant quantity of heat. The width grows with the square root of time, just like the average displacement of the random walk.

You can do the same thing with Fourier Transforms if you know that the transform of a Gaussian is a Gaussian, except with reciprocal relations of width and height. You also have to know that under the diffusion equation, sine waves remain sine waves for all time, except they shrink; and the faster they wave, the faster they shrink. The rate of shrinking is quadratic in wave number, so sin(2x) shrinks four times as fast as sine(x).

(Like the Gaussian, the total quantity of heat is a constant, except for the sine waves that constant is zero because the positive heat is balanced by the negative heat.)

With Fourier Transforms, you take your initial spike function (the concentrated limit of a delta function) and transform it to a constant function. This tells you the spike is made up of a distribution of sine waves equally distributed according to wave number from zero to infinity. These all shrink according to the square of the wave number. So after a time T the function sin(x) has shrunk by T-squared, and the function sin(2x) has shrunk by 4-T-squared. If you draw a graph of all possible sine waves showing how much they've shrunk at time T, you will see that it's a Gaussian function. This is what the spike looks like in the frequency domain...to see what it looks like in the space domain, you have to take the Inverse Fourier Transform...which happens to be the same as taking a Fourier Transform. Since the Fourier Transform of a gaussian is just a gaussian, you have now shown that the spike in the space domain spreads out as a gaussian.

With a little more work you can convince yourself that the rate of spreading does in fact go as the square root of time, as implied by your original equation.

-