A function is \(f(x) = \ln(\ln(x + 2))\). What is \(f'(x)\)?
# install.packages("Deriv")
library(Deriv)
f <- function(x) {
log(log(x + 2))
}
f_prime <- Deriv(f)
f_prime
## function (x)
## {
## .e1 <- 2 + x
## 1/(.e1 * log(.e1))
## }
Convert \(520^{\circ}\) into radians.
# install.packages("pracma")
library(pracma)
value <- deg2rad(deg = 520)
cat("520 degrees =",value,"radians","\n")
## 520 degrees = 9.075712 radians
Use a graphical method to find approzimate solutions to the system of equations below.
\[y = 3x + 2 \\ y = -x^2 + 2x + 3\]
A. Graph both equations.
# 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
f1 <- function(x) {
3 * x + 2
}
f2 <- function(x) {
-x^2 + 2 * x + 3
}
x_values <- seq(-1.75,0.85,length.out = 500)
f1_values <- f1(x_values)
f2_values <- f2(x_values)
q3_data <- data.frame(x = x_values,f1 = f1_values,f2 = f2_values)
root1 <- uniroot(function(x) f2(x) - f1(x),interval = c(-2,0))$root
root2 <- uniroot(function(x) f2(x) - f1(x),interval = c(0,2))$root
ggplot(q3_data,aes(x = x)) +
geom_line(aes(y = f1),col = "blue",lwd = 1.25) +
geom_line(aes(y = f2),col = "red",lwd = 1.25) +
labs(title = "Graph of System of Equations",
caption = paste("Intersections:",round(root1,4),"and",round(root2,4)),
x = "x",
y = "y") +
theme_gray(base_size = 14)
What is the value of the definite integral below?
\[\int_{-4}^{-2} e^{-x} dx\]
# install.packages("tidyverse")
library(tidyverse)
g <- function(x) {
exp(-x)
}
answer <- integrate(f = g,lower = -4,upper = -2)$value
x_vals <- seq(-5,-1,length.out = 500)
y_vals <- g(x_vals)
q4_data <- data.frame(x = x_vals,y = y_vals)
ggplot(q4_data,aes(x = x,y = y)) +
geom_line(col = "black",lwd = 1.25) +
geom_ribbon(data = subset(q4_data,x >= -4 & x <= -2),
aes(ymin = 0,ymax = y),
fill = "brown") +
labs(title = "Graph of g(x) = exp(-x)",
caption = paste("Answer:",round(answer,4)),
x = "x",
y = "y") +
theme_gray(base_size = 14)