Diffusion in an interval with zeroed boundaries
Solution 1:
$\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,} \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace} \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack} \newcommand{\dd}{\mathrm{d}} \newcommand{\ds}[1]{\displaystyle{#1}} \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,} \newcommand{\ic}{\mathrm{i}} \newcommand{\mc}[1]{\mathcal{#1}} \newcommand{\mrm}[1]{\mathrm{#1}} \newcommand{\on}[1]{\operatorname{#1}} \newcommand{\pars}[1]{\left(\,{#1}\,\right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,} \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}} \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$ $\ds{\bbox[5px,#ffd]{\partiald{\on{p}\pars{x,t}}{t} - D\,\partiald[2]{\on{p}\pars{x,t}}{x} = \delta\pars{x - x_{0}}\delta\pars{t - t_{0}},\quad D > 0,\qquad \left.\partiald{\on{p}\pars{x,t}}{x}\right\vert_{x\ =\ 0, 1} = 0}}$
It's convenient to enforce the homogeneous boundary condition at the very begining. Namely, $$ \partiald{\on{p}\pars{x,t}}{x} = \sum_{n = 1}^{\infty}a_{n}\pars{t}\sin\pars{n\pi x} $$ \begin{equation} \mbox{which leads to}\quad\on{p}\pars{x,t} = \sum_{n = 1}^{\infty}\on{a}_{n}\pars{t} \bracks{-\,{\cos\pars{n\pi x} \over n\pi}} + \on{f}\pars{t}\label{pfeq}\tag{1} \end{equation} where $\ds{\on{f}}$ is an $\ds{x}$-independent function. $\ds{\on{p}}$ must satisfies the original equation at the top: \begin{align} & \bracks{-{1 \over \pi}\sum_{n = 1}^{\infty}{\dot{\on{a}}_{n}\pars{t} \over n} \cos\pars{n\pi x} + \dot{\on{f}}\pars{t}} - D\bracks{{1 \over \pi}\sum_{n = 1}^{\infty}\on{a}_{n}\pars{t}n \cos\pars{n\pi x}} \\[2mm] = &\ \delta\pars{x - x_{0}}\delta\pars{t - t_{0}}\label{eqdef}\tag{2} \\[2mm] & \mbox{with}\quad \left\{\begin{array}{rcl} \ds{\int_{0}^{1}\cos\pars{n\pi x}\,\dd x} & \ds{=} & \ds{0} \\ \ds{\int_{0}^{1}\cos\pars{m\pi x}\cos\pars{n\pi x}\,\dd x} & \ds{=} & \ds{{1 \over 2}\delta_{mn}} \end{array}\right. \end{align} In integrating both sides of this expression along $\ds{\pars{0,1}}$ leads to $\ds{\dot{\on{f}}\pars{t} = \delta\pars{t - t_{0}}}$ such that $\ds{\on{f}\pars{t} = \Theta\pars{t - t_{0}} + c}$. $\ds{\Theta}$ is the Heaviside Step Function and $\ds{c}$ is a constant. The general solution (\ref{pfeq}) is reduced to \begin{equation} \on{p}\pars{x,t} = -{1 \over \pi}\sum_{n = 1}^{\infty}{\on{a}_{n}\pars{t} \over n} \cos\pars{n\pi x} + \Theta\pars{t - t_{0}} + c\label{pfeq3}\tag{3} \end{equation} Multiply both sides of (\ref{eqdef}) by $\ds{\cos\pars{n\pi x}}$ and integrate along $\ds{\pars{0,1}}$. It yields \begin{align} & -\,{1 \over 2n\pi}\,\dot{\on{a}}_{n}\pars{t} - {D \over 2\pi}\,\on{a}_{n}\pars{t} = \cos\pars{n\pi x_{0}}\delta\pars{t - t_{0}} \\[3mm] \implies & \dot{\on{a}}_{n}\pars{t} + nD\on{a}_{n}\pars{t} = -2n\pi\cos\pars{n\pi x_{0}}\delta\pars{t - t_{0}} \\[3mm] \implies & \totald{\bracks{\on{a}_{n}\pars{t}\expo{nDt}}}{t} = -2n\pi\cos\pars{n\pi x_{0}}\delta\pars{t - t_{0}}\expo{nDt} \\[3mm] \implies & \on{a}_{n}\pars{t}\expo{nDt} - \on{a}_{n}\pars{0} = -2n\pi\cos\pars{n\pi x_{0}}\expo{nDt_{0}}\,\,\Theta\pars{t - t_{0}} \\[3mm] \implies & \on{a}_{n}\pars{t} = \on{a}_{n}\pars{0}\expo{-nDt} -2n\pi\cos\pars{n\pi x_{0}}\expo{-nD\pars{t - t_{0}}} \,\,\Theta\pars{t - t_{0}} \end{align} The solution (\ref{pfeq3}) is reduced to \begin{align} \on{p}\pars{x,t} & = -\,{1 \over \pi}\sum_{n = 1}^{\infty} \on{a}_{n}\pars{0}{\expo{-nDt} \over n}\cos\pars{n\pi x} + \\[2mm] + & 2\Theta\pars{t - t_{0}} \sum_{n = 1}^{\infty}\cos\pars{n\pi x_{0}}\cos\pars{n\pi x}\expo{-nD\pars{t - t_{0}}} + \Theta\pars{t - t_{0}} + c \end{align} $\ds{\on{a}_{n}\pars{0}}$ and $c$ are determined once a initial condition is provided $\ds{\pars{~i.e, \on{p}\pars{x,0}~}}$. In such a case, the remaining $\ds{n}$-sums can be performed analytically.