Is the solution of the initial-boundary value problem correct? I have to solve the problem:
$$u_t=u_{xx}-6x, 0<x<L, t>0$$
$$u(0,t)=0, u(L,t)=2L^3, t>0$$
$$u(x,0)=x^3, 0<x<L$$
I did the following:
$$u(x,t)=v(x,t)+s(x)$$
So we have the following problems to solve:
$$\left.\begin{matrix}
s''(x)=6x\\ 
s(0)=0\\ 
s(L)=2L^3
\end{matrix}\right\} (1)$$
and
$$\left.\begin{matrix}
v_t=v_{xx}, 0<x<L, t>0\\ 
v(0,t)=v(L,t)=0, t>0\\ 
v(x,0)=x^3-s(x), 0<x<L
\end{matrix}\right\} (2)$$
Solving the problem $(1)$ we get:
$$s(x)=x^3+L^2x$$
and the solution of the problem $(2)$ is of th eform:
$$v(x,t)=\sum_{n=1}^{\infty}{A_n \sin {(\frac{n \pi x}{L})} e^{-(\frac{n \pi}{L})^2 t}}$$
and using the condition $$v(x,0)=x^3-s(x)=-L^2x$$ we have that $$-L^2x=\sum_{n=1}^{\infty}{A_n \sin{(\frac{n \pi x}{L})}}$$
So $$A_n=\frac{2L^3}{n \pi}(-1)^n$$
$$\Rightarrow v(x,t)=\sum_{n=1}^{\infty}{\frac{2L^3}{n \pi}(-1)^n \sin {(\frac{n \pi x}{L})} e^{-(\frac{n \pi}{L})^2 t}}$$
So the solution of the initial problem is: 
$$u(x,t)=\sum_{n=1}^{\infty}{\frac{2L^3}{n \pi}(-1)^n \sin {(\frac{n \pi x}{L})} e^{-(\frac{n \pi}{L})^2 t}}+x^3+L^2x$$
Could you tell me if this is correct??
 A: The steps seems correct and the solution looks good since the homogenous Dirichlet boundary conditions lead you tu sine eigenfunctions. It's good to remark that what you have used in order to split the solution in the form $u = v + s$ is called superposition principle and, the way you did, allows you to make the bcs homogenous as well as the PDE at once! 
I would have proceeded as follows, (step by step), and I will post it if it's not any inconvenience:


*

*We have: $$u_t - u_{xx} = f(x), \quad 0 < x < L, \quad t > 0,$$ with Dirichlet boundary conditions: $u(0,t) = \alpha(t), \ u(L,t) = \beta(t)$, together with $u(x,0) = g(x)$. 

*You can now (partially) 'non-dimensionalize' the $x$ and $t$ coordinates by defining $\bar{x} = x/L$ and $\tau = t/L^2$ so your problem becomes:
$$u_\tau - u_{\bar{x} \bar{x}} = L^2 f(L \bar{x}) \equiv h(\bar{x}), \quad 0 < \bar{x} < 1, \quad \tau > 0,$$ together with $u(0,t) = \alpha(L^2 \tau), \ u(1,t) = \beta(L^2 \tau)$ and $u(x,0)= g(L \bar{x})$. Now your problem has a more canonical form, which can be rewritten, by setting every variable as functions of $\tau$ and $\bar{x}$ as follows: 
$$u_\tau - u_{{x} {x}} =  h({x}), \quad 0 < {x} < 1, \quad \tau > 0,$$ with $u(0,\tau) = \alpha(\tau), \ u(1,t) = \beta(\tau) $ and $u(x,0) = g(x)$, where I have made $\bar{x} \to x$ for convenience.

*Your problem now has a non-homogeneous PDE with non-homogenous bcs, so we cannot yet apply Sturm Liouville theory to it. Let's make use of the superposition principle by setting: $$u = v+w,$$ where, for convenience, $v$ satisfies homogenous bcs and $w(x,\tau)$ is the simplest function that satisfies the original bcs, i.e.: $w(x,t) = A(\tau) \, x + B(\tau)$. Solve now the system $w(0,\tau) = \alpha(\tau), \ w(1,\tau) = \beta(\tau)$ for the coefficients $A$ and $B$. Your PDE for $v$ becomes now: 
$$ v_{\tau} - v_{xx} = h(x) - w_\tau + w_{xx} = p(x,\tau), $$ where $p$ is a known function of the independent variables. You have now homogenous boundary conditions for $v$ and $v(x,0) = u(x,0) - w(x,0)$ as initial condition.

*Using Fredholm's alternative we can create a fully homogenous problem given by: $$\theta_{\tau} - \theta_{xx} = 0, \quad 0 < x < 1, \quad \tau > 0, $$ with homogenous Dirichlet boundary conditions (the initial conditions are not important now). This problem can be solved in terms of separation of variables so we get the sine eigenfunctions, $\psi_n (x)$, with the correspondent eigenvalues, $\lambda_n$.

*Sturm-Liouville theory tells us that we can expand $v$ in terms of $\psi_n$ as follows: $$v(x,\tau) = \sum a_n(\tau) \psi_n(x),$$ where $a_n$ are the coefficients of the Fourier expansion. Now it's time to substitute back this in the equation for $v$ and obtain an ordinary differential equation for $a_n$ with initial condition given by the expression you wrote down above: 
$$v(x,0) = u(x,0)-w(x,0) = \sum a_n(0) \psi_n(x), $$ you now multiply each side by the weight function of the problem times $\psi_m$ and solve for $a_n(0)$ so we are done.
You can recover your 'dimensional' solution by unmaking the change of variables.
Let me know if this helps you!
Cheers.
