Compute \(\int (8x + 6) \sqrt{4x^2 - 6x + 9} dx\) for a physical potential function.
# 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((8 * x + 6) * sqrt(4 * x^2 - 6 * x + 9) ~ x)
anti_f <- antiD(f(x) ~ x)
anti_f
## function (x, C = 0)
## {
## F <- makeF((8 * x + 6) * sqrt(4 * x^2 - 6 * x + 9))
## evalFun(F, x = x, .const = C)
## }
## <environment: 0x0000017da2674b28>
Write 5,390,052 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(5390052)
## [1] "five million three hundred ninety thousand fifty-two"
Two fair dice are thrown. What is the probability that the score on the first die is 4 or the score on the second die is odd?
die <- 1:6
counter <- 0
N <- 1e5
for (i in 1:N) {
roll <- sample(x = die,size = 2,replace = T)
if (roll[1] == 4 || roll[2] %% 2 == 1) {
counter <- counter + 1
}
}
probability <- counter / N
cat("The probability is:",probability,"\n")
## The probability is: 0.58361