PARABOLICKE ROVNICE

Riesime rovnicu:
(∂_t) u -4 (∂_(x, x))u = 4*t^2*Cos(x) + 9-x*Sinx*t
u(x,0)=1-x^2
u(0,t)=1+t
u(π/2,t)=t-(π/2)^2
u(x,t)=Cos(x*t)-x^2+t

f[x_, t_] := 
        4*(t^2)*Cos[x] + 9 - x*Sin[x*t];
g[x_] := 1 - x^2;
α[t_] := 1 + t;
β[t_] := t - (π/2)^2;
pres[x_, t_] := Cos[x*t] - x^2 + t;
a = 0;
b = π/2;
pn = 6;
cn = 10;
k = 4;

h = N[(b - a)/(pn + 1)]
τ = h^2/(2*k)

xs = Array[1, pn + 1, 0];
up = Array[1, pn + 1, 0];
u = Array[1, pn + 1, 0];

Do[{xs[[i]] = a + i*h, up[[i]] = g[a + i*h]}, {i, 0, 
        pn + 1}]
num = 
      Table[{xs[[i]], up[[i]]}, {i, 0, 
          pn + 1}]
numgraf = 
        ListPlot[num, PlotRange -> {{0, 2}, {-2, 1.5}}, 
          PlotStyle -> {PointSize[0.02], RGBColor[1, 0, 1]}, 
          DisplayFunction -> Identity];
presgraf = 
        Plot[pres[x, 0], {x, a, b}, 
          PlotRange -> {{0, 2}, {-2, 1.5}}, 
          DisplayFunction -> Identity];

Show[numgraf, presgraf, 
      DisplayFunction -> $DisplayFunction]

σ = ((τ*
                k)/(h^2));
pole = Table[1, {i, 1, pn}];
Do[{
Do[{u[[i]] = 
              up[[i]] + σ*(up[[i - 1]] - 2*up[[i]] + 
                      up[[i + 1]]) + τ*
                  f[a + i*h, (j - 1)*τ]}, {i, 1, 
            pn}], 
Do[{up[[i]] = u[[i]]}, {i, 1, 
            pn}], 
up[[0]] = α[
            j*τ], 
up[[pn + 1]] = β[
            j*τ], 
num = 
          Table[{xs[[k]], up[[k]]}, {k, 0, 
              pn + 1}], 
numgraf = 
          ListPlot[num, PlotRange -> {{0, 2}, {-2, 1.5}}, 
            PlotStyle -> {PointSize[0.02], RGBColor[0, 0.5, 1]}, 
            DisplayFunction -> Identity], 
presgraf = 
          Plot[pres[x, j*τ], {x, a, b}, 
            PlotRange -> {{0, 2}, {-2, 1.5}}, 
            DisplayFunction -> Identity], 
Show[
          numgraf, presgraf, 
          DisplayFunction -> $DisplayFunction], 
Do[
{pole[[i]] = 
              Abs[up[[i]] - pres[a + i*h, j*τ]]}, {i, 1, 
            pn}], 
Print[
          Max[pole]]

}, {j, 1, 
        cn}]

DSolve[(∂_t) u[x, t] - 
          4*(∂_(x, x))u[x, t] == 
        4*(t^2)*Cos[x*t] + 9 - x*Sin[x*t], u[x, t], {x, t}]