Question 1

A force model is \(f(t) = \frac{t^2 \sin(t)}{t^2 + 1}\). What is \(f'(t)\)?

# install.packages("Deriv")
library(Deriv)
f <- function(t) {
  (t^2 * sin(t)) / (t^2 + 1)
}
f_prime <- Deriv(f)
f_prime
## function (t) 
## {
##     .e1 <- t^2
##     .e2 <- 1 + .e1
##     t * ((2 - 2 * (.e1/.e2)) * sin(t) + t * cos(t))/.e2
## }

Question 2

Solve the following system of equations.

\[5x + 6y = -1 \\ -2x - 8y = 5\]

q2_data <- data.frame(x = c(5,-2), # x-coefficients
                      y = c(6,-8), # y-coefficients
                      constants = c(-1,5)) # right-hand side of the equations
q2_model <- lm(constants ~ . - 1,data = q2_data) # . means all othee variables except response variable, -1 to exclude the intercept
coef(q2_model)
##          x          y 
##  0.7857143 -0.8214286

Question 3

Write the number 570 in words.

# install.packages("english")
library(english)
## Warning: package 'english' was built under R version 4.5.2
words(570)
## [1] "five hundred seventy"

Question 4

Convert 4.5 radians into degrees.

# install.packages("pracma")
library(pracma)
value <- rad2deg(rad = 4.5)
cat("4.5 radians =",value,"degrees","\n")
## 4.5 radians = 257.831 degrees

Question 5

What is \(\int x^3 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
## 
## Attaching package: 'scales'
## The following object is masked from 'package:english':
## 
##     ordinal
## 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(x^3 ~ x)
anti_g <- antiD(g(x) ~ x)
anti_g
## function (x, C = 0) 
## x^4/4 + C

Question 6

Two cards are chosen at random without replacement from a pack of 52 playing cards. If the first card chosen is the King of Spades, what is the probability the second card chosen is a picture card?

Note: A picture card is either a Jack, Queen, or King from any suit.

# install.packages(c("tidyverse","mmcards"))
library(tidyverse) # for the pipe %>% operator
## 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::cross()      masks pracma::cross()
## ✖ 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()
## ✖ tidyr::unpack()     masks Matrix::unpack()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(mmcards) # for deck of cards
## Warning: package 'mmcards' was built under R version 4.5.3
deck <- standard_deck()
deck_rem <- deck %>%
  filter(!(rank == "K" & suit == "Spade")) # removing King of Spades
pic_cards <- deck_rem %>%
  filter(rank %in% c("J","Q","K")) # filtering out picture cards from remaining deck
probability <- nrow(pic_cards) / nrow(deck_rem)
cat("The probability that the second card chosen is a picture card is:",probability,"\n")
## The probability that the second card chosen is a picture card is: 0.2307692