Question 1

If \(f(x) = \ln(x) + x\) and \(f(1) = 1\), what is \((f^{-1})'(1)\)?

# install.packages("Deriv")
library(Deriv)
f <- function(x) {
  log(x) + x
}
f_prime <- Deriv(f)
inverse <- function(f,lower,upper) {
  Vectorize(function(y) {
    uniroot(function(x) {f(x) - y},lower = lower,upper = upper)$root
  })
}
x_at_1 <- inverse(f = f,lower = 0.1,upper = 5)(1)
answer <- (f_prime(x_at_1))^(-1)
cat("Answer:",answer,"\n")
## Answer: 0.5

Question 2

Convert \(\frac{7 \pi}{4}\) radians to degrees.

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

Question 3

Solve and graph the following definite integral.

\[\int_{-\pi}^{\pi} \sin(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() ──
## ✖ 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
g <- function(x) {
  sin(x)
}
ans <- integrate(f = g,lower = -pi,upper = pi)$value
x_values <- seq(-pi - 0.01,pi + 0.01,length.out = 500)
y_values <- g(x_values)
q3_data <- data.frame(x = x_values,y = y_values)
ggplot(q3_data,aes(x = x,y = y)) +
  geom_line(col = "black",lwd = 1.25) +
  geom_ribbon(data = subset(q3_data,x >= -pi & x <= pi),
              aes(ymin = pmin(y,0),ymax = pmax(y,0)),
              fill = "blue") +
  labs(title = "Graph of g(x) = sin(x)",
       caption = paste("Answer:",round(ans,4)),
       x = "x",
       y = "y") +
  theme_gray()