Determine whether the series below is convergent, divergent, or neither.
\[\sum_{n = 1}^{\infty} \frac{(-1)^{n - 1}}{n}\]
total <- 0
series <- function(n) {
((-1)^(n - 1)) / n
}
for (x in 1:1e6) {
total <- total + series(x)
}
total
## [1] 0.6931467
We find that the series is convergent and comes to 0.693.
For the decimal number 6724.189, extract the digit in the thousandths place.
decimal_number <- 6724.189
answer <- floor((decimal_number * 1000)) %% 10
cat("The thousandths place number is:",answer,"\n")
## The thousandths place number is: 9
Convert \(\frac{23 \pi}{30}\) radians to degrees.
# install.packages("pracma")
library(pracma)
value <- rad2deg(rad = 23 * pi / 30)
cat("23 pi / 30 radians =",value,"degrees \n")
## 23 pi / 30 radians = 138 degrees
What is the area between the curve \(f(x) = -3x^2 + 12\) and the \(x\)-axis from \(x = 0\) to \(x = 2\)?
# 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
f <- function(x) {
-3 * x^2 + 12
}
area <- integrate(f,lower = 0,upper = 2)$value
x_values <- seq(0,2.05,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 = 1.25) +
geom_ribbon(data = subset(q4_data,x >= 0 & x <= 2),
aes(ymin = 0,ymax = y),
fill = "blue") +
labs(title = "Graph of f(x) = -3x^2 + 12",
caption = paste("The area under the curve from x = 0 to x = 2 is:",area),
x = "x",
y = "y") +
theme_gray(base_size = 14)