Fixed-temperature and fixed-flux heat equation on an interval (source code)

= Fixed-temperature and fixed-flux heat equation on an interval
{title2=$u_t=\nu u_{xx},\quad u(0,t)=0,\quad k u_x(L,t)=H$}

For positive thermal <diffusivity> $\nu$, <thermal conductivity> $k$ and length $L$, subtract the <stationary solution> $w(x)=Hx/k$. The remainder satisfies the <heat equation> with a homogeneous <Dirichlet boundary condition> at zero and a homogeneous <Neumann boundary condition> at $L$. The <mixed Dirichlet-Neumann modes on an interval> are $\sin(k_nx)$, where $k_n=(n+1/2)\pi/L$. Thus for an initial <temperature> profile $u_0$,
$$
u(x,t)=\frac{Hx}k+\sum_{n=0}^\infty b_n\sin(k_nx)e^{-\nu k_n^2t},\qquad b_n=\frac2L\int_0^L\left(u_0(x)-\frac{Hx}k\right)\sin(k_nx)dx.
$$
For zero initial <temperature>, $b_n=-2H(-1)^n/(kLk_n^2)$. The series gives the initial profile in the usual <Fourier series> sense and a smooth solution for $t>0$. If $H\ne0$, the zero initial profile does not satisfy the prescribed endpoint derivative at $t=0$: the <temperature> can be continuous there without its spatial <derivative> extending continuously to that corner. The sign $k u_x(L,t)=H>0$ describes incoming <heat flux>, since the outward conductive <heat flux> is $-k u_x$.