Probabilistic representation of the heat equation with time-dependent Dirichlet data (source code)

= Probabilistic representation of the heat equation with time-dependent Dirichlet data

For $u_t=\frac12u_{xx}$ on $(0,1)$ with initial data $g$ and time-dependent <Dirichlet boundary conditions> $f_1,f_2$, stop <Brownian motion> at its first hit of $0$ or $1$. Applying <Itô formula> to $u(t-s,B_s)$ yields
$$
u(t,x)=\mathbb E_x\!\left[g(B_t)\mathbf1_{\{t<\tau_0\wedge\tau_1\}}+f_1(t-\tau_0)\mathbf1_{\{\tau_0<t\wedge\tau_1\}}+f_2(t-\tau_1)\mathbf1_{\{\tau_1<t\wedge\tau_0\}}\right].
$$