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$.
 A: 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. 
A: 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$.
A: 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]);


Addition. Mathematica produces the same answer by
DSolve[{D[u[x, t], t] == D[u[x, t], {x, 2}], u[0, t] == 0,  

u[1, t] == 0, u[x, 0] == (x - 1/2)^2 - 1/4}, u[x, t], {x, t}]

$$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} $$
