Question 1

When \(2x^3 - 5x^2 + x + 3\) is divided by \(x - 2\), what is the remainder?

# install.packages("pracma")
library(pracma)
p1 <- c(2,-5,1,3) # coefficients of first expression (decreasing order by power)
p2 <- c(1,-2) # coefficients of second expression (decreasing order by power)
result <- polydiv(p = p1,q = p2)
cat("Quotient:","\n")
## Quotient:
print(result$d) # quotient
## [1]  2 -1 -1
cat("Remainder:","\n")
## Remainder:
print(result$r) # remainder
## [1] 1

We get a remainder of 1 and a resulting expression of \(2x^2 - x - 1\).

Question 2

Leanne went to the stationery shop. Use the data below to determine how much she paid for two erasers.

# 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() ──
## ✖ purrr::cross()  masks pracma::cross()
## ✖ 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(Item = c("Pen","Pencil","Notebook","Ruler","Glue","Eraser","Sharpener","Scissors"),
                      Price = c(0.85,0.15,0.96,0.58,0.75,0.40,0.69,0.98))
answer <- q2_data %>%
  filter(Item == "Eraser") %>%
  summarise(Amount = 2 * Price) %>%
  pull(Amount)
cat("Leanne paid $",answer,"for two erasers.","\n")
## Leanne paid $ 0.8 for two erasers.

Question 3

Convert \(\frac{5}{6} \pi\) radians into degrees.

# install.packages("pracma")
library(pracma)
value <- rad2deg(rad = 5 * pi / 6)
cat("5 pi / 6 radians =",value,"degrees","\n")
## 5 pi / 6 radians = 150 degrees

Question 4

Solve and graph the following definite integral.

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

# install.packages("tidyverse")
library(tidyverse)
f <- function(x) {
  cos(x)
}
area <- integrate(f = f,lower = 0,upper = pi / 2)$value
x_values <- seq(0,pi / 2 + 0.0001,length.out = 500)
y_values <- f(x_values)
q4_data <- data.frame(x = x_values,y = y_values)
ggplot(q4_data,aes(x = x,y = y)) +
  geom_line(col = "black",lwd = 2) +
  geom_ribbon(data = subset(q4_data,x >= 0 & x <= pi / 2),
              aes(ymin = 0,ymax = y),
              fill = "blue") +
  labs(title = "Graph of f(x) = cos(x)",
       caption = paste("Area:",area),
       x = "x",
       y = "y") +
  theme_gray()