Solution (source code)

= Solution

For $v=(t+1)^2u$, the derivatives are
$$
v_t=2(t+1)u+(t+1)^2u_t,\qquad v_{xx}=(t+1)^2u_{xx}.
$$
Substitution cancels the two terms $2(t+1)u$, giving the <diffusion equation>
$$
\boxed{u_t=u_{xx},\qquad u(0,t)=0,\quad u(\pi,t)=\frac{f(t)}{(t+1)^2},\quad u(x,0)=h(x).}
$$
This is a <scalar integrating factor for a reaction-diffusion equation>, since $\exp[\int2\,dt/(t+1)]=(t+1)^2$ up to a constant. We use $t\geq0$, so the factor never vanishes. A classical solution at the initial corners additionally requires compatible data, $h(0)=0$ and $h(\pi)=f(0)$.