num_int: Integrate on a Grid

Description Usage Arguments Value Examples

View source: R/numeric_tools.R

Description

Integrate on a Grid

Usage

1
num_int(f, grid, constant = 0)

Arguments

f

A sequence of values of a function

grid

The corresponding x axis

constant

Optional constant to add to the derivative.

Value

The integral between the start of the grid up until the grid.

Examples

1
2
3
4
5
6
x <- seq(from = 0, to = 2 * pi, by = 0.01)
f <- sin(x)
int_f <- num_int(f, x, -1)

plot(x, -cos(x), type = "l", col = "red")
points(x, int_f, col = "blue")

osorensen/mytools documentation built on May 3, 2019, 5:47 p.m.