Q: Suppose $u(x,t)$ satisfies the heat equation for $0<x<a$ with the usual initial condition $u(x,0)=f(x)$, and the temperature given to be a non-zero constant C on the surfaces $x=0$ and $x=a$.
We have BCs $u(0,t) = u(a,t) = C.$ Our standard method for finding u doesn't work here, since $e^{-k(\frac{n\pi}a)^2t}sin(\frac{n\pi}a)$ does not satisfy these BCs.
Make a change of variable from $u$ to $v=u-C.$ Show that $v$ satisfies the heat equation with BCs $v=0$ at $x=0$ and $x=a.$
Write down the solution for $v(x,t).$Deduce an expression for $u(x,t)$ in terms of constants $c_1,c_2,\ldots,$ and write down a formula for $c_n.$
[Harder] Now suppose the BCs are $u(0,t) = C$, $u(a,t)=D$ for constants $C,D.$ How could you solve the case?
My question: These are extensions to homework which I'd like try to attempt, but I don't know where to start with the change of variable
$\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,} \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace} \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack} \newcommand{\dd}{\mathrm{d}} \newcommand{\ds}[1]{\displaystyle{#1}} \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,} \newcommand{\ic}{\mathrm{i}} \newcommand{\mc}[1]{\mathcal{#1}} \newcommand{\mrm}[1]{\mathrm{#1}} \newcommand{\pars}[1]{\left(\,{#1}\,\right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,} \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}} \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
Write $\ds{\,\mrm{u}\pars{x,t} = C + \sum_{n = 1}^{\infty}\mrm{a}_{n}\pars{t}\sin\pars{n\pi\,{x \over a}}}$ such that $\ds{\braces{\mrm{a}_{n}\pars{t}}}$ satisfy $$ \totald{a_{n}\pars{t}}{t} = -D\,\pars{n\pi \over a}^{2}\,\mrm{a}_{n}\pars{t} $$.
The general solution is given by: \begin{equation} \mrm{u}\pars{x,t} = C + \sum_{n = 1}^{\infty}\mrm{a}_{n}\pars{0}\sin\pars{n\pi\,{x \over a}} \exp\pars{-D\,\bracks{n\pi \over a}^{2}t}\label{1}\tag{1} \end{equation}
$\ds{\braces{\mrm{a}_{n}\pars{0}}}$ is determined by: \begin{align} \mrm{f}\pars{x} & = \,\mrm{u}\pars{x,0} = C + \sum_{n = 1}^{\infty}\mrm{a}_{n}\pars{0}\sin\pars{n\pi\,{x \over a}} \\[5mm] \int_{0}^{a}\mrm{f}\pars{x}\sin\pars{n\pi\,{x \over a}}\,\dd x & = C\overbrace{\int_{0}^{a}\sin\pars{n\pi\,{x \over a}}\,\dd x}^{\ds{{2a \over \pi}\,{\sin^{2}\pars{n\pi/2} \over n}}} + \sum_{m =1}^{\infty}\mrm{a}_{m}\pars{0} \overbrace{\int_{0}^{a}\sin\pars{n\pi\,{x \over a}} \sin\pars{m\pi\,{x \over a}}\,\dd x}^{\ds{{1 \over 2}\,a\,\delta_{mn}}} \end{align}
$$\bbx{\ds{% \mrm{a}_{n}\pars{0} = {2 \over a}\int_{0}^{a}\mrm{f}\pars{x}\sin\pars{n\pi\,{x \over a}}\,\dd x - {4 \over \pi}\,{\sin^{2}\pars{n\pi/2} \over n}\,C}}\qquad \pars{~\mbox{see expression}\ \eqref{1}~} $$