today I was studying partial differential equations and I tried to check if my solution was correct, I thought Mathematica code would be easy, but it wasn’t.

Here is my problem:

Solve $u_{xx}-2tu-u_t=0$ for $0<x<1/2$ and $t>0$ with the boundary conditions $u_x(0,t)=u(1/2,t)=0$ and initial conditions $u(x,0)=1-2x$.

By hand I obtained

$$u(x,t)=frac{8}{pi^2}sum_{n=0}^{infty}frac{1}{(2n+1)^2}e^{-t^2-(2n+1)^2pi^2t}cos((2n+1)pi x)$$

Then I tried with the following code in Mathematica:

```
pde = D(u(x, t), {x, 2}) - 2 t*u(x, t) == D(u(x, t), {t, 1});
ic = {u(x, 0) == 1 - 2 x};
bc = {u(1/2, t) == 0, Derivative(1, 0)(u)(0, t) == 0};
sol = First@(u(x, t) /. DSolve({pde, ic, bc}, u(x, t), {x, t}));
```

I don’t know why I am getting error. Thanks in advance for your help.