\(<< graphics\Plotfield.m\)

k = -1;
th = 3;
PlotVectorField[{x2, -k*x1}, {x1, -th, th}, {x2, -th, th}, 
      Axes -> True, PlotPoints -> 9]
ParametricPlot[{Sin[t], Cos[t]}, {t, 0, 2*π}, ]

k = 1;
th = 2*Pi;
PlotVectorField[{x2, -k*Sin[x1]}, {x1, -th, th, 
        0.5}, {x2, -th, th, 0.5}, Axes -> True, 
      Ticks -> {{-th, -th/2, 0, th/2, th}, 
          Automatic}]

k = 1;
th = 2*Pi;
m = 1;
PlotVectorField[{x2, -k*x1 - m*x2}, {x1, -th, th, 
        1.5}, {x2, -th, th, 1.5}, Axes -> True, 
      Ticks -> {{-th, -th/2, 0, th/2, th}, 
          Automatic}]

riesenie dif rovnice

    y[t] je nezmana

    t je premenna

    y'  =  cosY^2  (toto hladame)

    ' = uvodzovka

sol = 
      DSolve[y'[t] == Cos[y[t]]^2, y[t], 
        t]
Plot[{y[t] /. sol /. C[1] -> 0, y[t] /. sol /. 
          C[1] -> 1, y[t] /. sol /. C[1] -> 2}, {t, -4*Pi, 
        3*Pi}]

a teraz pridu pociatocne podmienky
y' (t)  =  sin (y (t))
y[1]  =  
      pi /2     :: pociatocna podmienka
sol1 = 
      DSolve[{y'[t] == Sin[y[t]], y[1] == Pi/2}, y[t], 
        t]
Plot[{Pi, y[t] /. sol1}, {t, 0, th2*Pi}]

sol1 = 
      DSolve[y'[t] == Sin[y[t]], y[t], 
        t]
Plot[{y[t] /. sol1 /. C[1] -> 0, y[t] /. sol1 /. 
          C[1] -> 1, y[t] /. sol1 /. 
          C[1] -> -t}, {t, -Pi, Pi}]

numericke riesenie NDSolve
numericky (NDSolve) to vie vyriesit vacsinou aj vtedy ked to nevie vseobecne,  teda cez DSolve

th2  =  3
sol3 = 
      NDSolve[{a'[t] == Sin[a[t]], a[1] == Pi/2}, 
        a, {t, 0, th2*Pi}]
Plot[{Pi, a[t] /. sol3}, {t, 0, th2*Pi}]

urcte funkciu na narast invseticii,  
    na 10 000 dolarov pri 6  % uroku, 
Do[
      Print[i, "kapital: ", (y[i]) /. sol5[[1]] // N], {i, 0, 
        10}]
Do[Print[
        t, ", spojite: kapital: ", (y[t]) /. sol5[[1]] // N], {t, 
        0, 10}]
Do[Print[i, ", rocne: kapital: ", (1.06^i*10000) // N], {i, 0, 
        10}]

r  =  0.06;
sol5 = 
      DSolve[{y'[t] == r*y[t], y[0] == 10000}, y[t], 
        t]
Plot[{y[t] /. sol5, 1.06^t*10000}, {t, 0, 50}, 
      PlotStyle -> {RGBColor[0, 1, 1], RGBColor[1, 0, 0]}, 
      GridLines -> Automatic, 
      PlotLabel -> "Spojite urokovanie, vklad 10 000$, urok 6%", 
      AxesLabel -> {"ze Roky", "ze Dolare"}]
Do[Print[
        t, ", spojite: kapital: ", (y[t]) /. sol5[[1]] // N], {t, 
        0, 10}]
Do[Print[i, ", rocne: kapital: ", (1.06^i*10000) // N], {i, 0, 
        10}]
Do[Print[
        t, ", rozdiel: ", ((y[t]) /. 
              sol5[[1]]) - (1.06^t*10000)], {t, 0, 
        10}]
Do[Print[
        t, ", spojite: ", (y[t]) /. sol5[[1]] // 
          N, ", rocne: kapital: ", (1.06^t*10000) // 
          N, ", rozdiel: ", ((y[t]) /. 
              sol5[[1]]) - (1.06^t*10000)]  , {t, 0, 
        10}]

aleno  =  0;
Do[aleno += i, {i, 1000}]
aleno