I have used a rapid way to solve the heat equation, with von Neumann conditions:

\begin{equation} u_t-\alpha u_{xx}=0 \ \ \ 0<x<L, t>0 \\ u_x(0,t)=u_x(L,t)=0, \ \ \ t>0 \end{equation}


\begin{equation} u(x,0)= \begin{cases} 0\ \ \ 0<x<L/2\\ 1\ \ \ L/2<x<L \end{cases} \end{equation}

Ansatz: $u(x,t)=\sum_{n=1}^\infty u_k(t)\cos \frac{n\pi}{L}x$

Then we find $u_k(t)$ by inserting the Ansatz in the original PDE:

The ansatz becomes \begin{equation} u_t=\sum_{n=1}^\infty u'_k(t)\cos \frac{n\pi}{L}x \\ \alpha u_{xx}=-\alpha\sum_{n=1}^\infty u_k(t) \frac{n^2\pi^2}{L^2}\cos \frac{n\pi}{L}x \end{equation}

which gives:

\begin{equation} \sum_{n=1}^\infty \cos\frac{n\pi}{L}x\big(u'_k(t)+\alpha\frac{n^2\pi^2}{L^2}u_k(t)\big)=0 \end{equation}

Here, we clearly have to solve what is inside the brackets, hence

\begin{equation} \big(u'_k(t)+\alpha\frac{n^2\pi^2}{L^2}u_k(t)\big)=0 \end{equation}

which is an ordinary first order differential equation.

Solving it gives:

\begin{equation} u'+\alpha\frac{n^2\pi^2}{L^2}u=0\\ \frac{du}{u}=-\alpha\frac{n^2\pi^2}{L^2}dt\\ u=Ce^{-\alpha\frac{n^2\pi^2}{L^2}t} \end{equation}

We now have:

\begin{equation} \sum_{n=1}^\infty C_n\cos\frac{n\pi}{L}xe^{-\alpha\frac{n^2\pi^2}{L^2}t}+C_0 \end{equation}

The problem arises now, find C_0 appears trivial, as it is simply the fourier coefficient

\begin{equation} C_0=\frac{1}{L}\int_0^Lf(x)dx \end{equation}

here $f(x)=u(x,0)=\cos\frac{n\pi}{L}x$

So the coefficient is:

\begin{equation} C_0=\frac{1}{L}\int_0^L\cos\frac{n\pi}{L}xdx =\sin(n\pi)\frac{1}{n\pi} \end{equation}

This is clearly 0, but the solution for this is that it should be $\frac{1}{2}$! It appears that the given solution had a typo and the wrong lower boundary was written, which should be $L/2$ instead of $0$ (have a look at the IC)?

The solution is then, with boundary assumed to be $L/2\rightarrow L$

\begin{equation} \sum_{n=1}^\infty C_n\cos\frac{n\pi}{L}xe^{-\alpha\frac{n^2\pi^2}{L^2}t}-\frac{\sin(\frac{n\pi}{2})}{n\pi} \end{equation}


\begin{equation} \sum_{n=1}^\infty C_n\cos\frac{n\pi}{L}xe^{-\alpha\frac{n^2\pi^2}{L^2}t} \end{equation}

assuming the boundary $0 \rightarrow L$ was correct, and the integral is also.

What is the correct answer to this $C_0$ coefficient and how can it possibly become $\frac{1}{2}$?



1 Answer 1


The integral

\begin{equation} C_0=\frac{1}{L}\int_0^Lf(x)dx \end{equation}

Is simple to solve. You must use initial condition to determine the coefficient. Notice that $f(x) = u(x,0)$ is piecewise constant. Therefore you can split the integral to two parts:

\begin{align} C_0 = & \frac{1}{L}\int_0^Lf(x)dx \\ = & \frac{1}{L}\int_0^{L/2}f(x)dx + \frac{1}{L}\int_{L/2}^{L}f(x)dx \\ = & \frac{1}{L}\int_0^{L/2}0dx + \frac{1}{L}\int_{L/2}^{L}1dx \\ = & 0 + \frac{1}{L}\frac{L}{2} = \frac{1}{2} \end{align}

  • $\begingroup$ Indeed, my mistake! Thanks! $\endgroup$ Commented Apr 22, 2022 at 10:53
  • 1
    $\begingroup$ Glad it helped :) $\endgroup$
    – Tomek
    Commented Apr 22, 2022 at 10:54

You must log in to answer this question.

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