Question 1

A function satisfies \(f(x) = \frac{2}{x}\) for \(1 \leq x \leq e\). What is \(f(e) - f(1)\)?

# 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
f <- makeFun(2 / x ~ x)
anti_f <- antiD(f(x) ~ x)
answer <- anti_f(x = exp(1)) - anti_f(x = 1)
cat("f(e) - f(1) =",answer,"\n")
## f(e) - f(1) = 2

Question 2

Determine whether the series is convergent, divergent, or neither.

\[\sum_{n = 1}^{\infty} \frac{(-1)^n}{n^2}\]

total <- 0
series <- function(n) {
  (-1)^n / n^2
}
for (x in 1:1e6) {
  total <- total + series(x)
}
total
## [1] -0.822467

We determine the series is convergent because we arrive at a value of -0.82.

Question 3

Write 1,607,025 in words.

# install.packages("english")
library(english)
## Warning: package 'english' was built under R version 4.5.2
## 
## Attaching package: 'english'
## The following object is masked from 'package:scales':
## 
##     ordinal
words(1607025)
## [1] "one million six hundred seven thousand twenty-five"

Question 4

A die is thrown three times. What is the probability all three numbers are greater than four?

die <- 1:6 # fair six-sided die
counter <- 0 # number of times the numbers are all greater than 4
N <- 1e6 # 1 million trials
for (i in 1:N) {
  pick <- sample(x = die,size = 3,replace = T)
  if (all(pick > 4)) {
    counter <- counter + 1
  }
}
probability <- counter / N
cat("The probability all three numbers are greater than four is:",probability,"\n")
## The probability all three numbers are greater than four is: 0.037148

Question 5

If \(g(x) = 2^x\), what is \(g'(x)\)?

# install.packages("Deriv")
library(Deriv)
g <- function(x) {
  2^x
}
g_prime <- Deriv(g)
g_prime
## function (x) 
## 0.693147180559945 * 2^x