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.
 A: 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.
A: 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) \, .
$$
