# Diffusion in an interval with zeroed boundaries

I am attempting to solve the diffusion equation $$\left( \partial / \partial t - D (\partial/\partial x)^2 \right) p = J$$ where $$p$$ is the probability density, $$J$$ is a source, and $$D$$ is the diffusion coefficient. In particular, I'd like to solve this over the finite interval $$[0, 1]$$ with boundary conditions such that $$(\partial p/\partial x)(x\in\{0,1\})=0$$, i.e. zero space derivative at the boundaries. Furthermore, we consider a point source $$J(x, t) = \delta(x - x_0)\delta(t - t_0) \, .$$ As the equation is linear with constant coefficients, it seems we should solve it via Fourier transformation (also known as "separation of variables"). To that end, write $$p(x, t) = \int \frac{d\omega}{2\pi} e^{i \omega t} \sum_{k=-\infty}^\infty e^{i 2\pi k x} \tilde{p}_k(\omega)$$ where $$\tilde{p}_k(\omega) = \int_{-\infty}^\infty p_k(t) e^{-i \omega t} \, dt$$ is the time-domain Fourier transform of $$p_k(t)$$, which are the coefficients of the space-domain Fourier series $$p(x, t) = \sum_{k=-\infty}^\infty e^{i 2\pi k x} p_k(t) \, .$$ Also note that $$J(x, t) = \int \frac{d\omega}{2\pi} \sum_{k=-\infty}^\infty e^{i \omega (t - t_0)} e^{i2\pi k (x - x_0)} \, .$$

Here's where I get fuzzy. I believe that the following are true:

• I do not need to do anything special to ensure that the final solution is real. The source $$J$$ is real and the diffusion equation is such that it will not create any imaginary content from that real source.
• I do need to do something to enforce the boundary conditions. In particular, I think it's convenient to rewrite the Fourier series in terms of $$\sin$$ and $$\cos$$.

So, let's rewrite the sum over $$k$$ like this: $$\tilde{p}_0(\omega) + \sum_{k=1}^\infty \left( \tilde{p}_k(\omega) + \tilde{p}_{-k}(\omega) \right) \cos(2 \pi k x) + \left(\tilde{p}_k(\omega) - \tilde{p}_{-k}(\omega) \right) \sin(2\pi k x) \, .$$ I think that the boundary conditions are satisfied if the $$\sin$$ terms vanish, which I think requires $$\tilde{p}_k(\omega) = \tilde{p}_{-k}(\omega)$$.

Question: Have I made a mistake yet?

Now let's stuff our Fourier representations of $$p$$ and $$J$$ into the diffusion equation. Let $$A_k(\omega) \equiv \tilde{p}_k(\omega) + \tilde{p}_{-k}(\omega)$$ to clean up the notation.

\begin{align} \left( \partial / \partial t - D (\partial / \partial x)^2 \right) \int \frac{d\omega}{2\pi} e^{i \omega t} \left[ \tilde{p}_0(\omega) + \sum_{k=1}^\infty A_k(\omega) \cos(2\pi k x) \right] &= \underbrace{\int \frac{d \omega}{2\pi} \sum_{k=-\infty}^\infty e^{i \omega (t - t_0)} e^{i 2\pi k (x - x_0)}}_{J(x, t)} \\ \text{let A_0 = p_0} \quad \left( \partial / \partial t - D (\partial / \partial x)^2 \right) \int \frac{d\omega}{2\pi} \sum_{k=0}^\infty A_k(\omega) e^{i \omega t} \cos(2\pi k x) &= \\ \int \frac{d\omega}{2\pi} \sum_{k=0}^\infty (i\omega + D(2\pi k)^2 )A_k(\omega) e^{i \omega t} \cos(2\pi k x) &= \\ \end{align} Now normally at this point we invoke an orthonormality statement (or in the language of separation of variables, we multiply each side by $$\cos(2\pi k x)$$ and integrate) to match coefficients term-by-term on the left and right, giving us an algebraic equation in the Fourier domain. The problem, however, is that the sums over $$k$$ on the left and right run over different values. In particular, the sum on the right (the expansion of $$J$$) includes the $$\sin$$ terms that I claimed have to be zero to satisfy the boundary conditions.

