Let \(A\) be a \(3 \times 3\) matrix with \(det(A) = 10\). A new matrix B is formed by performing the following sequence of row operations on \(A\).
\(R_1 \to R_3\)
\(R_2 \to 4 R_2\)
\(R_1 \to R_1 - 2 R_2\)
What is \(det(B)\)?
\[A = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 10 \end{bmatrix}\]
# Define our example matrix A
A <- matrix(data = c(1,0,0,0,1,0,0,0,10),nrow = 3,ncol = 3,byrow = T)
# A. Swap Row 1 and Row 3
B <- A
B[c(1,3), ] <- B[c(3,1), ]
# B. R2 -> 4 R2
B[2, ] <- 4 * B[2, ]
# C. R1 -> R1 - 2 R2
B[1, ] <- B[1, ] - 2 * B[2, ]
# Display matrix B
cat("Matrix B: \n")
## Matrix B:
print(B)
## [,1] [,2] [,3]
## [1,] 0 -8 10
## [2,] 0 4 0
## [3,] 1 0 0
# Determinant of matrix B
cat("det(B) =",det(B),"\n")
## det(B) = -40
You are given the points A(2,3), B(4,7), C(6,5). Plot these points to make a polygon.
# install.packages("tidyverse")
library(tidyverse)
## Warning: package 'lubridate' was built under R version 4.5.2
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.1 ✔ stringr 1.5.2
## ✔ ggplot2 4.0.0 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.1.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
q2_data <- data.frame(Point = c("A","B","C"),
X = c(2,4,6),
Y = c(3,7,5))
ggplot(q2_data,aes(x = X,y = Y)) +
geom_polygon(fill = "lightblue",alpha = 0.5,color = "black",lwd = 1.25) +
geom_point(size = 3) +
geom_text(aes(label = Point),nudge_y = 0.3,fontface = "bold") +
theme_gray()
Ursula throws two tetrahedral dice at the same time and notes the scores on their bottom faces. Answer the following parts.
A. What is the probability both numbers are prime?
# install.packages("pracma")
library(pracma)
##
## Attaching package: 'pracma'
## The following object is masked from 'package:purrr':
##
## cross
die1 <- 1:4 # four sides to a tetrahedral die
die2 <- 1:4 # four sides to a tetrahedral die
N <- 1e6 # 1 million trials
counter1 <- 0
for (i in 1:N) {
roll1 <- sample(x = die1,size = 1,replace = T)
roll2 <- sample(x = die2,size = 1,replace = T)
if (isprime(roll1) & isprime(roll2)) {
counter1 <- counter1 + 1
}
}
probability1 <- counter1 / N
cat("The probability both numbers are prime is:",probability1,"\n")
## The probability both numbers are prime is: 0.249884
B. What is the probability both numbers are not prime?
# install.packages("pracma")
library(pracma)
die3 <- 1:4
die4 <- 1:4
N2 <- 1e6
counter2 <- 0
for (j in 1:N2) {
roll3 <- sample(x = die3,size = 1,replace = T)
roll4 <- sample(x = die4,size = 1,replace = T)
if (!isprime(roll3) & !isprime(roll4)) {
counter2 <- counter2 + 1
}
}
probability2 <- counter2 / N2
cat("The probability both numbers are not prime is:",probability2,"\n")
## The probability both numbers are not prime is: 0.249687