Question 1

Evaluate and graph the following definite integral.

\[\int_{4}^{8} \frac{1}{2}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 ──
## ✔ 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) {
  0.5 * x
}
answer <- integrate(f = f,lower = 4,upper = 8)$value
x_values <- seq(3.99,8.01,length.out = 500)
y_values <- f(x_values)
q1_data <- data.frame(x = x_values,y = y_values)
ggplot(q1_data,aes(x = x,y = y)) +
  geom_line(col = "black",lwd = 2) +
  geom_ribbon(data = subset(q1_data,x >= 4 & x <= 8),
              aes(ymin = 0,ymax = y),
              fill = "lightblue") +
  labs(title = "Graph of f(x) = 0.5x",
       caption = paste("Answer:",answer),
       x = "x",
       y = "y") +
  theme_gray()

Question 2

What is the area between the curve \(g(x) = \sin(x)\) and the \(x\)-axis from \(x = 0\) to \(x = \pi\)?

# install.packages("tidyverse")
library(tidyverse)
g <- function(x) {
  sin(x)
}
area <- integrate(f = g,lower = 0,upper = pi)$value
x_vals <- seq(0,pi + 0.01,length.out = 500) # pi + 0.01 to give a buffer
y_vals <- g(x_vals)
q2_data <- data.frame(x = x_vals,y = y_vals)
ggplot(q2_data,aes(x = x,y = y)) +
  geom_line(col = "black",lwd = 2) +
  geom_ribbon(data = subset(q2_data,x >= 0 & x <= pi),
              aes(ymin = 0,ymax = y),
              fill = "lightgreen") +
  labs(title = "Graph of g(x) = sin(x)",
       caption = paste("Area:",area),
       x = "x",
       y = "y") +
  theme_gray()

Question 3

Calculate \(\log_{23}(7)\) to 2 decimal places.

value <- log(x = 7,base = 23)
cat("Value:",round(value,2),"\n")
## Value: 0.62