Question 1

A car’s acceleration is \(a(t) = 2t\) and \(v(0) = 3\). What is the car’s change in velocity on \([0,4]\)?

# 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
## 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
a <- makeFun(2 * t ~ t)
v <- antiD(a(t) ~ t)
change <- v(t = 4,C = 3) - v(t = 0,C = 3)
cat("The car's change in velocity on [0,4] is:",change,"\n")
## The car's change in velocity on [0,4] is: 16

Question 2

Convert \(\frac{11}{8} \pi\) radians to degrees.

# install.packages("pracma")
library(pracma)
## 
## Attaching package: 'pracma'
## The following objects are masked from 'package:Matrix':
## 
##     expm, lu, tril, triu
value <- rad2deg(rad = 11 * pi / 8)
cat("11 pi / 8 radians =",value,"degrees","\n")
## 11 pi / 8 radians = 247.5 degrees

Question 3

There is a special die in the shape of an octagonal prism. It has eight rectangular faces, each with a number, and two octagonal faces at the ends. Abe rolls the die on a flat surface until it settles with a number on the top face. Abe wins if the number on top is a factor of 6. What is the probability of winning?

die <- 1:8
counter <- 0
N <- 1e5
for (i in 1:N) {
  roll <- sample(x = die,size = 1,replace = T)
  if (6 %% roll == 0) {
    counter <- counter + 1
  }
}
probability <- counter / N
cat("The probability of winning is:",probability,"\n")
## The probability of winning is: 0.49987

Question 4

Solve and graph the definite integral.

\[\int_{\frac{\pi}{2}}^{\pi} x \cos(x) \space dx\]

# install.packages("tidyverse")
library(tidyverse)
## 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
f <- function(x) {
  x * cos(x)
}
answer <- integrate(f = f,lower = pi / 2,upper = pi)$value
x_values <- seq(pi / 2 - 0.01,pi + 0.01,length.out = 500)
y_values <- f(x_values)
q4_data <- data.frame(x = x_values,y = y_values)
ggplot(q4_data,aes(x = x)) +
  geom_ribbon(data = subset(q4_data,x >= pi / 2 & x <= pi),
              aes(ymin = pmin(y,0),ymax = pmax(y,0)),
              fill = "blue") +
  geom_line(aes(y = y),col = "black",lwd = 1.25) +
  labs(title = "Graph of f(x) = x cos(x)",
       caption = paste("Answer:",round(answer,4)),
       x = "x",
       y = "y") +
  theme_gray()