What is \(\int \frac{1}{x} - \frac{1}{\cos^2(x)} dx\)?
# install.packages(c("ggformula","mosaicCalc"))
library(ggformula)
## Warning: package 'ggformula' was built under R version 4.5.2
## Loading required package: ggplot2
## Loading required package: scales
## Loading required package: ggiraph
## Warning: package 'ggiraph' was built under R version 4.5.2
## Loading required package: ggridges
## Warning: package 'ggridges' was built under R version 4.5.2
##
## New to ggformula? Try the tutorials:
## learnr::run_tutorial("introduction", package = "ggformula")
## learnr::run_tutorial("refining", package = "ggformula")
library(mosaicCalc)
## Warning: package 'mosaicCalc' was built under R version 4.5.2
## Registered S3 method overwritten by 'mosaic':
## method from
## fortify.SpatialPolygonsDataFrame ggplot2
##
## Attaching package: 'mosaicCalc'
## The following object is masked from 'package:stats':
##
## D
g <- makeFun(1 / x - 1 / (cos(x))^2 ~ x)
anti_g <- antiD(g(x) ~ x)
anti_g
## function (x, C = 0)
## {
## F <- makeF(1/x - 1/(cos(x))^2)
## evalFun(F, x = x, .const = C)
## }
## <environment: 0x000001d2e459cd60>
Find the roots and graph \(f(x) = 10x^2 + 111x + 270\).
# install.packages(c("rootSolve","tidyverse"))
library(rootSolve)
library(tidyverse)
## Warning: package 'lubridate' was built under R version 4.5.2
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats 1.0.1 ✔ stringr 1.5.2
## ✔ lubridate 1.9.4 ✔ tibble 3.3.0
## ✔ purrr 1.1.0 ✔ tidyr 1.3.1
## ✔ readr 2.1.5
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ readr::col_factor() masks scales::col_factor()
## ✖ purrr::discard() masks scales::discard()
## ✖ tidyr::expand() masks Matrix::expand()
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ✖ tidyr::pack() masks Matrix::pack()
## ✖ tidyr::unpack() masks Matrix::unpack()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
f <- function(x) {
10 * x^2 + 111 * x + 270
}
roots <- uniroot.all(f,c(-10,10))
for (x in seq_along(roots)) {
cat("Root",x,":",roots[x],"\n")
}
## Root 1 : -3.6
## Root 2 : -7.500003
x_values <- seq(-8,-3,length.out = 500)
y_values <- f(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) +
annotate("point",x = roots[1],y = f(roots[1]),col = "blue",size = 5) +
annotate("point",x = roots[2],y = f(roots[2]),col = "blue",size = 5) +
labs(title = "Graph of f(x) = 10x^2 + 111x + 270",
caption = paste("Roots:",roots[1],"and",round(roots[2],2)),
x = "x",
y = "y") +
theme_gray()
Which one of the following is even?
A. \(70 \times 74 \times 77\)
B. \(71 \times 73 \times 75\)
C. \(71 \times 75 \times 77\)
D. \(79 \times 75 \times 71\)
# install.packages("tidyverse")
library(tidyverse)
q3_data <- data.frame(Choice = LETTERS[1:4],
Number = c(70*74*77,71*73*75,71*75*77,79*75*71))
correct_answer <- q3_data %>%
mutate(Even = Number %% 2 == 0) %>%
filter(Even == TRUE) %>%
pull(Choice)
cat("The correct answer is:",correct_answer,"\n")
## The correct answer is: A