Question 1

Find the value and graph the following definite integral.

\[\int_{0}^{2 \pi} \cos(x) 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 ──
## ✔ 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
f <- function(x) {
  cos(x)
}
answer <- integrate(f = f,lower = 0,upper = 2 * pi)$value
x_vals <- seq(0,9 * pi / 4,length.out = 500)
y_vals <- f(x_vals)
q1_data <- data.frame(x = x_vals,y = y_vals)
ggplot(q1_data,aes(x = x,y = y)) +
  geom_line(col = "black",lwd = 1.25) +
  geom_ribbon(data = subset(q1_data,x >= 0 & x <= 2 * pi),
              aes(ymin = pmin(y,0),ymax = pmax(y,0)),
              fill = "blue") +
  labs(title = "Graph of f(x) = cos(x)",
       caption = paste("Answer:",round(answer,4)),
       x = "x",
       y = "y") +
  theme_gray()

Question 2

Find the value and graph the following definite integral.

\[\int_{2}^{4} x^3 dx\]

# install.packages("tidyverse")
library(tidyverse)
g <- function(x) {
  x^3
}
result <- integrate(f = g,lower = 2,upper = 4)$value
x_values <- seq(2,4.01,length.out = 500)
y_values <- g(x_values)
q2_data <- data.frame(x = x_values,y = y_values)
ggplot(q2_data,aes(x = x,y = y)) +
  geom_line(col = "black",lwd = 1.25) +
  geom_ribbon(data = subset(q2_data,x >= 2 & x <= 4),
              aes(ymin = 0,ymax = y),
              fill = "red") +
  labs(title = "Graph of g(x) = x^3",
       caption = paste("Result:",round(result,4)),
       x = "x",
       y = "y") +
  theme_gray()

Question 3

Write 511 in words.

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

Question 4

Convert \(420^{\circ}\) to radians.

# install.packages("pracma")
library(pracma)
## 
## Attaching package: 'pracma'
## The following object is masked from 'package:purrr':
## 
##     cross
value <- deg2rad(deg = 420)
cat("420 degrees =",value,"radians","\n")
## 420 degrees = 7.330383 radians