Prvy Priklad(Eulerova metoda)
y'=y[t]+cos[t*y[t]]
a.)
b.)
Zadanie ulohy: funkcia a okrajove ulohy. S prikazom DSolve to nejde vyriesit.

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

!!!toto je Numericke riesenie!!!

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

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

!!!!!!!!!Dopocitat to cez Eulerovu metodu, alebo inou metodou, na DU!!!!!!!!!

f[x_, y_] := 
      x*y^2

    x0 = 0;

    y0 = 1;

    koniec = 1;

    h := 0.1;

    NumRies[x_, y_, f_, h_] := y + h*f[x, y]

    PresneRies[x_] := 2/(2 - x^2)

    nPocetKrokov = koniec/h;

    x[0] = x0

    y[0] = y0

    Do[{x[i] = x0 + i*h, y[i] = NumRies[x[i - 1], y[i - 1], f, h]}, {i, 1, 
        nPocetKrokov, 1}]

    data = Table[{x[i], y[i]}, {i, 0, nPocetKrokov}];

    vysledky = 
      Table[{x[i], y[i], PresneRies[x[i]], 
          Abs[(y[i] - PresneRies[x[i]])]}, {i, 0, 
          nPocetKrokov}]

    chyba = 
        Table[{Abs[(y[i] - PresneRies[x[i]])]}, {i, 0, 
            nPocetKrokov}];

    error = Max[chyba]

\(
\)

Print["chyba pre n-krok je"]
PaddedForm[
      TableForm[vysledky[[nPocetKrokov + 1]]]]
PaddedForm[TableForm[error]]

graf1 = 
      ListPlot[data, 
        PlotStyle -> {RGBColor[0, 0.5, 0], PointSize[0.02]}]

graf2 = 
      ListPlot[data, 
        PlotStyle -> {RGBColor[0, 0, 0.1], PointSize[0.005]}]

graf3 = 
      ListPlot[data, 
        PlotStyle -> {RGBColor[0, 0, 1], PointSize[0.02]}]

graf4 = 
      ListPlot[data, 
        PlotStyle -> {RGBColor[0.2, 0, 0], PointSize[0.02]}]

g = 
      Plot[PresneRies[x], {x, 0, 1}, 
        PlotStyle -> {RGBColor[1, 0, 0], Thickness[0.01]}]

Show[graf1, g]

Druhy Priklad(rad metody)

h = 0.005
Do[{hz = h/j, 
        n = koniec/hz, 
Do[{x[i] = x0 + i*hz, 
            y[i] = NumRies[x[i - 1], y[i - 1], f, hz]}, {i, 1, n, 1}], 
        data3 = Table[Abs[(y[i] - PresneRies[x[i]])], {i, 0, n}], 
        error1[j] = Max[data3]}, {j, 1, 2, 1}]

a = error1[1]
b = error1[2]
rad = Log[2, a/b]