# One dimensional heat equation with boundary conditions

Consider the heat equation $$u_t = u_{xx}$$ for $$t \ge 0$$, $$0 \le x \le L$$, given boundary conditions $$u(0,t) = u(L,t) = f(t)$$ and an initial condition $$u(x,0) = g(x)$$ for some continuous functions $$g(x)$$ on $$[0,T]$$ and $$f(t)$$ on $$[0,\infty)$$.

Is there an explicit solution for $$u$$? In particular, I was wondering if $$u$$ can be expressed in terms of some integral involving $$g$$ and $$f$$.

Imposing some conditions on $$f$$ and $$g$$ the solution can be represented via Green's function G: $$u(x,t)=\int_0^L G(x,y,t)g(y)\,dy+\int_0^t\partial_y G(x,0,t-\tau)f(\tau)\,d\tau-$$ $$\int_0^t\partial_y G(x,L,t-\tau)f(\tau)\,d\tau.$$ Green's function for the first BVP on a segment can be written out explicitly as series, see ch. 3, $$\S7$$ in A. Friedman, Partial differential equations of parabolic type.

In general, there isn't a solution at all, let alone an explicit one. For example, take $$f(t)=0$$ and $$g(x)=(x-L/2)^2 -L^2/4$$. Then, at $$t=0$$, we have $$u_t = u_{xx} =2$$ at all $$x$$, including $$x=0$$ and $$x=L$$. This, however, contradicts $$u_t =0$$ for $$x=0$$ and $$x=L$$ as determined by the given $$f(t)=0$$.

• as a general comment it might be helpful to try and change of variable like $v(x,t)=u(x,t)- f(t)$ and write out the equation for $v$. At least this way one gets a problem with zero Dirichlet boundary conditions; which I assume should help the intuition – Math604 Jun 3 at 14:17
• How about a weak solution, not a classical one? – user64494 Jun 3 at 14:32
• ya i would assume the change of variables is fine for a weak solution. The main point was that at least this makes the problem much close to what (I assume) most people are used to considering. – Math604 Jun 3 at 15:07
• @user64494 - well, the OP asked for the solution on the closed domain. Be careful what you wish for ... indeed, a weak solution works. – Michael Engelhardt Jun 3 at 15:48

Maple 2019.1 finds its weak solution by

pdsolve({diff(u(x, t), t) = diff(u(x, t), x, x), u(0, t) = f(t), u(L, t) = f(t), u(x, 0) = g(x)}, u(x, t));


, producing $$u \left( x,t \right) =\sum _{n=1}^{\infty } \left( -2\,{\frac {1}{L} \sin \left( {\frac {\pi\,nx}{L}} \right) {{\rm e}^{-{\frac {{\pi}^{2}{ n}^{2}t}{{L}^{2}}}}}\int_{0}^{L}\! \left( -g \left( \tau \right) +f \left( 0 \right) \right) \sin \left( {\frac {\pi\,n\tau}{L}} \right) \,{\rm d}\tau} \right) +\\\int_{0}^{t}\!\sum _{n=1}^{\infty }2 \,{\frac { \left( {\frac {\rm d}{{\rm d}\tau}}f \left( \tau \right) \right) \left( \left( -1 \right) ^{n}-1 \right) }{\pi\,n}\sin \left( {\frac {\pi\,nx}{L}} \right) {{\rm e}^{-{\frac {{\pi}^{2}{n}^{ 2} \left( t-\tau \right) }{{L}^{2}}}}}}\,{\rm d}\tau+f \left( t \right)$$ In particular,

pdsolve({diff(u(x, t), t) = diff(u(x, t), x, x), u(0, t) = 0, u(1, t) = 0, u(x, 0) = (x - 1/2)^2 - 1/4}, u(x, t));


$$u \left( x,t \right) =\sum _{n=1}^{\infty }4\,{\frac {\sin \left( n\pi \,x \right) {{\rm e}^{-{\pi}^{2}{n}^{2}t}} \left( \left( -1 \right) ^ {n}-1 \right) }{{n}^{3}{\pi}^{3}}}$$ and

plot3d(Sum(4*sin(n*Pi*x)*exp(-Pi^2*n^2*t)*((-1)^n - 1)/(n^3*Pi^3), n = 1 .. infinity), x = 0 .. 1, t = 0 .. 2, grid = [60, 60]);


DSolve[{D[u[x, t], t] == D[u[x, t], {x, 2}], u[0, t] == 0,

$$u(x,t)\to \underset{K[1]=1}{\overset{\infty }{\sum }}\frac{4 \left(-1+(-1)^{K[1]}\right) e^{-\pi ^2 t K[1]^2} \sin (\pi x K[1])}{\pi ^3 K[1]^3}$$