PARABOLICKE ROVNICE

Riesime rovnicu:
(∂_t) u - (∂_(x, x))u = 2*t*x - 1
u(x,0)=x^2
u(0,t)=t
u(1,t)=1+t+t^2
u(x,t)=x*t^2+x^2+t

f[x_, t_] := 2*t*x - 1;
g[x_] := x^2;
α[t_] := t;
β[t_] := 1 + t + t^2;
pres[x_, t_] := x*t^2 + x^2 + t;
a = 0;
b = 1;
pn = 6;
cn = 10;
k = 1;

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, 1}, {0, 1.5}}, 
          PlotStyle -> {PointSize[0.02], RGBColor[1, 0, 1]}, 
          DisplayFunction -> Identity];
presgraf = 
        Plot[pres[x, 0], {x, a, b}, PlotRange -> {{0, 1}, {0, 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, 1}, {0, 1.5}}, 
            PlotStyle -> {PointSize[0.02], RGBColor[0, 0.5, 1]}, 
            DisplayFunction -> Identity], 
presgraf = 
          Plot[pres[x, j*τ], {x, a, b}, 
            PlotRange -> {{0, 1}, {0, 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}]