Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

jacobian

Jacobian Matrix


Description

Jacobian matrix of a function R^n –> R^m .

Usage

jacobian(f, x0, heps = .Machine$double.eps^(1/3), ...)

Arguments

f

m functions of n variables.

x0

Numeric vector of length n.

heps

This is h in the derivative formula.

...

parameters to be passed to f.

Details

Computes the derivative of each funktion f_j by variable x_i separately, taking the discrete step h.

Value

Numeric m-by-n matrix J where the entry J[j, i] is \frac{\partial f_j}{\partial x_i}, i.e. the derivatives of function f_j line up in row i for x_1, …, x_n.

Note

Obviously, this function is not vectorized.

References

Quarteroni, A., R. Sacco, and F. Saleri (2007). Numerical Mathematics. Second Edition, Springer-Verlag, Berlin Heidelberg.

See Also

gradient

Examples

##  Example function from Quarteroni & Saleri
f <- function(x) c(x[1]^2 + x[2]^2 - 1, sin(pi*x[1]/2) + x[2]^3)
jf <- function(x) 
          matrix( c(2*x[1], pi/2 * cos(pi*x[1]/2), 2*x[2], 3*x[2]^2), 2, 2)
all.equal(jf(c(1,1)), jacobian(f, c(1,1)))
# TRUE

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.