Question 1

Evaluate the following limit.

\[\lim_{x \to \frac{\pi}{2}} \frac{\cot(x)}{\csc(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 <- (cos(x) / sin(x)) / (1 / sin(x))
result <- lim(f,x,pi / 2)
result
## y: 0

Question 2

Evaluate the following indefinite integral.

\[\int \frac{\tan(x)}{\sec(x) - \tan(x)} dx\]

# install.packages(c("ggformula","mosaicCalc"))
library(ggformula)
## Warning: package 'ggformula' was built under R version 4.5.2
## Loading required package: ggplot2
## Loading required package: scales
## Loading required package: ggiraph
## Warning: package 'ggiraph' was built under R version 4.5.2
## Loading required package: ggridges
## Warning: package 'ggridges' was built under R version 4.5.2
## 
## New to ggformula?  Try the tutorials: 
##  learnr::run_tutorial("introduction", package = "ggformula")
##  learnr::run_tutorial("refining", package = "ggformula")
library(mosaicCalc)
## Warning: package 'mosaicCalc' was built under R version 4.5.2
## Registered S3 method overwritten by 'mosaic':
##   method                           from   
##   fortify.SpatialPolygonsDataFrame ggplot2
## 
## Attaching package: 'mosaicCalc'
## The following object is masked from 'package:stats':
## 
##     D
g <- makeFun(tan(x) / ((1 / cos(x)) - tan(x)) ~ x)
anti_g <- antiD(g(x) ~ x)
anti_g
## function (x, C = 0) 
## {
##     F <- makeF(tan(x)/((1/cos(x)) - tan(x)))
##     evalFun(F, x = x, .const = C)
## }
## <environment: 0x000002794b18caf8>

Question 3

Consider \(p(x,y,z) = xyz + x^2z^2 + y^3z\). What is the value of \(p_{xyz} + p_{zxy} + p_{yzx}\)?

# install.packages("Deriv")
library(Deriv)
p <- function(x,y,z) {
  x * y * z + x^2 * z^2 + y^3 * z
}
p_xyz <- Deriv(Deriv(Deriv(p,"x"),"y"),"z")
p_zxy <- Deriv(Deriv(Deriv(p,"z"),"y"),"x")
p_yzx <- Deriv(Deriv(Deriv(p,"y"),"z"),"x")
cat("p_xyz =","\n")
## p_xyz =
print(p_xyz)
## function (x, y, z) 
## 1
cat("p_zxy =","\n")
## p_zxy =
print(p_zxy)
## function (x, y, z) 
## 1
cat("p_yzx =","\n")
## p_yzx =
print(p_yzx)
## function (x, y, z) 
## 1

Question 4

Write \([\frac{5}{12},\frac{11}{12},\frac{7}{12},\frac{4}{12}]\) in order from smallest to largest.

# install.packages("tidyverse")
library(tidyverse)
## Warning: package 'lubridate' was built under R version 4.5.2
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats   1.0.1     ✔ stringr   1.5.2
## ✔ lubridate 1.9.4     ✔ tibble    3.3.0
## ✔ purrr     1.1.0     ✔ tidyr     1.3.1
## ✔ readr     2.1.5     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ readr::col_factor() masks scales::col_factor()
## ✖ purrr::discard()    masks scales::discard()
## ✖ tidyr::expand()     masks Matrix::expand()
## ✖ dplyr::filter()     masks stats::filter()
## ✖ dplyr::lag()        masks stats::lag()
## ✖ tidyr::pack()       masks Matrix::pack()
## ✖ purrr::simplify()   masks Ryacas::simplify()
## ✖ tidyr::unpack()     masks Matrix::unpack()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
q4_data <- data.frame(Fractions = c(5/12,11/12,7/12,4/12))
q4_data %>%
  arrange(Fractions) # arrange(): ascending order
##   Fractions
## 1 0.3333333
## 2 0.4166667
## 3 0.5833333
## 4 0.9166667

Question 5

What is the least common multiple of 12 and 15?

# install.packages("pracma")
library(pracma)
## 
## Attaching package: 'pracma'
## The following object is masked from 'package:purrr':
## 
##     cross
## The following objects are masked from 'package:Matrix':
## 
##     expm, lu, tril, triu
answer <- Lcm(a = 12,b = 15)
cat("The least common multiple of 12 and 15 is:",answer,"\n")
## The least common multiple of 12 and 15 is: 60

Question 6

Two spinners are numbered 1 to 5 in the shapes of regular pentagons. You spin the two spinners at the same time and note the numbers. What is the probability that one number is prime and one number is not prime?

# install.packages("pracma")
library(pracma)
spinner1 <- 1:5
spinner2 <- 1:5
counter <- 0
N <- 1e5
for (i in 1:N) {
  spin1 <- sample(spinner1,size = 1,replace = T)
  spin2 <- sample(spinner2,size = 1,replace = T)
  if ((isprime(spin1) && !isprime(spin2)) || (!isprime(spin1) && isprime(spin2))) {
    counter <- counter + 1
  }
}
probability <- counter / N
cat("The probability is:",probability,"\n")
## The probability is: 0.48143