obrot[x0_,α_]:=N[Mod[x0+α,2Pi]]

orbita[x0_,α_,n_]:=NestList[obrot[#,α]&,x0,n-1]

?NestList

orbita[0,Pi/2,7]

x0=Pi/2

α=Pi/7

n=10000

10000

2Pi Total[Map[Sin,orbita[x0,α,n]]]/n

Calka[x0_,α_,n_,fun_]:=2Pi Total[Map[fun,orbita[x0,α,n]]]/n

Calka[x0,α,n,Sin]

?WeightedAdjacencyGraph

A= {{0.5,∞,∞,∞,1},{0.5,∞,∞,∞,∞},{∞,1 ,∞,∞,∞},{∞,∞,1,∞,∞},{∞,∞,∞,1,∞}};

A//MatrixForm

WeightedAdjacencyGraph[Table[(Subscript[v, i]),{i,5}],Transpose[A],VertexLabels->"Name",EdgeLabels->"EdgeWeight"]

A= {{0.5,1,∞,∞},{∞,∞,0.5,∞},{0.5,∞,∞,1},{∞,∞,0.5,∞}};

A//MatrixForm

WeightedAdjacencyGraph[Table[(Subscript[v, i]),{i,4}],Transpose[A],VertexLabels->"Name",EdgeLabels->"EdgeWeight"]

?Eigensystem

Eigensystem[A /. {∞ -> 0}]

Re[Eigensystem[A /. {∞ -> 0}][[2]][[1]]]

Re[Eigensystem[A /. {∞ -> 0}][[2]][[1]]]/Total[(Re[Eigensystem[A /. {∞ -> 0}][[2]][[1]]])]

MatrixPower[A /. {∞ -> 0},100]

Zad. 4

GraphicsGrid[{{Style["kot:1/2 ser:1/2", 24], Style["kot:2/3 ser:1/3", 24],
Style["kot:1 ser:0", 24]},
{Style["kot:1/3 ser:2/3", 24], Style["kot:1/2 ser:1/2", 24],
Style["kot:2/3 ser:1/3", 24]},
{Style["kot:0 ser:1", 24], Style["kot:1/3 ser:2/3", 24],
Style["kot:1/2 ser:1/2", 24]}}, Frame->All, ImageSize -> 500
]

Zad. 5

n - poczatkowa komnata

?RandomChoice

P - macierz przejscia

1/3

P = {{0, 1/3, 0, 1/3, 0,0,0,0,0}, {1/2,0,0,0,1/4,0,0,0,0},
{0,1/3,1,0,0,1/3, 0,0,0},
{1/2,0,0,0,1/4,0,0,0,0},
{0,1/3,0,1/3,0,1/3,0,1/3,0},
{0,0,0,0, 1/4, 0,0,0, 1/2},
{0,0,0,1/3,0,0,1,1/3,0},
{0,0,0,0, 1/4,0,0,0,1/2},{0,0,0,0,0, 1/3,0,1/3,0}};

P // MatrixForm

bladzenie[n_]:= RandomChoice[Transpose[P][[n]] ->Range[9]]

bladzenie[1]

?NestWhile

?UnsameQ

szczur[n_] := NestWhile[bladzenie[#]&, n,UnsameQ,2]

szczur[5]

Table[szczur[2],{10}]