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: nmfunc1d nmgraddiff

Quantlet: nmfder1d
Description: Computes the derivative of a function restricted to a line: (f(t))' = d(func(x0 + t*direc)) / dt

Usage: fdert = nmfder1d(t)
Input:
nmfder1dfunc global variable, name of function (string) that has to be restricted to a line by this quantlet; as a result, the function should return a scalar
nmfder1dfder global variable, gradient of func (nmfder1dfunc); there are several possible formats: 1. name of function (string) computing gradient of func; output should be n x 1 vector 2. empty string; in this case the gradient will be computed automatically using the quantlet nmgraddiff with a default step h 3. a number or n x 1 vector h; the gradient will be computed automatically using the quantlet nmgraddiff with the given step h
nmfder1dx global variable, n x 1 vector, a point x0 on a line to which the function should be restricted
nmfder1dd global variable, n x 1 vector, direction vector "direc" of a line to which the function should be restricted
nmfder1dh optional, global variable, n x 1 vector or a scalar, step h used by nmgraddiff when computing the gradient numerically (only used when nmfder1dfder is not defined or is an empty string)
t scalar; the only input parameter of a restricted function
Output:
fdert scalar; fdert = f'(t) = d(func(x0 + h*direc)) / dh in h=t

Example:
library("nummath")
proc(a) = fun(x)
  a = x[1,]^2 + 3*(x[2,]-1)^4
endp
proc(b) = der(x)
  b = #(2*x[1,], 12*(x[2,]-1)^3)
endp
nmfder1dfunc = "fun"
nmfder1dfder = "der"
nmfder1dx    = #(2,-1)
nmfder1dd    = #(0,1)
putglobal("nmfder1dfunc")
putglobal("nmfder1dfder")
putglobal("nmfder1dx")
putglobal("nmfder1dd")
nmfder1d(3)
; computes the gradient of function fun in #(2,2)

Result:
Contents of fdert
[1,]       12
Example:
library("nummath")
proc(a) = fun(x)
  a = x[1,]^2 + 3.*(x[2,]-1)^4
endp
nmfder1dfunc = "fun"
nmfder1dx    = #(2,-1)
nmfder1dd    = #(0,1)
putglobal("nmfder1dfunc")
putglobal("nmfder1dx")
putglobal("nmfder1dd")
nmfder1d(3)
; this is the same example only with a numerically
; computed gradient

Result:
Contents of fdert
[1,]       12



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