Question 1

Evaluate the following limit.

\[\lim_{x \to 0} \frac{\sin(5x)}{x}\]

# 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
x <- ysym("x")
f <- sin(5 * x) / x
result <- lim(f,x,0)
result
## y: 5

Question 2

Which one of the following numbers is composite?

A. 79

B. 89

C. 99

D. 109

# install.packages(c("tidyverse","pracma"))
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
library(pracma)
## 
## Attaching package: 'pracma'
## 
## The following object is masked from 'package:purrr':
## 
##     cross
q2_data <- data.frame(Choice = LETTERS[1:4],
                      Number = c(79,89,99,109))
correct_answer <- q2_data %>%
  mutate(Prime = isprime(Number)) %>%
  filter(Prime == FALSE) %>%
  pull(Choice)
cat("The correct answer is:",correct_answer,"\n")
## The correct answer is: C

Question 3

Two fair cubical dice, one red and one blue, are thrown at the same time and their scores multiplied together. What is the probability that the product of the scores is less than 12?

red_die <- 1:6
blue_die <- 1:6
N <- 1e5
counter <- 0
for (i in 1:N) {
  roll1 <- sample(x = red_die,size = 1,replace = T)
  roll2 <- sample(x = blue_die,size = 1,replace = T)
  if (roll1 * roll2 < 12) {
    counter <- counter + 1
  }
}
probability <- counter / N
cat("The probability that the product of the scores is less than 12 is:",probability,"\n")
## The probability that the product of the scores is less than 12 is: 0.5283

Question 4

What are the first four terms of the Taylor series for \(e^x\) when \(a = 0\)?

# install.packages("calculus")
library(calculus)
## Warning: package 'calculus' was built under R version 4.5.2
## 
## Attaching package: 'calculus'
## The following objects are masked from 'package:pracma':
## 
##     cross, gradient, hessian, integral, jacobian, laplacian, taylor
## The following object is masked from 'package:purrr':
## 
##     cross
g <- function(x) {
  exp(x)
}
Taylor <- taylor(f = g,var = c(x = 0),order = 3)
Taylor$terms
##   var      coef degree
## 0   1 1.0000000      0
## 1 x^1 1.0000000      1
## 2 x^2 0.5000000      2
## 3 x^3 0.1666667      3