Question 1

Write the number 786 in words.

# install.packages("english")
library(english)
## Warning: package 'english' was built under R version 4.5.2
words(786)
## [1] "seven hundred eighty-six"

Question 2

\(7x^{\circ}\) and \(y^{\circ}\) are complementary. \(3x^{\circ}\) and \(3y^{\circ}\) are supplementary. What are the values of \(x\) and \(y\)?

Note: Complementary angles have a total angle measure of \(90^{\circ}\). Supplementary angles have a total angle measure of \(180^{\circ}\).

Given the note above, we get the following system of equations to solve.

\[7x + y = 90 \\ 3x + 3y = 180\]

q2_data <- data.frame(x = c(7,3), # x-coefficients
                      y = c(1,3), # y-coefficients
                      angle = c(90,180)) # total angle measures: right-hand side of equations
q2_model <- lm(angle ~ . - 1,data = q2_data) # . includes everything except response variable, -1 excludes the intercept
coef(q2_model) # extracting model coefficients
##  x  y 
##  5 55

Question 3

Convert \(4.5 \pi\) radians to degrees.

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

Question 4

A jar contains 40 blue bubblegums, 27 pink bubblegums, and 33 yellow bubblegums. Abe randomly chooses two bubblegums from the jar without replacement. What is the probability they are both yellow?

jar <- c(rep("Blue",40),rep("Pink",27),rep("Yellow",33))
counter <- 0
N <- 1e5 # 100,000 trials
for (i in 1:N) {
  pick <- sample(x = jar,size = 2,replace = F)
  if (all(pick == "Yellow")) {
    counter <- counter + 1
  }
}
probability <- counter / N
cat("The probability they are both yellow is:",probability,"\n")
## The probability they are both yellow is: 0.10763

Question 5

Solve the system of equations below.

\[3x + y = -2 \\ 3x^2 + y = 4\]

# install.packages("rootSolve")
library(rootSolve)
## 
## Attaching package: 'rootSolve'
## The following objects are masked from 'package:pracma':
## 
##     gradient, hessian
our_system <- function(variables) {
  x <- variables[1]
  y <- variables[2]
  c(3 * x + y + 2, # 3x + y = -2 (doing simple algebra)
    3 * x^2 + y - 4) # 3x^2 + y = 4 (doing simple algebra)
}
answer1 <- multiroot(f = our_system,start = c(0,0))
answer2 <- multiroot(f = our_system,start = c(3,-10))
cat("Answer 1:",answer1$root,"\n")
## Answer 1: -1 1
cat("Answer 2:",answer2$root,"\n")
## Answer 2: 2 -8

Question 6

What is \(\int \cos^3(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
## 
## 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((cos(x))^3 ~ x)
anti_g <- antiD(g(x) ~ x)
anti_g
## function (x, C = 0) 
## (9 * sin(x) - sin(-3 * x))/12 + C