---
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)
```




```{r}
P = matrix(c(1/2, 1/2,
             2/3, 1/3), nrow = 2, ncol = 2, byrow = T)
P %^% 2
P %^% 3
P %^% 4
P %^% 5
P %^% 10
P %^% 20
P %^% 30
P %^% 97
P %^% 98
P %^% 99
P %^% 100
```

```{r}
P = matrix(c(0, 1/2, 0, 0, 1/2,
             1/2, 0, 1/2, 0, 0,
             0, 1/2, 0, 1/2, 0,
             0, 0, 1/2, 0, 1/2,
             1/2, 0, 0, 1/2, 0), nrow = 5, ncol = 5, byrow = T)

P %^% 10
P %^% 20
P %^% 30
P %^% 97
P %^% 98
P %^% 99
P %^% 100
```

```{r}
P = matrix(c(1/2, 1/2, 0, 0, 0,
             2/3, 1/3, 0, 0, 0,
             0, 0, 1/4, 3/4, 0,
             0, 0, 4/5, 1/5, 0,
             1/4, 1/4, 1/4, 1/4, 0), nrow = 5, ncol = 5, byrow = T)

P %^% 2
P %^% 3
P %^% 4
P %^% 5
P %^% 10
P %^% 20
P %^% 30
P %^% 97
P %^% 98
P %^% 99
P %^% 100
```

```{r}
P = matrix(c(0, 1/2, 0, 0, 0, 1/2,
             1/2, 0, 1/2, 0, 0, 0,
             0, 1/2, 0, 1/2, 0, 0,
             0, 0, 1/2, 0, 1/2, 0,
             0, 0, 0, 1/2, 0, 1/2,
             1/2, 0, 0, 0, 1/2, 0), nrow = 6, ncol = 6, byrow = T)
P %^% 2
P %^% 3
P %^% 4
P %^% 5
P %^% 10
P %^% 20
P %^% 30
P %^% 97
P %^% 98
P %^% 99
P %^% 100
```

