--- title: "Math 339SP -- Matrix products" author: "Tim Chumley" date: "Spring 2024" output: pdf_document: default --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) library(tinytex) library(expm) ``` # Matrix power calculations The commands below demonstrate how to input a matrix, entry by entry, and do some computations with matrix multiplication and exponentiation. ```{r} P = matrix(c(0, 1/3, 0, 1/3, 1/3, 0, 1/2, 0, 0, 1/2, 0, 0, 0, 0, 0, 1/2, 1/2, 0, 1/4, 1/4, 1/4, 0, 1/4, 0, 1/4, 0, 1/4, 1/4, 0, 1/4, 0, 0, 0, 0, 1, 0), nrow = 6, ncol = 6, byrow = T) P %*% P # the matrix P times P P %^% 2 # the matrix P^2 (P %^% 2)[4,5] # the (4,5) entry of P^2 ```