\(~\)
\(~\)
# create functions
<- function(x) {2 * (x^2) + (5 * x) - 3}
f13 <- function(x) {(x^2) + (4 * x) - 1}
g13
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
# 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.
<- integrate(f13, lower = -2, upper = 1)
f13_area f13_area
## -10.5 with absolute error < 1.4e-13
<- integrate(g13, lower = -2, upper = 1)
g13_area 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"
\(~\)
# create functions
<- function(x) {(x ^2) - (3 * x) + 2}
f14 <- function(x) {(-3 * x) + 3}
g14
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
# 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.
<- integrate(f14, lower = -1, upper = 1)
f14_area f14_area
## 4.666667 with absolute error < 5.2e-14
<- integrate(g14, lower = -1, upper = 1)
g14_area 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"
\(~\)