I have to solve the heat equation
$\qquad u_t=u_{xx}+0.5 u, 0<x<1,t>0$
and
$\qquad u_x (0,t)=u_x (1,t)=0, u(x,0)=[\cos(\pi x)]^2.$
I used
uF =
NDSolveValue[
{D[u[x, t], t] == D[u[x, t], {x, 2}] - 0.5*D[u[x, t], x],
u[x, 0] == (Cos[Pi*x])^2, D[u[0, t]] == 0, D[u[1, t]] == 0},
u, {x, 0, 1}, {t, 0, 2}]
Plot3D[uF[x, t], {x, 0, 1}, {t, 0, 2},
AxesLabel -> {"x","t","u"}, PlotRange -> All]
But I get
boundary and initial conditions are inconsistent
Is there a solution by Fourier transformation and using partial sums (e.g., for N = 5, 10, 15
)? I need the same thing for
$\qquad u_{tt}=c^2 u_{xx}, 0<x<\pi,t>0$
and
$\qquad c=\frac{1}{4 \pi},u(0,t)=u(1,t)=0, u(x,0)=\sin x-\sin{(4x)}+\sin{(9x)}$