Solve with eigenfunction expansion $\frac{\partial u}{\partial t} = k \frac{\partial^2 u}{\partial x^2} + e^{-t} + e^{-2t} \cos \frac{3\pi x}{L}$ 
Q: Solve the following non-homogeneous problem:
  \begin{align*}
  \frac{\partial u}{\partial t} &= k \frac{\partial^2 u}{\partial x^2} + e^{-t} + e^{-2t} \cos \frac{3\pi x}{L} \\
\end{align*}
  With the following boundary and initial value conditions:
  \begin{align*}
  \frac{\partial u}{\partial x}(0,t) &= 0 \\
  \frac{\partial u}{\partial x}(L,t) &= 0 \\
  u(x,0) &= f(x) \\
\end{align*}
  Assume that $2 \neq k(3\pi/L)^2$. Use the method of eigenfunction expansion. Look for the solution as a Fourier cosine series. Assume appropriate continuity.
TEXTBOOK GIVEN ANSWER:
  \begin{align*}
  u &= \sum\limits_{n=0}^\infty A_n(t) \cos \frac{n \pi x}{L} \\
  A_{n,n \neq 0, n\neq 3}(t) &= A_n(0) e^{-k \left( \frac{n \pi}{L} \right)^2 t} \\
  A_0(t) &= A_0(0) + 1 - e^{-t} \\
  A_3(t) &= A_3(0) e^{-k \left( \frac{3 \pi}{L} \right)^2 t} + \frac{e^{2t} - e^{-k \left( \frac{3 \pi}{L} \right)^2 t}}{k \left( \frac{3 \pi}{L} \right)^2 - 2} \\
  A_0(0) &= \frac{1}{L} \int_0^L f(x) \, dx \\
  A_{n \ge 1}(0) &= \frac{2}{L} \int_0^L f(x) \cos \frac{n \pi x}{L} \, dx \\  
\end{align*}

My work: I fully understand how to get most of the answer, but I am stuck on the rest. Specifically, I don't understand the $n=0, n=3$ cases.
First, the part I fully understand:
We look for the solution as a Fourier cosine series. The right hand side is an even extended and periodized version of $u(x,t)$ along the $x$ variable.
\begin{align*}
  u(x,t) &\sim A_0 + \sum\limits_{n=1}^\infty A_n(t) \cos \frac{n \pi x}{L} \\
\end{align*}
The problem says we can assume appropriate continuity which means that we can assume the original, non-periodized $u(x,t)$ is continuous. We can apply term by term partial differentiation to both $x$ and $t$. For $t$, we are not periodized by $t$, the given function is continuous, so that's all we need. For $x$, we are dealing with the even extended, periodized version of a continuous function, which must be continuous, so we can use term by term partial differentiation there as well.
\begin{align*}
  \frac{\partial u}{\partial x} &\sim - \sum\limits_{n=1}^\infty \frac{n \pi}{L} A_n(t) \sin \frac{n \pi x}{L} \\
  \frac{\partial u}{\partial t} &\sim \sum\limits_{n=1}^\infty A'_n(t) \cos \frac{n \pi x}{L} \\
\end{align*}
We also assume that $\frac{\partial u}{\partial x}$ is continuous. Since we are given that $\frac{\partial u}{\partial x}(0,t) = 0 = \frac{\partial u}{\partial x}(L,t)$, then we can see that the periodized version along the $x$ variable must also be fully continuous so that we can again use term by term differentiation to get:
\begin{align*}
  \frac{\partial^2 u}{\partial x^2} &\sim - \sum\limits_{n=1}^\infty \left(\frac{n \pi}{L}\right)^2 A_n(t) \cos \frac{n \pi x}{L} \\
\end{align*}
Now plugging that back in to the PDE:
\begin{align*}
  \frac{\partial u}{\partial t} &= k \frac{\partial^2 u}{\partial x^2} + e^{-t} + e^{-2t} \cos \frac{3\pi x}{L} \\
  \sum\limits_{n=1}^\infty A'_n(t) \cos \frac{n \pi x}{L} &= k \left( - \sum\limits_{n=1}^\infty \left(\frac{n \pi}{L}\right)^2 A_n(t) \cos \frac{n \pi x}{L} \right) + e^{-t} + e^{-2t} \cos \frac{3\pi x}{L} \\
