Question 1

A measured angle satisfies \(h(x) = \cos^{-1} (x^2)\). What is \(h'(x)\)?

# install.packages("Deriv")
library(Deriv)
h <- function(x) {
  acos(x^2) # acos(): inverse cosine
}
h_prime <- Deriv(h)
h_prime
## function (x) 
## -(2 * (x/sqrt(1 - x^4)))

Question 2

A medical device models response as \(v(x) = \csc^{-1} (2x^2 + 1)\). What is \(v'(x)\)?

# install.packages("Deriv")
library(Deriv)
v <- function(x) {
  1 / asin(2 * x^2 + 1) # 1 / asin() = acsc() or inverse cosecant
}
v_prime <- Deriv(v)
v_prime
## function (x) 
## {
##     .e1 <- 1 + 2 * x^2
##     -(4 * (x/(asin(.e1)^2 * sqrt(1 - .e1^2))))
## }

Question 3

How many composite numbers are there between 60 and 69 inclusive?

# install.packages(c("comprehenr","pracma"))
library(comprehenr)
## Warning: package 'comprehenr' was built under R version 4.5.2
library(pracma)
composite_numbers <- to_vec(for (x in 60:69) if (!isprime(x)) x)
cat("There are",length(composite_numbers),"composite numbers between 60 and 69 inclusive.")
## There are 8 composite numbers between 60 and 69 inclusive.

Question 4

In the game of roulette, a horizontal spinner (the roulette wheel) is spun so that a small ball can land at random in any one of the 38 grooves. Oswald spun the spinner and waited until the ball settled in a groove. Then, Oswald spun the spinner a second time. What is the probability that the ball landed in a green number both times?

roulette_wheel <- c(rep("Green",2),rep("Red",19),rep("Black",18))
counter <- 0
N <- 1e5 # 100,000 trials
for (i in 1:N) {
  spins <- sample(x = roulette_wheel,size = 2,replace = T)
  if ((spins[1] == "Green") & (spins[2] == "Green")) {
    counter <- counter + 1
  }
}
probability <- counter / N
cat("The probability is:",probability,"\n")
## The probability is: 0.00274