# Finding the coefficient of the Heat equation

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

$$$$u_t-\alpha u_{xx}=0 \ \ \ 00 \\ u_x(0,t)=u_x(L,t)=0, \ \ \ t>0$$$$

and

$$$$u(x,0)= \begin{cases} 0\ \ \ 0

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 $$$$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$$$$

which gives:

$$$$\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$$$$

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

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

which is an ordinary first order differential equation.

Solving it gives:

$$$$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}$$$$

We now have:

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

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

$$$$C_0=\frac{1}{L}\int_0^Lf(x)dx$$$$

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

So the coefficient is:

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

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$$

$$$$\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}$$$$

or

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

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}$$?

Thanks

$$$$C_0=\frac{1}{L}\int_0^Lf(x)dx$$$$
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}