In Exercises 13 – 20, find the total area enclosed by the functions f and g.
Solution:
Let’s use R to create two function, f(x) and g(x).
function_f <- function(x)
{
2 * (x ^ 2) + 5 * x - 3
}
function_g <- function(x)
{
(x ^ 2) + 4 * x - 1
}
We need to find the intersection of the two functions. To do this we set f(x) = g(x).
\(2x^2 + 5x - 3 = x^2 + 4x - 1\) = Subtract to set equal to 0.
\(x^2 + x - 2 = 0\) Solve using the quadratic formula where a = 1, b = 1, and c = -2
I’ll skip over the steps for the quadratic formula, but we end up with x = -2 and x = 1. So we have two intersection points, -2 and 1.
Now that we know the intersection points, we integrate f(x) - g(x), where our interval is made up of the two intersection points we found. We know that f(x) - g(x) is \(x^2 + x - 2\).
function_fg <- function(x)
{
(x ^ 2) + x - 2
}
integrate(function_fg, lower = -2, upper = 1)
## -4.5 with absolute error < 5e-14
The total area enclosed by the functions f and g is -4.5. We can’t have a negative area, so we take the absolute value of the total area. So we get 4.5 as the total area enclosed by the functions f and g.