\(~\)

Calculus Exercise 7.1.13 and 7.1.14

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.

\(~\)

Find the total area enclosed by the functions f and g

\(f(x) = 2x^2 + 5x −3, g(x) = x^2 + 4x − 1\)

# create functions
f13 <- function(x) {2 * (x^2) + (5 * x) - 3}
g13 <- function(x) {(x^2) + (4 * x) - 1}
 
integrate(f13, lower = -3, upper = 2)
## -4.166667 with absolute error < 2.7e-13
integrate(g13, lower = -1, upper = 1)
## -1.333333 with absolute error < 4.7e-14

Based on this, the total area enclosed by the function f is -4.167 with absolute error < 2.7e-13 and for function g is -1.33 with absolute error < 4.7e-14.

# plot
curve(f13, from = -3, to = 3, col = 2)
curve(g13, from = -3, to = 3, add = TRUE, col = 4)

\(~\)

# Based on the graph, the two intersecting points are -2 and 1, we are setting the lower and upper to those points.
f13_area <- integrate(f13, lower = -2, upper = 1)
f13_area
## -10.5 with absolute error < 1.4e-13
g13_area <- integrate(g13, lower = -2, upper = 1)
g13_area
## -6 with absolute error < 9.9e-14
# area between the curve is g - f
print(paste0('The area between the curve is ',(g13_area$value - f13_area$value)))
## [1] "The area between the curve is 4.5"

\(~\)

\(f(x) = x^2 − 3x + 2, g(x) = −3x + 3\)

# create functions
f14 <- function(x) {(x ^2) - (3 * x) + 2}
g14 <- function(x) {(-3 * x) + 3}
 
integrate(f14, lower = 2, upper = 1)
## 0.1666667 with absolute error < 1.9e-15
integrate(g14, lower = 3, upper = -3)
## -18 with absolute error < 3.3e-13

Based on this, the total area enclosed by the function f is 0.167 with absolute error < 1.9e-15 and for function g is -18 with absolute error < 3.3e-13.

# plot
curve(f14, from = -3, to = 3, col = 2)
curve(g14, from = -3, to = 3, add = TRUE, col = 4)

\(~\)

# Based on the graph, the two intersecting points are -1 and 1, we are setting the lower and upper to those points.
f14_area <- integrate(f14, lower = -1, upper = 1)
f14_area
## 4.666667 with absolute error < 5.2e-14
g14_area <- integrate(g14, lower = -1, upper = 1)
g14_area
## 6 with absolute error < 6.7e-14
# area between the curve is g - f
print(paste0('The area between the curve is ',(g14_area$value - f14_area$value)))
## [1] "The area between the curve is 1.33333333333333"

\(~\)

References: