1-D heat diffusion in a bar with fixed temperatures at the edges I'm trying to calculate the temperature gradient in a bar of metal with a heater at either end. Initially, the bar is at room-temperature $T_0$, then at $t=0$ the heaters are turned on: $u(0,t)=T_1$ and $u(L,t)=T_2$. As I understand it, eventually the temperature gradient will just be linear between $0$ and $L$. But how does this system evolve over time?
 A: $\newcommand{\+}{^{\dagger}}%
 \newcommand{\angles}[1]{\left\langle #1 \right\rangle}%
 \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}%
 \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}%
 \newcommand{\ceil}[1]{\,\left\lceil #1 \right\rceil\,}%
 \newcommand{\dd}{{\rm d}}%
 \newcommand{\down}{\downarrow}%
 \newcommand{\ds}[1]{\displaystyle{#1}}%
 \newcommand{\equalby}[1]{{#1 \atop {= \atop \vphantom{\huge A}}}}%
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}%
 \newcommand{\fermi}{\,{\rm f}}%
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}%
 \newcommand{\half}{{1 \over 2}}%
 \newcommand{\ic}{{\rm i}}%
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}%
 \newcommand{\isdiv}{\,\left.\right\vert\,}%
 \newcommand{\ket}[1]{\left\vert #1\right\rangle}%
 \newcommand{\ol}[1]{\overline{#1}}%
 \newcommand{\pars}[1]{\left( #1 \right)}%
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}%
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,#2\,}\,}%
 \newcommand{\sech}{\,{\rm sech}}%
 \newcommand{\sgn}{\,{\rm sgn}}%
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}%
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$
The solution is given by:
$$
{\rm T}\pars{x,t} = T_{1} + \pars{T_{2} - T_{1}}\,{x \over L}
+ \sum_{n = 1}^{\infty}A_{n}\pars{t}\sin\pars{k_{n}\,x}\,,
\quad k_{n} = {n\pi \over L}\tag{1}
$$
${\rm T}\pars{x,t}$ obeys the Difussion Equation
$\ds{\partiald{{\rm T}\pars{x,t}}{t} = D\,\partiald[2]{{\rm T}\pars{x,t}}{x}}$ where
$D$ is the Difussion Constant.

From $\pars{1}$:
  $$
\sum_{n = 1}^{\infty}\totald{A_{n}\pars{t}}{t}\,\sin\pars{k_{n}\,x}
=
D\sum_{n = 1}^{\infty}A_{n}\pars{t}\pars{-\,k_{n}^{2}}\sin\pars{{n\pi \over L}\,x}
\quad\imp\quad A_{n}\pars{t} = A_{n}\pars{0}\exp\pars{-Dk_{n}^{2}t}
$$

$\pars{1}$ becomes:
$$
{\rm T}\pars{x,t} = T_{1} + \pars{T_{2} - T_{1}}\,{x \over L}
+ \sum_{n = 1}^{\infty}A_{n}\pars{0}\sin\pars{k_{n}\,x}\exp\pars{-Dk_{n}^{2}t}
$$

$$
T_{0} = {\rm T}\pars{x,0} = T_{1} + \pars{T_{2} - T_{1}}\,{x \over L}
+ \sum_{n = 1}^{\infty}A_{n}\pars{0}\sin\pars{k_{n}\,x}
$$

$$
\int_{0}^{L}\bracks{T_{0} - T_{1} + \pars{T_{1} - T_{2}}\,{x \over L}}\,
\sin\pars{k_{n}x}\,\dd x
=\sum_{m = 1}^{\infty}A_{m}\pars{0}
\overbrace{\int_{0}^{L}\sin\pars{k_{n}x}\sin\pars{k_{m}\,x}\,\dd x}
^{\ds{=\ L\,\delta_{n,m}/2}}
=\half\,L\,A_{n}\pars{0}
$$

$$
A_{n}\pars{0} = {2 \over L}
\int_{0}^{L}\bracks{T_{0} - T_{1} + \pars{T_{1} - T_{2}}\,{x \over L}}\,
\sin\pars{k_{n}x}\,\dd x
=2\,{T_{0} - T_{1} + \pars{T_{2} - T_{0}}\pars{-1}^{n} \over n\pi}
$$

\begin{align}
\color{#00f}{\large{\rm T}\pars{x,t}}
&=
\color{#00f}{T_{1} + \pars{T_{2} - T_{1}}\,{x \over L}}
\\[3mm]&\phantom{=}\color{#00f}{+
{2 \over \pi}\sum_{n = 1}^{\infty}{T_{0} - T_{1} + \pars{T_{2} - T_{0}}\pars{-1}^{n} \over n}\,\sin\pars{{n\pi \over L}\,x}
\exp\pars{-\bracks{Dn^{2}\pi^{2}/L^{2}}t}}
\end{align}
