| jacobian | R Documentation |
Computes the first derivative of f at x using forward-mode
AD. Equivalent to D(f, x). For f: R^p -> R^m, returns an
m x p matrix. For scalar-valued f, returns a length-p
gradient vector.
jacobian(f, x)
f |
A function taking a parameter vector and returning a scalar,
list of scalars, or a |
x |
A numeric vector of parameter values (length |
An m x p numeric matrix for vector-valued f, or
a numeric vector of length p for scalar-valued f.
f <- function(x) {
a <- x[1]; b <- x[2]
list(a * b, a^2, sin(b))
}
jacobian(f, c(2, pi/4))
g <- function(x) x[1]^2 + x[2]^2
jacobian(g, c(3, 4))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.