\(f(x) = 2x^2 + 5x - 31\), $ g(x) = x^2 + 4x - 1$
Solution
f <- function(x) {2*x^2+5*x-3}
g <- function(x) {x^2+4*x-1}
curve(f, -3, 3)
curve(g, -3, 3, add=TRUE)
(rootF <- uniroot(function(x) f(x) - g(x) , c(-5000,-0.01), tol=1e-8))
## $root
## [1] -2
##
## $f.root
## [1] 1.776357e-15
##
## $iter
## [1] 29
##
## $init.it
## [1] NA
##
## $estim.prec
## [1] 8.680272e-09
rootF$root
## [1] -2
(root0 <- uniroot(function(x) f(x) - g(x) , c(0.0001, 5000), tol=1e-8))
## $root
## [1] 1
##
## $f.root
## [1] 2.112702e-09
##
## $iter
## [1] 29
##
## $init.it
## [1] NA
##
## $estim.prec
## [1] 5.000001e-09
root0$root
## [1] 1
(areaG <- integrate(g, lower = -2, upper = 1))
## -6 with absolute error < 9.9e-14
(areaF <- integrate(f, lower = -2, upper = 1))
## -10.5 with absolute error < 1.4e-13
areaG$value - areaF$value
## [1] 4.5