Learn R Programming

mosaic (version 0.1-34)

D: Derivative and Anti-derivative operators

Description

Operators for computing numerical derivatives and anti-derivatives as functions.

Usage

D(f, n=1, h = 1e-04)
antiD(f, input0 = 0, val0 = 0, init = c(input0, val0), ...)

Arguments

f
a function that returns a numerical vector of the same length as its first (numerical) argument. All values are required to be finite.
h
horizontal distance between points used for secant slope calculation in D()
n
order of derivative
input0
initial input to f unless init is used instead
val0
initial value of f unless init is used instead
init
a numerical vector of length 2 providing an initial input to and value of the function f
...
additional arguments to f

Value

  • A function.

Examples

Run this code
fplot(D(sin),xlim=c(-2*pi,2*pi))
fplot(antiD(sin),xlim=c(-2*pi,2*pi))
fplot( list( sin, D(sin), D(sin,2) ), xlim=c(-2*pi, 2*pi) )
f <- antiD(cos)
f(1)
sin(1)

Run the code above in your browser using DataLab