Integration of two lines
Hans W Borchers wrote :
First define a function from those points:
fx <- approxfun(x, f_x)
fy <- approxfun(y, f_y)
f <- function(x) abs(fx(x)-fy(x))
and now you can apply integrate() or trapz():
xx <- sort(c(x, y))
yy <- f(xx)
trapz(xx, yy)
trapz() should return the more accurate (i.e. exact) result.
Thanks a lot Hans! I didn't know about the 'approx' functions and that was exaclty what I needed! Regards, Xavier