\end{align*}
That will be satisfied if the summation terms on the left/right side are all equal and the term on the right hand side outside the summation is zero:
\begin{align*}
  A'_n(t) &= -k \left(\frac{n \pi}{L}\right)^2 A_n(t) \\
  A_n(t) &= A_n(0) e^{-k \left( \frac{n \pi}{L} \right)^2 t} \\
\end{align*}
Solving for the coefficients with the initial condition:
\begin{align*}
  u(x,t) &= \sum\limits_{n=0}^\infty A_n(t) \cos \frac{n \pi x}{L} \\
  u(x,0) = f(x) &= \sum\limits_{n=0}^\infty A_n(0) \cos \frac{n \pi x}{L} \\
  A_0(0) &= \frac{1}{L} \int_0^L f(x) \, dx \\
  A_{n \ge 1}(0) &= \frac{2}{L} \int_0^L f(x) \cos \frac{n \pi x}{L} \, dx \\
\end{align*}
ok, so far so good. All of that lines up perfectly with the given answer. But I am unsure about how to get the rest.
From earlier, I said if the terms on the right hand side out side the summation came to zero, it would satisfy the PDE. That would mean that:
\begin{align*}
  e^{-t} + e^{-2t} \cos \frac{3\pi x}{L} &= 0 \\
  e^{t} &= -\cos \frac{3\pi x}{L} \\  
\end{align*}
I am not sure how to use this. I also don't see what to do with the problem given that $2 \neq k(3\pi/L)^2$
 A: Letting 
$$u \sim \sum_{n \ge 0} A_{n}(t) \cos \left( \frac{n \pi x}{L} \right)$$ 
then substituting into the PDE (and noting that $1 \equiv \cos(0 \pi x/L)$) yields 
$$\sum_{n \ge 0} A_{n}'(t) \cos \left( \frac{n \pi x}{L} \right) = -k \sum_{n \ge 0} \left( \frac{n \pi}{L} \right)^{2} A_{n}(t) \cos \left( \frac{n \pi x}{L} \right) + e^{-t} \color{red}{\cos \left( \frac{0 \pi x}{L} \right)} + e^{-2t}\cos \left( \frac{3 \pi x}{L} \right)$$
Equating terms in $\cos$ for $n = 0, 1, \dots$ and letting $C_{n}$ be the constants of integration, we have
\begin{align}
A_{0}'(t) = -k(0)+e^{-t} &\implies A_{0}(t) = -e^{-t} + C_{0} \\
&\implies A_{0}(0) = -1+C_{0} \\
&\implies A_{0}(t) = A_{0}(0) + 1 - e^{-t} \\\\
A_{1}'(t) = -k \left( \frac{\pi}{L} \right)^{2} A_{1}(t) &\implies A_{1}(t) = A_{1}(0) e^{-k \left( \frac{\pi}{L} \right)^{2} t} \\\\
A_{2}'(t) = -k \left( \frac{2 \pi}{L} \right)^{2} A_{2}(t) &\implies A_{2}(t) = A_{2}(0) e^{-k \left( \frac{2 \pi}{L} \right)^{2} t} \\\\
A_{3}'(t) = -k \left( \frac{3 \pi}{L} \right)^{2} A_{3}(t) + e^{-2t} &\implies A_{3}(t) = \frac{e^{-2t}}{-2 + k \left( \frac{3 \pi}{L} \right)^{2}} + C_{3} e^{-k \left( \frac{3 \pi}{L} \right)^{2} t} \\
&\implies A_{3}(0) = \frac{1}{-2 + k \left( \frac{3 \pi}{L} \right)^{2}} + C_{3} \\
&\implies A_{3}(t) = \frac{e^{-2t} - e^{-k \left( \frac{3 \pi}{L} \right)^{2} t}}{-2 + k \left( \frac{3 \pi}{L} \right)^{2}} + A_{3}(0) e^{-k \left( \frac{3 \pi}{L} \right)^{2} t}
\end{align}
