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)]))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.