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.
\(f(x) = x^2 - 3x + 2, \space g(x) = -3x + 3\)
Ans:
https://www.mathsisfun.com/data/function-grapher.php#
Solving the equations for f(x) and g(x), we get x2 - 1 = 0, x = -1 or 1, which is confirmed from the graphical approach above.
f <- function (x) {x^2 - 3*x + 2}
g <- function (x) {-3*x + 3}
curve(f, xlim = c(-1,3), ylim = c(-1,7), ylab = 'f(x), g(x)', col='red', sub = paste0("f(x)= x^2-3x+2", " g(x)= -3x+3"))
curve(g, col='blue', add = TRUE)
The function to integrate should be g(x) - f(x) to get the total area enclosed, i.e., we’ve to solve for
\(\int_{-1}^{1} -x^2+1dx\)
integrand <- function(x){-x^2 + 1}
area <- stats::integrate(integrand, -1, 1)
area
## 1.333333 with absolute error < 1.5e-14
The answer is 4/3.