0th

Percentile

Computes the gradient or jacobian of functions, expressions and characters.

##### Usage
gradient(f, var, accuracy = 2, stepsize = NULL,
coordinates = "cartesian")f %gradient% var
##### Arguments
f

function, expression or character array.

var

character vector, giving the variable names with respect to which derivatives will be computed. If a named vector is provided, derivatives will be computed at that point.

accuracy

accuracy degree for numerical derivatives.

stepsize

finite differences stepsize for numerical derivatives. Auto-optimized by default.

coordinates

coordinate system to use. One of: cartesian, polar, spherical, cylindrical, parabolic, parabolic-cylindrical or a character vector of scale factors for each varibale.

##### Functions

• gradient: arbitrary coordinate system

• %gradient%: cartesian coordinates

##### Examples
# NOT RUN {
# gradient with respect to x
gradient(f = "sin(x)", var = "x")

# gradient with respect to x and evaluate in x = 0
gradient(f = "sin(x)", var = c("x" = 0))

# gradient with respect to (x,y)
gradient(f = "y*sin(x)", var = c("x","y"))

# jacobian with respect to (x,y)
f <- c("y*sin(x)", "x*cos(y)")
gradient(f = f, var = c("x","y"))

# jacobian with respect to (x,y) and evaluate in (x = 0, y = 0)
f <- c(function(x, y) y*sin(x), function(x, y) x*cos(y))
gradient(f = f, var = c(x=0,y=0))