Using R, provide the solution for any exercise in either Chapter 4 or Chapter 7 of the calculus textbook.
Find the arc length of the function on the given interval:
Solution
Define the function in R and plot the curve for a visual reference.
# Define the function using R syntax.
f <- function(x) {
1/3 * x ^ (3/2) - x ^ (1/2)
}
x <- seq(0, 1, 0.01)
curve(f(x), col = 'blue', ylab='f(x)')
Now find the arc length of the function on the given interval using the pracma library's arclength() function.
# The arclength() function expects the first paremeter to be parameterized, so we
# need to create a parameterize version of our function before passing it to arclength().
par_function <- function(x) c(x, f(x))
arclength(par_function, 0, 1)
## $length
## [1] 1.333331
##
## $niter
## [1] 11
##
## $rel.err
## [1] 3.825585e-06
The arc length of the function on the given interval is 1.3.