
For this question, I get stuck when I apply the second initial equation. My answer is $θ= Ae^-(kλ^2 t)\cos λx$, where $A$ is a constant. Would anyone mind telling me how to solve it?

For this question, I get stuck when I apply the second initial equation. My answer is $θ= Ae^-(kλ^2 t)\cos λx$, where $A$ is a constant. Would anyone mind telling me how to solve it?
Notice that the general solution to the heat equation with Neumann boundary conditions is given by
$$ \theta(x,t) = \sum_{n=0}^{\infty} A_n\cos\bigg(\frac{nx}{2}\bigg)\exp\bigg(-k\bigg(\frac{n}{2}\bigg)^{2}t\bigg) $$
We are given
$$ \theta(x,0) = 2\pi x - x^{2} $$
But our series solution at $ t = 0$ is
$$ \theta(x,0) = \sum_{n=0}^{\infty} A_n\cos\bigg(\frac{nx}{2}\bigg) $$
These must be equivalent, hence we have
$$ \begin{align} \theta(x,0) &= \sum_{n=0}^{\infty} A_n\cos\bigg(\frac{nx}{2}\bigg) \\ &= 2\pi x - x^{2} \\ \end{align} $$
Now, for orthogonality, we multiply both sides by
$$ \cos\bigg(\frac{mx}{2}\bigg) $$
And integrate from $0 \rightarrow 2\pi$ (you will need to integrate by parts). Hence you will need to solve
$$ \int_{0}^{2\pi} (2\pi x -x^{2})\cos\bigg(\frac{mx}{2}\bigg) dx = \sum_{n=0}^{\infty} A_n \int_{0}^{2\pi}\cos\bigg(\frac{nx}{2}\bigg)\cos\bigg(\frac{mx}{2}\bigg) dx $$
Where the RHS gives
$$ A_0 \cdot 2\pi $$ for $ n=m=0 $ $$ \implies A_0 = \frac{1}{2\pi} \int_{0}^{2\pi} (2\pi x -x^{2}) dx $$
and
$$ A_n \cdot \pi $$ for $ n=m \ne 0 $ $$ \implies A_n = \frac{1}{\pi} \int_{0}^{2\pi} (2\pi x -x^{2})\cos\bigg(\frac{mx}{2}\bigg) dx $$
Solving for $A_0, A_n$ gives
$$ \theta(x,t) = \frac{2\pi^{2}}{3} + \sum_{n=1}^{\infty} \frac{8}{n^{2}}\bigg[(-1)^{n+1}-1\bigg]\cos\bigg(\frac{nx}{2}\bigg)\exp\bigg(-k\bigg(\frac{n}{2}\bigg)^{2}t\bigg) $$