NestList[f,x,3]
NestList[Sin,x,3]

addrandom1[x_]:=x+Random[]-.5
addrandom2[x_]=x+Random[]-.5

addrandom2[y]

addrandom1[x]

proch1=NestList[addrandom1,0,100];
proch2=NestList[addrandom2,0,100];
ListPlot[proch1,PlotJoined->True]
ListPlot[proch2,PlotJoined->True]

(* Ryzi funkce, Pure Functions *)
Clear[g]
g[x_]:=x^2
g[3]

f=Function[x,x^2]
f[3]

f=#^2&
f[3]

(#^2&)[3]

(#1+#2^2&)[a,b]

proch3=NestList[(#+Random[]-.5)&,0,100];

ListPlot[proch3,PlotJoined->True]

Map[f,{1,2,3,4}]

?f

Map[fun,{1,2,3,4}]

??Select

Select[Range[5],#>3&]

Select[Range[10],(3<= # <8)&]

Select[Range[10],(#>=3 && #<8)&]

Needs["DiscreteMath`Master`"]

Table[RandomPermutation[3],{10}]

KSubsets[{1,2,3,4,5},3]

Compositions[6,3]

(* Diferencni rovnice *)
Needs["DiscreteMath`RSolve`"]

res1=RSolve[{f[n]==f[n-1]+f[n-2],f[1]==1,f[2]==1},
	f[n],n]

pv[cf_,i_]:=Module[{j,n},
		n=Length[cf];
		j=Range[0,n-1];
		Apply[Plus,cf/(1+i)^j]]

durbar[cf_,i_]:=pv[cf*Range[0,Length[cf]-1],i]/
	pv[cf,i]
dursedl[cf_,i_]:=Module[{n=Length[cf]-1,t},
	t=Range[0,n];
	Apply[Plus,t*cf/(1+i)^t]/	
		Apply[Plus,cf/(1+i)^t]]

irrmar[cf_]:=Module[{j,n},
	n=Length[cf];
	j=Range[0,n-1];
	j=NSolve[Apply[Plus,cf/(1+x)^j]==0,x];
	Cases[x/.j,z_Real/;z>=0]]

irrmar[cf1]

cf2={-1000,3600,-4310,1716}
Plot[pv[cf2,i],{i,0,.5},PlotRange->All];
irrmar[cf2]

?LinearProgramming

c={-17,20,-18};
m={{-1,1,-1},
   {-1,0,0},
   {1,0,1}};
b={-10,-5,20};
x0=LinearProgramming[c,m,b]
Print["Hodnota ucelove funkce = ",c.x0]

?LinearProgramming

c={-17,20,-18};
m={{-1,1,-1},
   {-1,0,0},
   {1,0,1}};
b={-10,-5,20};
x0=LinearProgramming[c,m,b]
Print["Hodnota ucelove funkce = ",c.x0]

?LinearProgramming

c={-17,20,-18};
m={{-1,1,-1},
   {-1,0,0},
   {1,0,1}};
b={-10,-5,20};
x0=LinearProgramming[c,m,b]
Print["Hodnota ucelove funkce = ",c.x0]

(* Vyrovnat data funkci a*x*Exp[-c*x] *)
data2=Table[{x,3.1*x*Exp[-2.1x]+
0.05*(Random[]-0.5)},{x,0.02,2,0.02}];
ListPlot[data2,PlotJoined->True];

Map[f,{1,2,3}]
Map[#&,{1,2,3}]

trdata2=Map[{#[[1]],Log[#[[2]]]}&,data2];
graf1=ListPlot[trdata2,PlotJoined->True]

fun2=Fit[trdata2,{1,Log[x],x},x]
graf2=Plot[fun2,{x,0.02,2}]

Show[graf1,graf2]