num_diff: Differentiate on a Grid

Description Usage Arguments Value Examples

View source: R/numeric_tools.R

Description

Differentiate on a Grid

Usage

1

Arguments

f

A sequence of values of a function

grid

The corresponding x axis

Value

The derivative on the grid.

Examples

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

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

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