2.1. Use the method of separation of variables to solve the following initial-Neumann problem:
$$
\begin{equation}
\begin{cases}
u_t-u_{xx} = 0 & 0 < x < L, t > 0\\
u(x,0) = x & 0 < x < L\\
u_x(0,t) = u_x(L,t) = 0 & t > 0.
\end{cases}
\end{equation}
$$
Step 1. We look for non-trivial solutions of (2.12) of the form
$$u(x,t)=w(t)v(x),$$
with $v'(0) = v'(L) = 0.$
$$\frac{w'(t)}{w(t)} = \frac{v''(x)}{v(x)}.$$
Now, the left hand side in is a function of $t$ only, while the right hand side is a function of $x$ only and the equality must hold for every $t > 0$ and every $x \in (0, L).$ This is possible only when both sides are equal to a common constant $\lambda,$ say.
$$\begin{equation}v''(x) = \lambda v(x)\label{v}\end{equation}$$
with
$$\begin{equation}v'(0) = v'(L) = 0\label{init_v}\end{equation}$$
and
$$\begin{equation}w'(t) = \lambda w(t)\label{w}\end{equation}.$$
We first solve problem $\ref{v}.$
-
$\lambda = 0.$
$$v''(x) = 0 \Rightarrow v(x) = Ax+B.$$
From $\ref{init_v}$ we have $A = 0$ and $B -$ any. Thus, if $\lambda=0$ any constant function $\boxed{v(x) = B}$ is an eigenfunction for the eigenvalue $\lambda = 0.$
-
$\lambda = \mu^2 > 0.$
$$v(x) = Ae^{\mu x} + Be^{-\mu x}.$$
From $\ref{init_v}$ we have
$$
\begin{cases}
A\mu e^{1} - B\mu e^{-1} = 0\\
A\mu e^{\mu L} - B\mu e^{-\mu L} = 0
\end{cases}
\Rightarrow
\begin{cases}
A\mu - B\mu = 0\\
Ae^{2\mu L} - B = 0
\end{cases}
$$
so $A = B = 0.$
-
$\lambda = -\mu^2 < 0.$
$$v(x) = A\cos{(\mu x)} + B\sin{(\mu x)}.$$
From $\ref{init_v}$ we have
$$
\begin{cases}
-A\mu \sin{0} + B\mu \cos{0} = 0\\
-A\mu \sin{L} + B\mu \cos{L} = 0\\
\end{cases}
\Rightarrow
\begin{cases}
B = 0\\
A\mu\sin{\mu L} = 0
\end{cases}
$$
To get nontrivial solution we require $\mu_n = \frac{n\pi}{L}.$ And, so $\lambda = -\frac{n^2\pi^2}{L^2}$ and $\boxed{v_n(x) = A\cos{\left(\frac{n\pi}{L}x\right)}}$ for $n \in {0,1,\dots}.$ Where $\mu_n - $ eigenvalues, $v_n - $ eigenfunctions.
Now let's solve $\ref{w}.$ We now that $\lambda = -\frac{n^2\pi^2}{L^2},$ so $\boxed{w(t) = Ce^{-\frac{n^2\pi^2}{L^2}t}}.$
Now we can state the big answer. It is
$$\boxed{u(x,t) = A+\sum_{n=1}^{\infty}\left(A_n\cos{\left(\frac{n\pi}{L}x\right)}e^{-\frac{n^2\pi^2}{L^2}t}\right)}.$$
The initial condition requires
$$u(x,0) = A_0+\sum_{n=1}^{\infty}A_n\cos{\left(\frac{n\pi}{L}x\right)} = x.$$
Cosines in the series correspond to the necessity of taking even extension of the Neumann data unlike Dirichlet data in which case we take odd extension as the reflection method precribes. That's not a particularly hard to find such coefficients using
Fourier series expansion.
$$
\begin{align*}
A_n &= \frac{2}{L}\int_0^L x\cos{\frac{\pi n x}{L}} dx\\
&= \frac{2}{L}\frac{L}{\pi n}\left(x\sin{\frac{\pi n x}{L}}|_0^L-\int_0^L\sin\frac{\pi nx}{L}dx\right)\\
&= -\frac{2L}{\pi^2 n^2}\cos\frac{\pi nx}{L}|_0^L\\
&= \begin{cases}
\frac{4L}{\pi^2 n^2}&n\ \mbox{is odd}\\
0 &\mbox{otherwise.}
\end{cases}
\end{align*}
$$
References