Question 1

Write the number 375 in words.

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

Question 2

Given the data frame below, construct the corresponding polygon.

  1. Define the data frame.
q2_data <- data.frame(x = c(-5,-2,7,10,10),
                      y = c(-2,5,8,5,-2))
q2_data
##    x  y
## 1 -5 -2
## 2 -2  5
## 3  7  8
## 4 10  5
## 5 10 -2
  1. Construct the polygon.
# 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() ──
## ✖ 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
q2_closed_data <- rbind(q2_data,q2_data[1, ]) # closing the polygon
ggplot(q2_closed_data,aes(x = x,y = y)) +
  geom_polygon(fill = "yellow",alpha = 0.5,color = "black",lwd = 1) +
  geom_point(size = 3) +
  theme_gray(base_size = 14)

Question 3

What integer value of \(y\) satisfies the sytem of equations below?

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

# install.packages("rootSolve")
library(rootSolve)
system_of_equations <- function(variables) {
  x <- variables[1]
  y <- variables[2]
  c(5 * x - 4 * y - 22,-3 * x^2 - y + 4)
}
result <- multiroot(system_of_equations,start = c(0,0))
cat("x =",result$root[1],"\n")
## x = 1.583333
cat("y =",result$root[2],"\n")
## y = -3.520833

Question 4

What is \(\int \cos(x) e^x dx\)?

# install.packages(c("ggformula","mosaicCalc"))
library(ggformula)
## Warning: package 'ggformula' was built under R version 4.5.2
## Loading required package: scales
## 
## Attaching package: 'scales'
## The following object is masked from 'package:purrr':
## 
##     discard
## The following object is masked from 'package:readr':
## 
##     col_factor
## 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) * exp(x) ~ x)
anti_g <- antiD(g(x) ~ x)
anti_g
## function (x, C = 0) 
## {
##     F <- makeF(cos(x) * exp(x))
##     evalFun(F, x = x, .const = C)
## }
## <environment: 0x0000017f8444e8c0>