What is the second derivative of \(f(x) = 12x^2 + 13x + 4\)?
# install.packages("Deriv")
library(Deriv)
f <- function(x) {
12 * x^2 + 13 * x + 4
}
f_prime <- Deriv(f)
f_double_prime <- Deriv(f_prime)
f_double_prime
## function (x)
## 24
Evaluate the following definite integral.
\[\int_{-3}^{9.9} \frac{13}{3^{5 \cos(3x)}} dx\]
g <- function(x) {
13 / ((3)^(5 * cos(3 * x)))
}
answer <- integrate(g,lower = -3,upper = 9.9)$value
cat("The answer is:",answer,"\n")
## The answer is: 7123.25
Calculate the descriptive statistics for \([5,5,5,6,8,9,11,11,15,16,18,22,25,25,26]\).
# install.packages("summarytools")
library(summarytools)
nums <- c(5,5,5,6,8,9,11,11,15,16,18,22,25,25,26)
descr(nums)
## Descriptive Statistics
## nums
## N: 15
##
## nums
## ----------------- --------
## Mean 13.80
## Std.Dev 7.82
## Min 5.00
## Q1 6.00
## Median 11.00
## Q3 22.00
## Max 26.00
## MAD 8.90
## IQR 13.00
## CV 0.57
## Skewness 0.33
## SE.Skewness 0.58
## Kurtosis -1.54
## N.Valid 15.00
## N 15.00
## Pct.Valid 100.00
If \(x \neq 0\) and \(h(x) = \frac{-12x^7 + 6x^5}{3x^2}\), what is \(h''(x)\)?
# install.packages("Deriv")
library(Deriv)
h <- function(x) {
(-12 * x^7 + 6 * x^5) / (3 * x^2) # keep in mind x != 0
}
h_prime <- Deriv(h)
h_double_prime <- Deriv(h_prime)
h_double_prime
## function (x)
## {
## .e1 <- x^2
## 0.666666666666667 * (x * (3 * (6 - 12 * .e1) - 84 * .e1))
## }
Diana, Ed, and Fiona all shopped in the same store. Diana bought 2 apples, 3 bananas, and 1 coconut for a total of \(\$4.50\). Ed bought 1 apple, 4 bananas, and 2 coconuts for a total of \(\$6.70\). Fiona bought 3 apples, 1 banana, and 3 coconuts for a total of \(\$8.80\). What was the cost of 1 apple, 1 banana, along with 1 coconut?
Translating to a system of equations…
\[2a + 3b + c = 4.50 \\ a + 4b + 2c = 6.70 \\ 3a + b + 3c = 8.80\]
q5_data <- data.frame(a = c(2,1,3), # apples
b = c(3,4,1), # bananas
c = c(1,2,3), # coconuts
totals = c(4.50,6.70,8.80)) # totals of each order
q5_model <- lm(totals ~ . - 1,data = q5_data) # "." means all other variables except response variable, -1 to exclude intercept
coef(q5_model) # model coefficients
## a b c
## 0.5 0.4 2.3
We find that one apple costs \(\$0.50\), one banana costs \(\$0.40\) and one coconut costs \(\$2.30\).
The temperature at the surface of the Sun is about \(5600^{\circ}\text{C}\). What is this in \(^{\circ}\text{F}\)?
# install.packages("weathermetrics")
library(weathermetrics)
## Warning: package 'weathermetrics' was built under R version 4.5.3
temp_degF <- celsius.to.fahrenheit(T.celsius = 5600)
cat("The temperature in degrees Fahrenheit is:",temp_degF,"\n")
## The temperature in degrees Fahrenheit is: 10112
Put \([-6,2,5,-9,7,0,-3]\) in order from greatest to least.
numbers <- c(-6,2,5,-9,7,0,-3)
sort(numbers,decreasing = T) # decreasing = T means greatest to least
## [1] 7 5 2 0 -3 -6 -9
# 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() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ✖ tibble::view() masks summarytools::view()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
numbers <- data.frame(Numbers = c(-6,2,5,-9,7,0,-3))
numbers %>%
arrange(desc(Numbers)) # arrange(): ascending order, desc(): descending order
## Numbers
## 1 7
## 2 5
## 3 2
## 4 0
## 5 -3
## 6 -6
## 7 -9