dfun: Finite Differences

Description Usage Arguments Value Author(s) Examples

Description

Estimates the derivate (or gradient) of the function fn with respect to the argument x

Usage

1
2
3
4
5
6
7
## S3 method for class 'numeric'
dfun(x, fn)

## S3 method for class 'array'
dfun(x, fn)

dfun(x, fn)

Arguments

x

input numeric

fn

function

Value

Returns the gradient of x

Author(s)

Filippo Monari

Examples

1
2
3
4
5
6
7
fn = function(x)x**2
## On scalar arguments
dx_scalar = dfun(3, fn)
print(dx_scalar)
## On matrix (or arrays)
dx_array = dfun(matrix(c(3, 3, 3, 3), 2, 2), fn)
print(dx_array)

modello documentation built on Feb. 2, 2021, 9:06 a.m.

Related to dfun in modello...