matrix.derv: Matrix derivative

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Evaluate the derivative of the following types (d denotes the "curly d" in partial derivatives):

Note that this is only for real variables although one may modify the source code allowing for some complex-valued ones. Yet correct result is not guaranteed.

Usage

1
matrix.derv(Y, X0, order = 1, rel.tol=.Machine$double.eps^0.5)

Arguments

Y

One single function y (for type 0, 1 & 4), a vector of functions y (for type 2 & 3) or a matrix of functions Y (for type 5) whose derivative to be evaluated.
For a vector or a matrix of functions, the variables and their order must be the same across all functions. Also see Examples.

X0

Evaluation points of the derivative. It can be a scalar x (type 0, 2 & 5), a vector x (type 1 & 3) or a matrix X (type 4).
Note that (1) the number of elements in X0 must match the number of variables in each of the functions in Y and,
(2) the order of the elements in X0 follows that of the variables in each of the functions in Y.
Also see Examples.

order

The order of the derivative. Must be a non-zero natural number.

rel.tol

Relative tolerance of the R built-in function integrate in calculating the derivative.

Details

Error or misleading result may occur if arugments are not properly supplied. Some examples:

Value

result

A matrix even if type 0 (scalar-by-scalar).

type

The type of derivative: 0,1,...,5

Author(s)

Char Leung

See Also

derv

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#Type-0 : scalar-by-scalar
X<-3
Y<-function(x){x^3}
matrix.derv(Y,X)
#Type-1 (gradient): scalar-by-vector
X<-c(1,2,0.4)
Y<-function(a,b,c){a^2+b*c}
matrix.derv(Y,X)
#Type-2 : vector-by-scalar
X<-10
Y<-c(function(a){sin(a)},function(a){cos(a)*a^2})
matrix.derv(Y,X)
#Type-3 (Jacobian) : vector-by-vector 
X<-c(1,3,5)
Y<-c(function(a,b,c){a^2+c/b},function(a,b,c){a+b/c})
matrix.derv(Y,X)
#Type-4 : scalar-by-matrix
X<-matrix(1:9,ncol=3)
Y<-function(a,b,c,x,y,z,s,t,r){a*b+c-x*y*z*(s+t+r)}
matrix.derv(Y,X)
#Type-5 : matrix-by-scalar
X<-2
Y<-matrix(c(function(a){a^3},function(a){a^2},function(a){a},function(a){1}),ncol=2)
matrix.derv(Y,X)

ComplexAnalysis documentation built on Jan. 15, 2017, 10:24 a.m.

Search within the ComplexAnalysis package
Search all R packages, documentation and source code