using LinearAlgebra A = [0.9 0.2 0.1 0.8] eigvals(A) A^100 * [17, 4] cx₀ = A^1000 * [17, 4] A * cx₀ o = [1,1] o'A A' * o A - 1*I (A - I) * [2,1] # The following code prints a sequence of Aⁿx values # for n=0,1,2,… nicely formatted with LaTeX. x = [3, 0] pmatrix(x) = string("\\begin{pmatrix} ", round(x[1],digits=3), "\\\\", round(x[2],digits=3), "\\end{pmatrix}") buf = IOBuffer() println(buf, "\$") for k = 1:6 print(buf, pmatrix(x), " \\longrightarrow ") for i = 1:4 x = A*x print(buf, pmatrix(x), " \\longrightarrow ") end println(buf, "\\\\") end println(buf, "\$") display("text/latex", String(take!(buf))) A^100 P = [0 1 1 0] [P^n * [1,0] for n = 0:5] eigvals(P) X = eigvecs(P) # the eigenvectors X ./ X[1,:]' # normalize the first row to be 1, to resemble our hand solutions M = rand(5,5) # random entries in [0,1] sum(M,dims=1) # not Markov yet M = M ./ sum(M,dims=1) sum(M,dims=1) eigvals(M) abs.(eigvals(M)) x = rand(5) x = x / sum(x) # normalize x to have sum = 1 M^100 * x sum(x), sum(M^100 * x) # still = 1 λ, X = eigen(M) X[:,end] / sum(X[:,end]) # eigenvector for λ=1, normalized to sum=1