traprule: Trapezoid Rule Numeric Integration

View source: R/RcppExports.R

trapruleR Documentation

Trapezoid Rule Numeric Integration

Description

Compute the integral of y with respect to x via trapezoid rule.

Usage

traprule(x, y)

Arguments

x, y

numeric vectors of equal length

Value

a numeric value, the estimated integral

Examples

xvec <- seq(-2 * pi, 3 * pi, length = 560)
foo  <- function(x) { sin(x) + x * cos(x) + 12 }
yvec <- foo(xvec)
plot(xvec, yvec, type = "l")

integrate(f = foo, lower = -2 * pi, upper = 3 * pi)
traprule(xvec, yvec)


dewittpe/qwraps2 documentation built on Jan. 4, 2024, 1:59 p.m.