CoCalc Public Filesmarkov.sagews
Author: Matt Thomas
Views : 9
%typeset_mode True

P = Matrix([[1,0,0,0,0],[1/2,0,1/2,0,0],[0,1/2,0,1/2,0],[0,0,1/2,0,1/2],[0,0,0,0,1]]); P

$\displaystyle \left(\begin{array}{rrrrr} 1 & 0 & 0 & 0 & 0 \\ \frac{1}{2} & 0 & \frac{1}{2} & 0 & 0 \\ 0 & \frac{1}{2} & 0 & \frac{1}{2} & 0 \\ 0 & 0 & \frac{1}{2} & 0 & \frac{1}{2} \\ 0 & 0 & 0 & 0 & 1 \end{array}\right)$
N(P^(50))

$\displaystyle \left(\begin{array}{rrrrr} 1.00000000000000 & 0.000000000000000 & 0.000000000000000 & 0.000000000000000 & 0.000000000000000 \\ 0.749999985098839 & 1.49011611938477 \times 10^{-8} & 0.000000000000000 & 1.49011611938477 \times 10^{-8} & 0.249999985098839 \\ 0.499999985098839 & 0.000000000000000 & 2.98023223876953 \times 10^{-8} & 0.000000000000000 & 0.499999985098839 \\ 0.249999985098839 & 1.49011611938477 \times 10^{-8} & 0.000000000000000 & 1.49011611938477 \times 10^{-8} & 0.749999985098839 \\ 0.000000000000000 & 0.000000000000000 & 0.000000000000000 & 0.000000000000000 & 1.00000000000000 \end{array}\right)$
N(vector([1/5,1/5,1/5,1/5,1/5])*P^(50))

$\displaystyle \left(0.499999991059303,\,5.96046447753906 \times 10^{-9},\,5.96046447753906 \times 10^{-9},\,5.96046447753906 \times 10^{-9},\,0.499999991059303\right)$
Q = matrix([[0,1/2,0],[1/2,0,1/2],[0,1/2,0]]); Q

$\displaystyle \left(\begin{array}{rrr} 0 & \frac{1}{2} & 0 \\ \frac{1}{2} & 0 & \frac{1}{2} \\ 0 & \frac{1}{2} & 0 \end{array}\right)$
R = matrix([[1/2,0],[0,0],[0,1/2]]); R

$\displaystyle \left(\begin{array}{rr} \frac{1}{2} & 0 \\ 0 & 0 \\ 0 & \frac{1}{2} \end{array}\right)$
N = (identity_matrix(3)-Q).inverse(); N

$\displaystyle \left(\begin{array}{rrr} \frac{3}{2} & 1 & \frac{1}{2} \\ 1 & 2 & 1 \\ \frac{1}{2} & 1 & \frac{3}{2} \end{array}\right)$
c = vector([1,1,1]); c

$\displaystyle \left(1,\,1,\,1\right)$
N*c

$\displaystyle \left(3,\,4,\,3\right)$
B = N*R; B

$\displaystyle \left(\begin{array}{rr} \frac{3}{4} & \frac{1}{4} \\ \frac{1}{2} & \frac{1}{2} \\ \frac{1}{4} & \frac{3}{4} \end{array}\right)$