Question 1

Evaluate the following limit.

\[\lim_{y \to -1.5} \frac{8y^3 + 27}{2y + 3}\]

# install.packages("Ryacas")
library(Ryacas)
## Warning: package 'Ryacas' was built under R version 4.5.2
## 
## Attaching package: 'Ryacas'
## The following object is masked from 'package:stats':
## 
##     integrate
## The following objects are masked from 'package:base':
## 
##     %*%, det, diag, diag<-, lower.tri, upper.tri
y <- ysym("y")
f <- (8 * y^3 + 27) / (2 * y + 3)
result <- lim(f,y,-1.5)
result
## y: 27.

Question 2

A spinner has the numbers \([1,5,1,5,2,1,5,3]\). The spinner was spun 80 times. Perform a Monte Carlo simulation to determine the probability of spinning a 1.

spinner <- c(1,5,1,5,2,1,5,3) # our spinner
counter <- 0 # counting the number of 1's
N <- 80 # 80 trials (spins)
for (x in 1:N) {
  spin <- sample(spinner,size = 1,replace = T)
  if (spin == 1) {
    counter <- counter + 1
  }
}
probability <- counter / N
cat("The probability of spinning a 1 is:",probability,"\n")
## The probability of spinning a 1 is: 0.425

Question 3

A spinner is in the shape of a regular hexagon number 1 to 5. Richard spun the spinner 20 times and got the following scores below. Record the scores in a frequency table and construct a bar graph for the results.

\[\text{Scores} = [4,3,4,1,1,5,2,1,1,4,1,2,5,2,3,5,3,4,1,2,4]\]

  1. Construct the frequency table.
Scores <- c(4,3,4,1,1,5,2,1,1,4,1,2,5,2,3,5,3,4,1,2,4) # our list of scores
q3_table <- table(Scores) # table of Scores
q3_data <- as.data.frame(q3_table) # changing the table to a data frame
colnames(q3_data) <- c("Score","Frequency") # renaming the column headers
q3_data # displaying the data
##   Score Frequency
## 1     1         6
## 2     2         4
## 3     3         3
## 4     4         5
## 5     5         3
  1. Construct a bar graph.
# 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()
## ✖ purrr::simplify() masks Ryacas::simplify()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
ggplot(q3_data,aes(x = Score,y = Frequency,fill = Score)) +
  geom_col() +
  labs(title = "Richard's Spinner Data",
       x = "Score",
       y = "Frequency",
       fill = "Spin") +
  theme_gray(base_size = 14)