Assignment: Using R, provide the solution for any exercise in either Chapter 4 or Chapter 7 of the calculus textbook. If you are unsure of your solution, post your concerns. ## Solution
Question 17/25, section 7.4, on page 386 of APEX Calculus:
Set up the integral to compute the arc length of the function of the given interval.
\[f(x) = \sqrt{1 - x^2}\]
on interval [-1,1] (Note: f’(x) is not defined at the endpoints.)
The general formula for arc length is as follows: the length from x = [a,b] following function f(x) is
\[length = \int ^b _a \sqrt{1 + f'(x)^2}\] Substituting in for our given f(x):
\[f'(x) = (1/2)(-2x)(1-x^2)^{-1/2} = \frac {-x}{\sqrt{1-x^2}}\]
\[length = \int ^1 _{-1} \sqrt{1 + [\frac{-x} {\sqrt{1-x^2}}]^2}dx = \int ^1 _{-1} \sqrt{1 + \frac{x^2} {1-x^2}}dx = \int ^1 _{-1} \sqrt{\frac {1-x^2 + x^2} {1-x^2}dx}\] Simplify:
\[ \int ^1 _{-1} \sqrt{ \frac {1} {1-x^2 }}dx = \int ^1 _{-1} (1- x^2)^{-1/2}\]
Looking at differentiation rules, this form follows the definition of the arcsine of x:
\[arcsin(x) \vert ^1 _{-1} \] Evaluate:
\[arcsin(1) - arcsin(-1) = \frac{\pi}{2} - \frac{-\pi}{2} = \pi\]
This conforms to the expectation that the arc length of a half-circle is equal to pi.
Use Simpson’s Rule, with n = 4, to approximate the arc length of the function on the given interval.
The general formula for Simpson’s rule, which estimates the value of an integral at n = 4:
\[ \int ^b _a f(x) \approx \frac{\Delta x}{3} * [ f(x0)+ 4f(x_1)+ 2f(x_2)+ 4f(x_3)+ 2f(x_4)] \]
\[\Delta x = \frac{b- a}{n}\]
and the subsections are the two endpoints plus equally spaced units between the values.
To find the arc length, we’ll let f(x) be equal to l(x) from question 17:
\[length = l(x) = \int ^1 _{-1} \sqrt{1 + (\frac{-x}{\sqrt{1-x^2}})^2}dx\]
q_17 <- expression((1-x^2)^0.5) #original function
q_17_deriv <- D(q_17,'x') #differentiate with respect to x
print(q_17_deriv)
## -(0.5 * (2 * x * (1 - x^2)^-0.5))
q_25 <- function(x) {
formula = sqrt(1 + (-x * (1 - x^2)^-0.5)^2)
return(formula)
}
b <- .9999999 #function is undefined at -1, 1
a <- -.9999999
delta_x <- (b - a)/4
sol <- integrate(q_25, -.99999, .99999)
subintervals <- seq(a, b, delta_x)
f_x <- q_25(subintervals)
simpson_val <- (delta_x/3)* (f_x[1] + 4*f_x[2] + 2*f_x[3] + 4*f_x[4] + f_x[5])
print(sol)
## 3.132649 with absolute error < 0.00032
print(simpson_val)
## [1] 747.2289
print(pi)
## [1] 3.141593
In this case, Simpson’s rule fails to approximate the arc length, which should be equal to pi. The built-in R function does provide an approximation of pi however.