R/integrate_xy_left.R

integrate_xy_left <-
function (x,y) {
## Summary: Calulates the function F(z) = int_0^z f(x) dx
## Input:
# Two vectors x, y of same length  
## Output:
# Gives a vector of same length with evaluated numbers at each point
	if(length(x) != length(y)) stop("Both vectors should have same length")
    idx = 2:length(x)
	int_left 				<- cumsum(as.double((x[idx] - x[idx - 1]) * (y[idx] + y[idx - 1]))/2)
	return(c(int_left, int_left[length(int_left)]))
}
stefanrameseder/PartiallyFD documentation built on May 29, 2019, 9:50 a.m.