Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: nummath
See also: nmgraddiff nmgraditer

Quantlet: nmjacobian
Description: Computes the jacobian of function(s) func (or more generally, the matrix of gradients) at a point x0

Usage: jacobi = nmjacobian(func, x0{, h, iter})
Input:
func name of function(s) (string or vector of strings) whose gradient matrix (jacobian) is to be computed. The function(s) should take just one parameter x, which is n x k matrix (k >= 1) x = (x1,x2,...,xk); xi (n x 1 vector; i=1..k) represent points in which the function should be evaluated. As a result, the function should return k real numbers in a form of 1 x k vector.
x0 n x 1 vector, the point at which gradient(s) will be computed
h optional n x 1 vector or scalar (in the latter case, h <- h * matrix(n) will be used); vector of initial stepsizes for partial derivatives; if not given, default value of gradient quantlet will be used
iter optional number, controls usage of iterative/difference method for computing gradient; if iter is not given or iter = 0, difference method nmgraddiff will be used (quicker), otherwise iterative method nmgraditer will be used (more precise)
Output:
jacobi dim(func) x n matrix, i-th row containes the gradient of i-th function (it is jacobian for dim(func) = n)

Note:

Example:
library("nummath")
;
; definition of function f(x1,x2) = sin(x1) + x2^2
;                        g(x1,x2) = x1 - x2
;
proc(ff)=f(x)
  ff=sin(x[1,])+x[2,]^2
endp
proc(gg)=g(x)
  gg=x[1,]-x[2,]
endp
;
nmjacobian(#("f","g"),#(pi,2))

Result:
Contents of jacobi
[1,]       -1        4
[2,]        1       -1



Author: L. Cizkova, 20010505 license MD*Tech
(C) MD*TECH Method and Data Technologies, 05.02.2006