Heat equation with non zero BC Assume I have a heat equation on $[0,\pi]$ with 0 value on the boundaries and say 1 initial value, constant. I can see that I can write the solution as a series. Now, I want to change the boundary condition value to 2 and 4 on the left and on the right. How would I approach solving this problem? 
 A: The system that you want to solve is 
\begin{split}
\partial_{t}u &= \partial_{xx}u, \ x\in[0,\pi], \ t>0\\
u (0,t) &= 2,  \\
u (\pi,t) &= 4 \\
u(x,0) &= u_{0}
\end{split}
where you have probably found that using the ansatz $u(x,t) = X(x)T(t)$ and proceeding by separation of variables doesn't work.
The strategy is to rewrite the solution $u(x,t)$ in terms of a new variable $v(x,t)$ such that the new problem has homogeneous boundary conditions.
We start by defining $v$
\begin{align*}
v(x,t) = u(x,t) - u_{E}(x,t)
\end{align*}
where $u_{E}(x,t)$ is the solution at equilibrium. 
Hence one would firstly solve
\begin{align}
\begin{split}
\partial_{xx}u_{E} &= 0, \ x\in[0,\pi]\\
u_{E} (0) &= 2 \\
u_{E} (\pi) &= 4
\end{split}
\end{align}
for which the solution is 
\begin{align}
u_{E}(x) = \frac{2}{\pi}x + 2.
\end{align}
Then we can write the new system for $v(x,t) = u(x,t) - \frac{2}{\pi}x - 2$ as the following
\begin{align}
\begin{split}
\partial_{t}v &= \partial_{xx}v, \ x\in[0,\pi]\\
v (0,t) &= 0 \\
v (\pi,t) &= 0 \\
v(x,0) &= u_{0} - \frac{2}{\pi}x - 2, \ x\in[0,\pi].
\end{split}
\end{align}
and solve using separation of variables using the ansatz $v(x,t) = X(x)T(t)$ in the usual way.
Then one can finally write the solution as $u(x,t) = v(x,t) + u_{E}(x)$
