Consider the following inhomogeneous heat equation with Neumann boundary conditions. $$ \begin{cases} u_t-u_{xx}=\cos(2x)\\ u(x,0)=x \\ u_x(0,t)=u_x(\pi,t)=0 \end{cases}\text{ for }\: \begin{align} 0<x<\pi,\\ 0<t\quad \end{align}$$ By separation of variables I arrive at the homogeneous solution $$u_h(x,t)=\sum_{i=0}^\infty A_ne^{-n^2t}\cos(nx)$$ $$ A_n= \begin{cases} \pi /2 & n=0\\ -4/(\pi n^2)& \text{if $n$ is odd}\\ 0& \text{if $n$ is even} \end{cases}$$ On trying to find the inhomogeneous solution by applying Duhamel's principle i.e. using $$u_p(x,t)=\int_0^t\sum_{i=0}^\infty B_n(s)\cos(nx)e^{-n^2(t-s)}ds$$ where $$B_n(s)=2/\pi \int_0^\pi \cos(nx)\cos(2x) dx$$ I get $$B_n(s)=0$$ What went wrong? Any assistance much appreciated.

  • $\begingroup$ $n$ isn't fixed, it can be any integer. Can you think of an integer where $B_n(s)$ is nonzero? $\endgroup$ Commented Nov 19, 2019 at 20:22
  • $\begingroup$ I can write cos(nx)cos(2x) as 1/2(cos((n+2)x)+cos((n-2)x)) which integrates to terms in sin which vanish for multiples of pi. So I am struggling to find an integral n that produces anything other than zero. I am clearly missing something? A pi/2 would be nice $\endgroup$
    – OEB
    Commented Nov 20, 2019 at 16:37
  • $\begingroup$ Thank you. I missed the obvious!!! $\endgroup$
    – OEB
    Commented Nov 21, 2019 at 0:19

1 Answer 1


Using the Laplace transform

$$ {\cal L}\left(u_t-u_{xx}-\cos(2x)\right) = sU(s,x)-u(0,x)-U_{xx}(s,x)-\frac 1s\cos(2x) $$

and now solving

$$ sU(s,x)-x-U_{xx}(s,x)-\frac 1s\cos(2x)=0,\ \ U_x(s,0)=U_x(s,\pi) $$

we have

$$ U(s,x) = \frac{1}{s(s+4)}\left((s+4)x+\cos(2x)-(s(s+4))(e^{\sqrt s x}-e^{\sqrt s(s-x)})C(s)\right) $$

now assuming that $U(s,x)$ remains limited as $x\to\infty$ we have $C(s) = 0$ and then

$$ U(s,x) = \frac xs+\frac{\cos(2x)}{s(s+4)} $$

with inverse

$$ u(t,x) = \frac 14\left(1-e^{-4 t}\right) \cos (2 x)+x $$


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .