Sol4 = 
      DSolve[{a'[t] == a[t] + Cos[t + a[t]], a[0] == 0}, a, 
        t]

Sol5 = 
      NDSolve[{a'[t] == a[t] + Cos[t + a[t]], a[0] == 0}, 
        a, {t, 0, 2*Pi}]

Plot[{a[t] /. Sol5}, {t, 0, 2*Pi}]

\(\(\( (*\ \ \ a2y'' + \ a1y'\  + \ a0y = 
        f \((x)\)\ \ \ \ *) \)\(
\)\( (*\ \ \ y \((a)\) = \(ya\ \ y \((b)\) = 
          y \((b)\)\)\ \ \ \ \ \ \ *) \)\(
\)\( (*\ \ \ a0, 
      a1, a2\ ϵ\ R\ \ \ \ \ \ \ \ \ \ \ \ \ \ *) \)\(
\)\(
\)\( (*\ \ \ y'' - y = 
        x^3\  + \ 6  x^2\  + \ 
          1\ \ \ \ \ \ *) \)\(
\)\( (*\ \ \ y \((0)\)\  = 
        1\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *) \)\(
\)\( (*\ \ \ y \((2)\) = 
        5\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *) \)\(
\)\(
\)\(pr[x_] := 
      8.286134462  Exp[x] + 5.713865537  Exp[\(-x\)] - x^3 - 6  x^2 - 6  x - 
        13

    f[x_] := x^3 + 6  x^2 + 1

    \(a2 = 1;\)

    \(a1 = 0;\)

    \(a0 = \(-1\);\)

    \(a = 0;\)

    \(b = 2;\)

    \(ya = 1;\)

    \(yb = 5;\)

    Needs["LinearAlgebra`Tridiagonal`"]\)\)\)

Okrajovauloha[n_, xleft_, xright_, LeftBv_, RightBv_, a0_, a1_, a2_, 
        f_, pr_] := 
Module[
{h, a, b, c, 
          ps, diag, hordiag, doldiag, riesenie}, 
h = 
          N[(xright - xleft)/(n + 1)]; 
a = 
          N[a0 - 2  a2/h^2]; 
b = 
          N[a2/h^2 + a1/2*h]; 
c = 
          N[a2/h^2 - a1/2*h]; 
ps = 
          Join[{f[xleft + h] - c*LeftBv}, 
            Table[f[xleft + i*h], {i, 2, n - 1}], {f[xleft + n*h] - 
                b*RightBv}]; 
diag = 
          Table[a, {n}]; 
hordiag = 
          Table[b, {n - 1}]; 
doldiag = 
          Table[c, {n - 1}]; 
Print[
          ps]; 
Print[diag]; 
Print[
          doldiag]; 
Print[
          hordiag]; 
riesenie = 
          TridiagonalSolve[N[doldiag], N[diag], N[hordiag], 
            N[ps]]; 
xsuradnice = 
          Table[xleft + (i - 1)*h, {i, 1, 
              n + 2}]; 
ysuradnice = 
          Join[{LeftBv}, 
            Table[riesenie[[i]], {i, 1, 
                n}], {RightBv}]; 
Print[
          xsuradnice]; 
Print[
          ysuradnice]; 
graf = 
          Table[{xsuradnice[[i]], ysuradnice[[i]]}, {i, 1, 
              n + 2}]; 
vysledky = 
          Table[{xsuradnice[[i]], ysuradnice[[i]], 
              pr[xsuradnice[[i]]], 
              Abs[(ysuradnice[[i]] - pr[xsuradnice[[i]]])]}, {i, 
              1, n + 2}]
]

Okrajovauloha[5, 0, 2, 1, 5, -1, 0, 1, f, pr];

g1 = 
        Plot[pr[x], {x, a, b}, 
          DisplayFunction -> Identity];
g2 = 
        ListPlot[graf, DisplayFunction -> Identity, 
          PlotStyle -> {PointSize[0.025], 
              RGBColor[0, 0, 1]}];
Show[g1, g2, DisplayFunction -> $DisplayFunction]

\(\(\( (*\ \ \ PRIKLAD\ 2\ \ \ *) \)\(
\)\(
\)\(f[x_] := Cos[x]

    \(a2 = 1;\)

    \(a1 = \(-2\);\)

    \(a0 = 3;\)

    \(a = 0;\)

    \(b = Pi;\)

    \(ya = 1;\)

    \(yb = \(-Pi\);\)

    Needs["LinearAlgebra`Tridiagonal`"]\)\)\)

Okrajovauloha[20, 0, 2, 1, 5, -1, 0, 1, f, pr];

g2 = 
        ListPlot[graf, DisplayFunction -> Identity, 
          PlotStyle -> {PointSize[0.02], 
              RGBColor[0.4, 0, 0.8]}];
Show[g2, DisplayFunction -> $DisplayFunction]

f[x_] := 
      x^2*(Sin[x] - Cos[x]) - 2  x * Sin[x]
a = 0;
b = Pi;
ya = 0;
yb = -Pi;
a0[x_] := 1;
a1[x_] := -x

ps = Join[{f[
              xleft + h] - (a2[xleft + h]/h^2 - 
                a1[xleft + h]/(2*h))