Riesime rovnicu:
(Subscript[u, t])  - 4(Subscript[u, xx]) =4  t^2 cos xt + 9 - x sin xt
u (x, 0) = 1 - x^2
u (0, t) = 1 + t
u (π/2, t) = t - (π/2)^2
u (x, t) = cos xt  -  x^2  + t

f[x_, t_] := 
        4*t^2*Cos[x*t] + 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;
k = 4;
pn = 12;
cn = 5;

h = N[(b - a)/(pn + 1)]
τ = h^2/(4*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, π/2}}, 
          PlotStyle -> {PointSize[0.03], RGBColor[1, 0, 1]}, 
          DisplayFunction -> Identity];
presgraf = 
        Plot[pres[x, 0], {x, a, b}, 
          PlotRange -> {{0, π/2}, {-π/2, π/2}}, 
          DisplayFunction -> Identity];

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

con = (τ*k)/(h^2);
Do[{
Do[{u[[i]] = 
                up[[i]] + 
                  con*(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[[l]], up[[l]]}, {l, 0, 
              pn + 1}], 
numgraf1 = 
          ListPlot[num, 
            PlotRange -> {{0, π/2}, {-π/2, π/2}}, 
            PlotStyle -> {PointSize[0.03], RGBColor[1, 0, 1]}, 
            DisplayFunction -> Identity]; 
presgraf1 = 
          Plot[pres[x, j*τ], {x, a, b}, 
            PlotRange -> {{0, π/2}, {-π/2, π/2}}, 
            DisplayFunction -> Identity], 
Show[
          presgraf1, numgraf1, 
          DisplayFunction -> $DisplayFunction]}, {j, 1, cn}]