If I understand correctly, what you want is to subtract the area under the x-axis and above the curve [green in the plot] from the area above the x-axis and the curve [red in the plot]. Is that right?
If so, then though I don't know the correct answer, but I can provide you a counter example where step and spline gives wrong results. Please keep in mind that this doesn't prove that trapezoid is correct always.
# dummy points
u <- c(1, 3, 5, 4)
v <- c(2, 0, -2, 0)
# plot
plot(x = u,
y = v)
polygon(x = c(1, 1, 3),
y = c(0, 2, 0),
col = "green",
border = "green")
polygon(x = c(3, 5, 4),
y = c(0, -2, 0),
col = "red",
border = "red")
abline(h = 0)

# expected answer
(0.5 * 2 * 2) - (0.5 * 1 * 2)
#> [1] 1
# DescTools results
sapply(X = c("trapezoid", "step", "spline"),
FUN = DescTools::AUC,
x = u,
y = v)
#> trapezoid step spline
#> 1.0000000 4.0000000 0.6956522
Created on 2019-04-18 by the reprex package (v0.2.1)
For your reference, here's the source code:
AUC <- function(x, y, method=c("trapezoid", "step", "spline"), na.rm = FALSE) {
# calculates Area unter the curve
# example:
# AUC( x=c(1,2,3,5), y=c(0,1,1,2))
# AUC( x=c(2,3,4,5), y=c(0,1,1,2))
if(na.rm) {
idx <- na.omit(cbind(x,y))
x <- x[idx]
y <- y[idx]
}
if (length(x) != length(y))
stop("length x must equal length y")
idx <- order(x)
x <- x[idx]
y <- y[idx]
switch( match.arg( arg=method, choices=c("trapezoid","step","spline") )
, "trapezoid" = { a <- sum((apply( cbind(y[-length(y)], y[-1]), 1, mean))*(x[-1] - x[-length(x)])) }
, "step" = { a <- sum( y[-length(y)] * (x[-1] - x[-length(x)])) }
, "spline" = { a <- integrate(splinefun(x, y, method="natural"), lower=min(x), upper=max(x))$value }
)
return(a)
}