x <- seq(0, 1, length.out = 10) # try larger length.out to see if area approaches 2
y <- 2 * x + 3 * x^2
A <- integrateTrapezoid(x, y)
dA <- integrateTrapezoid(x, y, "dA")
cA <- integrateTrapezoid(x, y, "cA")
print(A)
print(sum(dA))
print(tail(cA, 1))
print(integrateTrapezoid(diff(x[1:2]), y))
print(integrateTrapezoid(y))
Run the code above in your browser using DataLab