$$U_{t} - D U_{xx}= -kU$$ where
BC: $U_{x}(0,t)=0$, $U_{x}(l,t)=0$
where
$0 < x < l$, $t > 0$
IC: $U(x,0)=A + B cos \big(\frac{2πx}{l}\big)$
where
$ 0<x<l$
where $D$ and $k$ are positive constants and $A$ and $B$ are constants.
I have been unable to find an example i can understand and apply to this problem.
This will get you started. Suppose $$ U\left(x,t\right)=X\left(x\right)T\left(t\right) $$ with $X,T$ smooth. Substituting into the PDE, $$ XT^{\prime}-DX^{\prime\prime}T=-kXT. $$ Further suppose that $U\neq0$ so that dividing through by $XT$ yields $$ \frac{T^{\prime}}{T}+k=D\frac{X^{\prime\prime}}{X}. $$ Since the left-hand side depends only on $t$ and the right-hand side depends only on $x$, this reveals that $$ \frac{T^{\prime}}{T}+k=\text{constant} $$ and $$ \frac{X^{\prime\prime}}{X}=\text{constant}. $$