How solve next heat equation? I want to solve the following PDE:$$
 \begin{cases}
 u_{t}-c^2u_{xx}=0, \quad 0<x<l,\ t> 0\\
 u_x(0,t)+u(0,t)=0=u_x(l,t)+u(l,t) \quad t\geq 0 \\
 u(x,0)=f(x), \quad x\in\mathbb{R}
 \end{cases}
 $$
Thanks for your help.
my approach:
Separate variables in the heat equation by putting $u(x,t)=X(x)T(t)$ to 
    obtain
    $$ 
 \begin{cases}T'(t)+ac^2T(t)=0\\
 X''(x)+aX(x)=0\\
 X'(0)+X(0)=X'(l)+X(l)=0\end{cases}
 $$
Consider cases on $a$ for $X$
Case 1. $a=0$ this case has only the trivial solution. 
Case 2. $a<0$ this case has solution for $a=-1$, $X(x)=\mathbf{e}^{-x}$.
Case 3. $a>0$ this case has solution for $a={(\frac{n\pi}{l})}^2$,
     $X_n(x)=\sin(\frac{n\pi x}{l})-\frac{n\pi }{l}\cos(\frac{n\pi x}{l})$. 
Now for $T$
Case 1. $a=-1$ then $T=\mathbf{e}^{c^2t}$
Case 2. $a={(\frac{n\pi}{l})}^2$ then $T_n =\mathbf{e}^{(\frac{nc\pi}{l})^2t}$
Now $u(x,t)=\frac{a_0}{2}\mathbf{e}^{-x}\mathbf{e}^{c^2t}+\sum_{n=1}^{\infty}{a_{n}}{\mathbf{e}^{(\frac{nc\pi}{l})^2t}}(\sin(\frac{n\pi x}{l})-\frac{n\pi }{l}\cos(\frac{n\pi x}{l}))$
And    $f(x)=u(x,0)=\frac{a_0}{2}\mathbf{e}^{-x}+\sum_{n=1}^{\infty}{a_{n}}{(\sin(\frac{n\pi x}{l})-\frac{n\pi }{l}\cos(\frac{n\pi x}{l}))}$
what can I do now?
 A: Now you have a Fourier series for $f(x)$, though it's not so obvious. For simplicity, let's say you have
$$
f(x) = \frac{a_0}{2} e^{-x} + \sum_{n=1}^\infty a_n X_n(x),
$$
where the $X_n(x)$ are your 
$$
X_n(x) = \sin\left(\frac{n\pi x}{l}\right) - \frac{n\pi}{l}\cos\left(\frac{n\pi x}{l}\right).
$$
Then 
$$
\int_0^l X_n(x) X_m(x) ~\mathrm{d}x= 0
$$ 
if $n\neq m$. And
$$\int_0^l (X_n(x))^2~ \mathrm{d}x = \frac12(l + n^2 \pi^2/l),$$
so the eigenfunctions are orthogonal and may be normalized.
We also have
$$
\int_0^l X_n(x) e^{-x} ~\mathrm{d}x = 0,
$$
so $e^{-x}$ is also orthogonal to our eigenfunctions $X_n(x)$. So multiply both sides of the Fourier series for $f(x)$ by $X_m(x)$ and (formally exchanging the sum and integral) use Orthogonality to keep only the $m$ term to find
$$
\int_0^l f(x) X_m(x)~\mathrm{d}x = \frac{a_m}{2}(l + m^2 \pi^2/l),
$$
this defines your $a_m$. To get your $a_0$ multiply both sides by $e^{-x}$ and integrate from $0$ to $l$ (formally exchanging sum and integral and using orthogonality) to find
$$
\int_0^l f(x) e^{-x} ~\mathrm{d}x = \frac{a_0}2 \int_0^l e^{-2x}~\mathrm{d}x = \frac{a_0}{2} e^{-l}\sinh(l),
$$
which now defines your $a_0$. 
A: Your solution is close but I want you to see why it can't be in that form. Ultimately, I get the same solutions as you in each case, so you may skip to the end if you wish
\begin{equation}
  \begin{cases}
    T'+\eta T=0\\
    X''+\frac{\eta}{c^2}X=0\\
    X'(0)+X(0)=0\\
    X'(L)+X(L)=0
  \end{cases}
\end{equation}
$\eta$ is the separation constant; it holds just one value, so we want to pick it so that it gives nontrivial solutions for both $T(t)\text{ and }X(x)$

Case $I$ | $\eta = 0$
$$T'=0$$
Trivial solution

