Question 1

For \(v(x,y) = x^2 e^y + ye^x\), what is \(v_{xy}\) and \(v_{yx}\)?

A. \(v_{xy}\)

# install.packages("Deriv")
library(Deriv)
v <- function(x,y) {
  x^2 * exp(y) + y * exp(x)
}
v_x <- Deriv(v,"x")
v_xy <- Deriv(v_x,"y")
cat("v_xy =","\n")
## v_xy =
v_xy
## function (x, y) 
## 2 * (x * exp(y)) + exp(x)

B. \(v_{yx}\)

# install.packages("Deriv")
library(Deriv)
v <- function(x,y) {
  x^2 * exp(y) + y * exp(x)
}
v_y <- Deriv(v,"y")
v_yx <- Deriv(v_y,"x")
cat("v_yx =","\n")
## v_yx =
v_yx
## function (x, y) 
## 2 * (x * exp(y)) + exp(x)

Question 2

Which of the following numbers is between 59 and 64?

A. 58

B. 61

C. 65

D. 71

choices <- c(58,61,65,71)
for (x in choices) {
  if (x > 59 & x < 64) {
    cat(x,"is between 59 and 64.")
  } else {
    next
  }
}
## 61 is between 59 and 64.

Question 3

Which of the following is a factor of 390?

A. 14

B. 15

C. 16

D. 17

q3_choices <- 14:17
for (y in q3_choices) {
  if (390 %% y == 0) {
    cat(y,"is a factor of 390.")
  } else {
    next
  }
}
## 15 is a factor of 390.

Question 4

There are 6 people in a room who were all born in the 1990s. What is the chance that any two of them were born in the same year?

set.seed(123) # for reproducibility
N <- 1e5
counter <- 0
for (i in 1:N) {
  years <- sample(x = 1990:1999,size = 6,replace = T)
  if (any(duplicated(years))) {
     counter <- counter + 1
  }
}
probability <- counter / N
cat("The probability is:",probability,"\n")
## The probability is: 0.84814