Question 1

How many even numbers are in the set \([2,10,4,16,14,8,12,18,6,9,21,3,15]\)?

# install.packages("comprehenr")
library(comprehenr)
## Warning: package 'comprehenr' was built under R version 4.5.2
even_nums <- to_vec(for (x in c(2,10,4,16,14,8,12,18,6,9,21,3,15)) if (x %% 2 == 0) x)
cat("There are",length(even_nums),"even numbers in the set.","\n")
## There are 9 even numbers in the set.

Question 2

Graph the corresponding polygon to the points in the data frame below.

# 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_data <- data.frame(X = c(3,3,9,9),
                      Y = c(4,7,10,4))
ggplot(q2_data,aes(x = X,y = Y)) +
  geom_polygon(fill = "green",color = "black",lwd = 1.25) +
  geom_point(size = 4) +
  coord_equal() +
  theme_gray()

Question 3

Find the cube root of -0.49 correct to 2 decimal places.

# install.packages("pracma")
library(pracma)
## 
## Attaching package: 'pracma'
## The following object is masked from 'package:purrr':
## 
##     cross
value <- nthroot(x = -0.49,n = 3) # x = -0.49 (our value),n = 3 (cube root)
cat("The answer is:",round(value,2),"\n")
## The answer is: -0.79

Question 4

What is \(\int x^2 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
## 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
f <- makeFun(x^2 * exp(x) ~ x)
anti_f <- antiD(f(x) ~ x)
anti_f
## function (x, C = 0) 
## x^2 * exp(x) - 2 * x * exp(x) + 2 * exp(x) + C