Question: What is going on here?

It seems that, maybe, a delta function source simply violates the boundary conditions, i.e. because if we write the delta function as a sequence of e.g. increasingly narrow Gaussian functions, each element in that sequence does not satisfy the boundary conditions (unless $$x_0 = 1/2$$). Am I on the right track, or have I made a mistake already?

This is a crosspost. The original post is here on the math site. I'm reposting here because while I got an answer on the Math site, the author of that answer hasn't responded to what I think is an important comment on that answer, and no further answers have appeared.

• $\{\rm{cos} (n\pi x)\};n=01,1,2,...$ is complete in the interval $[0,1]$ for functions $f(x)$ satisfying $f'(0)=f'(1)=0$. The corresponding cosine series represents an even function whose period is $2$. Dec 23, 2021 at 18:19
• @hyportnex Ok that seems worth trying. Do you see why what I did is wrong? Is it even wrong? Dec 23, 2021 at 20:13
• (mistakenly I left the comment here but it was really intended to comment on your question to @FelixMarin on math.stck). It is not that is "wrong", I just wanted to say that the functions $\rm{cos}(2\pi n x) ; n=0,1,2,...$ are not complete on $[0,1]$, as you can see that from the implied restriction that their derivatives are all zero at $x=1/2$ so these can only be used to expand functions that also satisfy $f'(1/2)=0$. Dec 23, 2021 at 21:03
• $\cos n\pi x$, n=1,2,3 is complete on $[0,1]$. They can expand all functions in $L^2[0,1]$. Jun 27, 2022 at 11:44

This is a case where using hardcore Fourier series in terms of sines and cosines would be less confusing than starting with a more general Fourier integral.

Another approach would be to use the separation of variables to find the eigenmodes of this equation (there is relation between the mode number $$k$$ and the corresponding frequency). The delta-function source than can be dealt with using the resolution of identity in terms of the eigenmodes.

Finally, let me note that this problem is a very close relative of the well-known problem about a particle in an infinite quantum well, with only difference that the time-dependent Schrödinger equation is replace by the diffusion equation (i.e., there is no imaginary unit $$\imath$$). And you probably will find a lot of discussions about that one in this community.

• In that case, isn't it easier to carry out straight sep. of var., instead of this Fourier transf. lark?
– Gert
Dec 23, 2021 at 18:51
• @Gert the spatial part of the eigenmodes is cosine functions, so Fourier transform here is more of a good guess than a general method. Dec 23, 2021 at 20:10
• I didn't do a Fourier transform in space, I did a Fourier series, which is equivalent to a sin and cosine expansion. I even regrouped the $\exp(i2\pi k x)$ terms into $\sin$ and $\cos$. Can you help me understand what else you are suggesting to do differently? Dec 23, 2021 at 20:12
• @Gert on the other hand, for the time part the Laplace transform would work better - often a better choice for problems with the initial conditions. Dec 23, 2021 at 20:13
• @DanielSank They're the same thing So all that time I was doing SoV I was actually doing FT? Just because carefully applied they give the same result doesn't make them 'the same thing'. Oh, I see RV beat me to it...
– Gert
Dec 23, 2021 at 21:15

I made a mistake in writing $$p(x, t)$$ as a Fourier series in space: $$p(x,t)= \sum_{k=−\infty}^\infty e^{i 2 \pi k x} p_k(t) \, .$$ This expansion implicitly assumes that the boundary conditions in space are periodic, which is simply wrong (as noted by Roger Vadim in the comments of his answer). As stated in the question, the boundary conditions are $$(\partial p/ \partial x)(x \in \{0,1\}) = 0 \, .$$ The correct expansion in space that satisfies those boundary conditions is $$p(x, t) = \sum_{k=0}^\infty \cos \left( \pi n x \right) \, .$$