Solving the heat equation with Neumann boundary conditions The task is to solve the system:
$$
u_t - u_{xx}=tx \;\;\;\;\;\;\;(x,t)\in(0,L)\times[0,\infty)\\u(x.0)=1 \;\;\;\;\;x\in(0,L)\\u_x(0,t)=u_x(L,t) =0 \;\;\;t>0
$$
I am very stuck and so far I have tried a lot of different approaches:

*

*First I tried to find a solution to the homogenous case using separation of variables. When I did this, I solved the differential equation in terms of $t$ but and the differential equation for $x$ only gave a non trivial solution in the case where I assumed that the ratio between $X$ and $X''$ was negative, but even this didn't help.

*I thought a particular solution of $\frac{1}{2}xt^2$ might also be useful, but it doesn't equal 0 at the boundary

*I realised I need a periodic function probably using $\sin(\frac{n\pi}{L})$ but I haven't been taught this formula that I keep seeing and I certainly haven't been taught Fourier's theorem which I see being used to calcuate the coefficients in these series.

I was wondering if anyone could help me. I think with a model solution that I can follow well, I will be able to solve some of the other problems from this class.
 A: Now that we have covered the solution in class, I know how to solve it:
So consider  the Neumann problem:
$$u_t-u_{xx}=tx \;\;\;(0,T)\times(0,L)\\
u(0,x)=1 \;\;\;0\leq x\leq L\\
u_x(t,0)=u_x(t,L)=0\;\;\;\;t>0$$
We will use the separation of variables method, first analysing the homogenous equation; suppose the solution has the following form:
$$
u(t,x) = \sum_{k=0}^{\infty}c_k(t)v_k(x)
$$
Substitution into the homogenous equation gives us ODEs to solve:
$$c_k'v_k-v_k''c_k=0\\
\frac{c_k'}{c_k}=\frac{v_k''}{v_k}=\lambda\\
v_{k_x}(0)=v_{k_x}(L)=0
$$
It can be seen pretty easily that if $\lambda \geq 0$, then $v_k(x)$ is either 0 or constant so we focus on the case $\lambda <0$. We shall call $\lambda = -\mu_k^2$
$$v_k''=-\mu_k^2v_k\\
v_k=a\cos(\mu_kx)+b\sin(\mu_kx)
$$
The initial condition gives us that $b=0$, and that $\mu_k = \frac{k\pi}{L}$. For ease of notation, we will call $\omega = \frac{\pi}{L}$. Dropping factor constants for now, we have
$$v_k(x)=\cos(k\omega x)$$
Now we  will solve for $c_k$ using the non-homogenous equation:
$$
u_t-u_{xx} = tx  = \sum_{{k=0}}^{\infty}(c_k'-((k\omega)^2\cos(k\omega  x)))
$$
We want to write the function $x$ as a sum of cosines, in other words, in its Fourier series,
$$
x = \frac{a_0}{2} + \sum_{k=0}^{\infty}a_k\cos(k\omega x)
$$
By using Fourier's Theorem, we have that:
$$
a_0 = \frac{2}{L} \int_{0}^{L}x  dx\\
a_k = \frac{2}{L}\int_0^L x\cos(k\omega x) dx
$$
Calculating the integrals (by parts), we  have
$$
a_0 = L\\
a_{2k} = 0\\
a_{2k-1} = \frac{-4}{L(kw)^2}$$
Now we can equate the two expressions:
$$
u_t - u_{xx} = \sum_{k=0}^{\infty}(c_k'-(k\omega)^2c_k)\cos(k\omega x) = t(\frac{a_0}{2}+\sum_{k=1}^{\infty}a_k\cos(k\omega x))
$$
Equating for each $k$ we have:
$$
c_0' = \frac{tL}{2} \;\;\; c_0(0)=1\\
c_0(t) = \frac{t^2L}{4}+1$$
$$
c_{2k}'-(2k\omega)^2c_{2k} = 0\\
c_{2k}(t) = c_{2k}(0)e^{(2k\omega)^2t}=0
$$
$$
c_k' - (k\omega)^2c_k = \frac{-4t}{L(k\omega)^2}$$
Using the integrating factor method, we can solve this last ODE which is valid for $k$ odd:
$$
c_k(t) = \frac{4t}{L(k\omega)^4}-\frac{4}{L(k\omega)^6}-\frac{4}{L(k\omega)^6}e^{-(k\omega)^2t}$$
We can now write down our final solution:
$$
u(t,x) = \sum_{k=0}^{\infty}c_k(t)v_k(x)\\
=\frac{t^2L}{4}+1 + \sum_{k \;\text{odd}} (\frac{4t}{L(k\omega)^4}-\frac{4}{L(k\omega)^6}-\frac{4}{L(k\omega)^6}e^{-(k\omega)^2t})\cos(k\omega x)
$$
$\square$