Case $II$ | $\eta < 0$
$$T'-\eta T=0\implies T(t)=Ce^{\eta t}$$
$$X''-\frac{\eta}{c^2}X=0$$
Here the minus sign has been taken out of $\eta$ so the square root will be of its magnitude
$r^2-\frac{\eta}{c^2}=0\implies r=\pm\frac{\sqrt{\eta}}{c}$
$$X(x)=C_1e^{\sqrt{\eta}x/c}+C_2e^{-\sqrt{\eta}x/c}$$
$$X'(x)=C_1\frac{\sqrt{\eta}}{c}e^{\sqrt{\eta}x/c}-C_2\frac{\sqrt{\eta}}{c}e^{-\sqrt{\eta}x/c}$$
Imposing the conditions
$$X(0)+X'(0)=C_1\left(1+\frac{\sqrt{\eta}}{c}\right)+C_2\left(1-\frac{\sqrt{\eta}}{c}\right)=0$$
$$X(L)+X'(L)=C_1e^{\sqrt{\eta}L/c}\left(1+\frac{\sqrt{\eta}}{c}\right)+C_2e^{-\sqrt{\eta}L/c}\left(1-\frac{\sqrt{\eta}}{c}\right)=0$$
\begin{gather}
 \begin{bmatrix} 1+\frac{\sqrt{\eta}}{c} & 1-\frac{\sqrt{\eta}}{c} \\ e^{\sqrt{\eta}L/c}\left(1+\frac{\sqrt{\eta}}{c}\right) & e^{-\sqrt{\eta}L/c}\left(1-\frac{\sqrt{\eta}}{c}\right) \end{bmatrix}
\begin{bmatrix} C_1 \\ C_2 \end{bmatrix}
 =
 0
\end{gather}
For nontrivial solutions, the determinant must be $0$ which is met if $\eta=c^2$, implying that $C_1=0$ to satisfy the above equations.
Denoting $CC_2=\tilde{C}$
$$u(x,t)=\tilde{C}e^{tc^2-x}$$
Not a very good solution as it becomes unbounded as $t$ deviates from $x$ which is guaranteed to happen

Case $III$ | $\eta > 0$
$$T'+\eta T=0\implies T(t)=Ce^{-\eta t}$$
$$X''+\frac{\eta}{c^2}X=0\implies X(x)=C_1\cos\left(\frac{\sqrt{\eta}}{c}x\right)+C_2\sin\left(\frac{\sqrt{\eta}}{c}x\right)$$
$$X'(x)=-C_1\frac{\sqrt{\eta}}{c}\sin\left(\frac{\sqrt{\eta}}{c}x\right)+C_2\frac{\sqrt{\eta}}{c}\cos\left(\frac{\sqrt{\eta}}{c}x\right)$$
Imposing the conditions
$$C_1+C_2\frac{\sqrt{\eta}}{c}=0$$
$$C_1\left(\cos\left(\frac{\sqrt{\eta}}{c}L\right)-\frac{\sqrt{\eta}}{c}\sin\left(\frac{\sqrt{\eta}}{c}L\right)\right)+C_2\left(\sin\left(\frac{\sqrt{\eta}}{c}L\right)+\frac{\sqrt{\eta}}{c}\cos\left(\frac{\sqrt{\eta}}{c}L\right)\right)=0$$
Substituting $C_1=-\frac{\sqrt{\eta}}{c}C_2$ yields
$$C_2\sin\left(\frac{\sqrt{\eta}}{c}L\right)\left(1+\frac{\eta}{c^2}\right)=0$$
for which $C_2\neq 0$
$$\frac{\sqrt{\eta}}{c}L=n\pi\implies \eta =\left(\frac{n\pi}{L}\right)^2c^2$$
So
$$u(x,t)=\sum_{n=0}^\infty Ce^{-\left(n\pi /L\right)^2c^2t}\left(C_1\cos\left(\frac{n\pi x}{L}\right)+C_2\sin\left(\frac{n\pi x}{L}\right)\right)$$
$$u(x,t)=\sum_{n=0}^\infty \tilde{C}e^{-\left(n\pi /L\right)^2c^2t}\left(\sin\left(\frac{n\pi x}{L}\right)-\frac{n\pi}{L}\cos\left(\frac{n\pi x}{L}\right)\right)$$
You got all of these results, but my point is they are separate cases that can't be combined. That's because $\eta$ was a single number and we solved twice for when it was different values, particularly when $\eta < 0$ and $\eta > 0$. We cannot combine solutions even though they all satisfy the PDE and boundary conditions because $\eta$ cannot be positive and negative at the same time.
So even though case $II$ is a solution, it's not a good one because it becomes easily unbounded. For that reason, we're throwing it out and not revisiting it.
Case $III$ is the solution we want because it's bounded and decays to $0$. It somewhat resembles a linear combination of the zero-temperature ends and zero-flux ends solutions of the heat equation because of the linear combination of their respective boundary conditions
Changing $c^2\rightarrow k$ is a direct replacement in the exponent
$$\boxed{u(x,t)=\sum_{n=1}^\infty C_ne^{-\left(\large\frac{n\pi}{L}\right)^2kt}\left(\sin\left(\frac{n\pi x}{L}\right)-\frac{n\pi}{L}\cos\left(\frac{n\pi x}{L}\right)\right)}$$
Specifically, without exponential terms out front and indexed first at $1$ because it doesn't matter what $C_0$ is, the whole term becomes $C_0e^0(\sin(0)-0)=0$.
The procedure for finding $C_n$ as outlined by Jeremy should be relatively the same
