(*problem matematickeho kyvadla pre male vychylky
x1 - uhol odklonu od zvislej roviny
x2 - uhlova rychlost pohybu
 x1' =x2 x2'=-kx1 k=l/g          l-dlzka mat.kyvadla g-zrychlenie
v:(x1,x2)->(x2,-kx1)
*)


Needs["VectorFieldPlots`"]

k:=1
VectorFieldPlot[{x2,-k*x1},{x1,-3,3},{x2,-3,3},Axes->True,PlotPoints->9]

ParametricPlot[{Sin[t],Cos[t]},{t,0,2*Pi}]

(*presnejsi model mat.kyvadla  -pre vacsie vychylky
	x1'=x2 , x2=-k*sin(x1),k=l/g
	v:(x1,x2)->(x2,-k*sin(x1))

*)


VectorFieldPlot[{x2,-k*Sin[x1]},{x1,-2*Pi,2*Pi,Pi/4},{x2,-2,2,0.5},Axes->True,Ticks->{{-2*Pi,-Pi,0,Pi,2*Pi},Automatic}]

(*mat kyvadlo - uvazujuci trenie analog. ekon.modelovanie ISML
x1'=x2,x2'=-kx1-mx2,k=l/g
v:(x1,x2)->(x2,-kx1,-mx2)  
  *)

m:=1

VectorFieldPlot[{x2,-k*x1-m*x2},{x1,-3,3},{x2,-3,3},Axes->True,PlotPoints->9]

m:=2
VectorFieldPlot[{x2,-k*x1-m*x2},{x1,-3,3},{x2,-3,3},Axes->True,PlotPoints->9]

(*riesenie Dif.rovnic*)
(*sol je meno a solve riesenie   ...Dsolve pre diferencialne*)
sol=DSolve[x'[t]==Cos[x[t]]^2,x[t],t]  ;   (*3funkcie pre tri parametre C  0,1,2  v tomto riadku riesime. *)
Plot[{x[t]/.sol/.C[1]->0,x[t]/.sol/.C[1]->1,x[t]/.sol/.C[1]->2},{t,-2*Pi,2*Pi}](*tu sa odvolavame na riesenie zhora  /.sol*)

(*teraz to riesime numericky---- riesenie jedinej krivky.ciye musi byt funkcia dana jednoznacne aj so zac.podmienkou*)

sol1=NDSolve[{x'[t]==Sin[x[t]],x[1]==Pi/2},x,{t,0,2*Pi}];
Plot[{Pi,x[t]/.sol1},{t,0,2*Pi},PlotRange->{{0,2*Pi},{-2*Pi-0.5,2*Pi+0.5}}]

(*EKONOMICKY PRIKLAD*)