Question 1

Differentiate \(y = 3 \csc(x) + 5 \sin(x)\).

# install.packages("Deriv")
library(Deriv)
y <- function(x) {
  3 * (1 / sin(x)) + 5 * sin(x) # csc(x) = 1 / sin(x)
}
y_prime <- Deriv(y)
y_prime
## function (x) 
## (5 - 3/sin(x)^2) * cos(x)

Question 2

Find the slope of the tangent line for the function \(f(x) = 6x^3 - 5x^2 + 3x\) at \(x = 1\).

# install.packages("Deriv")
library(Deriv)
f <- function(x) {
  6 * x^3 - 5 * x^2 + 3 * x
}
f_prime <- Deriv(f)
cat("The slope at x = 1 is:",f_prime(x = 1),"\n")
## The slope at x = 1 is: 11

Question 3

Choose the symmetric matrix from the four choices given.

  1. Define the four matrices.
A <- matrix(data = c(-12,-16,-3,16,17,-16,14,-7,-7,-4,-3,-7,-11,7,-11,16,-7,7,19,7,17,-4,-11,7,-17),nrow = 5,ncol = 5,byrow = T)
B <- matrix(data = c(13,6,-9,-6,18,-15,-5,15,-19,4,14,-6,9,-19,9,-15,-5,15,-19,4,13,6,-9,-6,18),nrow = 5,ncol = 5,byrow = T)
C <- matrix(data = c(5,-5,13,-5,5,8,-6,20,-6,8,15,-6,5,-6,15,7,19,-6,19,7,-4,-16,-10,-16,-4),nrow = 5,ncol = 5,byrow = T)
D <- matrix(data = c(-3,-18,-19,32,-8,-9,5,3,12,4,-10,-5,12,-20,-10,25,20,-11,-6,-7,1,11,-1,2,-27),nrow = 5,ncol = 5,byrow = T)
cat("Matrix A: \n")
## Matrix A:
print(A)
##      [,1] [,2] [,3] [,4] [,5]
## [1,]  -12  -16   -3   16   17
## [2,]  -16   14   -7   -7   -4
## [3,]   -3   -7  -11    7  -11
## [4,]   16   -7    7   19    7
## [5,]   17   -4  -11    7  -17
cat("Matrix B: \n")
## Matrix B:
print(B)
##      [,1] [,2] [,3] [,4] [,5]
## [1,]   13    6   -9   -6   18
## [2,]  -15   -5   15  -19    4
## [3,]   14   -6    9  -19    9
## [4,]  -15   -5   15  -19    4
## [5,]   13    6   -9   -6   18
cat("Matrix C: \n")
## Matrix C:
print(C)
##      [,1] [,2] [,3] [,4] [,5]
## [1,]    5   -5   13   -5    5
## [2,]    8   -6   20   -6    8
## [3,]   15   -6    5   -6   15
## [4,]    7   19   -6   19    7
## [5,]   -4  -16  -10  -16   -4
cat("Matrix D: \n")
## Matrix D:
print(D)
##      [,1] [,2] [,3] [,4] [,5]
## [1,]   -3  -18  -19   32   -8
## [2,]   -9    5    3   12    4
## [3,]  -10   -5   12  -20  -10
## [4,]   25   20  -11   -6   -7
## [5,]    1   11   -1    2  -27
  1. Determine which one of the four matrices is the symmetric matrix.
# install.packages("matrixcalc")
library(matrixcalc)
## Warning: package 'matrixcalc' was built under R version 4.5.2
if (is.symmetric.matrix(A) == TRUE) {
  cat("Matrix A is the symmetric matrix.")
} else if (is.symmetric.matrix(B) == TRUE) {
  cat("Matrix B is the symmetric matrix.")
} else if (is.symmetric.matrix(C) == TRUE) {
  cat("Matrix C is the symmetric matrix.")
} else if (is.symmetric.matrix(D) == TRUE) {
  cat("Matrix D is the symmetric matrix.")
} else {
  cat("None of the matrices are symmetric.")
}
## Matrix A is the symmetric matrix.

Question 4

What is \(\frac{d}{dx} (\frac{3x^3 - x^2}{x})\)?

# install.packages("Deriv")
library(Deriv)
g <- function(x) {
  (3 * x^3 - x^2) / (x)
}
g_prime <- Deriv(g)
g_prime
## function (x) 
## 6 * x - 1

Question 5

Calculate the geometric mean of 4, 5, and 6.25.

# install.packages("pracma")
library(pracma)
nums <- c(4,5,6.25)
geo_mean <- geomean(nums)
cat("The geometric mean of 4, 5, and 6.25 is:",geo_mean,"\n")
## The geometric mean of 4, 5, and 6.25 is: 5

Question 6

Sammy caught ten rainbow trout from a river, measured their lengths to the nearest inch, and recorded his results in groups as follows. Use the midpoints of the groups to estimate the standard deviation of the lengths of all rainbow trout from the river.

  1. Define the data frame.
q6_data <- data.frame(Length = c("15-19","20-24","25-29"),
                      Number = c(3,5,2))
q6_data
##   Length Number
## 1  15-19      3
## 2  20-24      5
## 3  25-29      2
  1. Find the standard deviation of the lengths using the midpoints.
# 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() ──
## ✖ purrr::cross()  masks pracma::cross()
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
answer <- q6_data %>%
  separate(Length,into = c("Lower","Upper"),sep = "-",convert = T) %>%
  mutate(Midpoint = (Lower + Upper) / 2) %>%
  uncount(Number) %>%
  summarise(SD = sd(Midpoint)) %>%
  pull(SD)
cat("The standard deviation of the lengths of all rainbow trout using the midpoints is:",answer,"\n")
## The standard deviation of the lengths of all rainbow trout using the midpoints is: 3.689324