jacobian {calculus} | R Documentation |
Numerical and Symbolic Jacobian
Description
Computes the numerical Jacobian of functions
or the symbolic Jacobian of characters
in arbitrary orthogonal coordinate systems.
Usage
jacobian(
f,
var,
params = list(),
coordinates = "cartesian",
accuracy = 4,
stepsize = NULL
)
f %jacobian% var
Arguments
f |
array of |
var |
vector giving the variable names with respect to which the derivatives are to be computed and/or the point where the derivatives are to be evaluated. See |
params |
|
coordinates |
coordinate system to use. One of: |
accuracy |
degree of accuracy for numerical derivatives. |
stepsize |
finite differences stepsize for numerical derivatives. It is based on the precision of the machine by default. |
Details
The function is basically a wrapper for gradient
with drop=FALSE
.
Value
array
.
Functions
-
f %jacobian% var
: binary operator with default parameters.
References
Guidotti E (2022). "calculus: High-Dimensional Numerical and Symbolic Calculus in R." Journal of Statistical Software, 104(5), 1-37. doi:10.18637/jss.v104.i05
See Also
Other differential operators:
curl()
,
derivative()
,
divergence()
,
gradient()
,
hessian()
,
laplacian()
Examples
### symbolic Jacobian
jacobian("x*y*z", var = c("x", "y", "z"))
### numerical Jacobian in (x=1, y=2, z=3)
f <- function(x, y, z) x*y*z
jacobian(f = f, var = c(x=1, y=2, z=3))
### vectorized interface
f <- function(x) x[1]*x[2]*x[3]
jacobian(f = f, var = c(1, 2, 3))
### symbolic vector-valued functions
f <- c("y*sin(x)", "x*cos(y)")
jacobian(f = f, var = c("x","y"))
### numerical vector-valued functions
f <- function(x) c(sum(x), prod(x))
jacobian(f = f, var = c(0,0,0))
### binary operator
"x*y^2" %jacobian% c(x=1, y=3)