## We will look at the error function exp(-x^2)
f <- function(x) exp(-x^2)
quadinf(f, -Inf, 0) #=> 0.886226925756445 with abs. error 3e-10 (sqrt(pi)/2)
quadinf(f, 0, Inf) # same
quadinf(f, -Inf, -1, tol = 1e-12) - integrate(f, -Inf, -1)$value
quadinf(f, -Inf, 1, tol = 1e-12) - integrate(f, -Inf, 1)$value
quadinf(f, -1, Inf, tol = 1e-12) - integrate(f, -1, Inf)$value
quadinf(f, 1, Inf, tol = 1e-12) - integrate(f, -Inf, -1)$value
Run the code above in your browser using DataLab