trind {dsfa} R Documentation

## trind function

### Description

Provides the column index of the required derivative for the specified order of a derivs object.

### Usage

trind(tri, part_deriv_var)


### Arguments

 tri list; created by the function trind_generator(). part_deriv_var integer vector; specifies \frac{\partial^J f(\cdot)}{\partial x_{ni_1} ... \partial x_{ni_J}}. The length of the vector is denoted as J and determines the order of the partial derivatives with maximum four. The element i_j \in \{0,...,K-1\} specifies the variable with respect to which the derivative is taken, where j \in \{1,...,J\}, The order corresponds to the order of derivatives. For example c(0,0,1,2) is equal to \frac{\partial^4 f(\cdot)}{\partial x_{n1} \partial x_{n1} \partial x_{n2} \partial x_{n3}}. See details for more information.

### Details

Let f:\mathbb{R}^K \to \mathbb{R}^L, (x_{n1},x_{n2},...,x_{nK}) \mapsto f(x_{n1},x_{n2},...,x_{nK}) be differentiable up to order four w.r.t all parameters x_{nk}, where k \in \{1,...,K\} and n \in \{1,...,N\}. Then a derivs class object is a numeric matrix with N rows and L columns. N is the length of the input vectors. Further, it has the following attributes:

1. d1: a numeric matrix of the first derivatives w.r.t all parameters, where the nth row corresponds to: (\frac{\partial f(\cdot)}{\partial x_{n1}}, \frac{\partial f(\cdot)}{\partial x_{n1}},...,\frac{\partial f(\cdot)}{\partial x_{nK}})

2. d2: a numeric matrix of the second derivatives w.r.t all parameters, where the nth row corresponds to: (\frac{\partial^2 f(\cdot)}{\partial x_{n1} \partial x_{n1}}, \frac{\partial^2 f(\cdot)}{\partial x_{n1} \partial x_{n2}},...,\frac{\partial^2 f(\cdot)}{\partial x_{nK} \partial x_{nK}})

3. d3: a numeric matrix of the third derivatives w.r.t all parameters, where the nth row corresponds to: (\frac{\partial^3 f(\cdot)}{\partial x_{n1} \partial x_{n1} \partial x_{n1}}, \frac{\partial^3 f(\cdot)}{\partial x_{n1} \partial x_{n1} \partial x_{n2}},...,\frac{\partial^3 f(\cdot)}{\partial x_{nK} \partial x_{nK} \partial x_{nK}})

4. d4: a numeric matrix of the fourth derivatives w.r.t all parameters, where the nth row corresponds to: (\frac{\partial^4 f(\cdot)}{\partial x_{n1} \partial x_{n1} \partial x_{n1} \partial x_{n1}}, \frac{\partial^4 f(\cdot)}{\partial x_{n1} \partial x_{n1} \partial x_{n1} \partial x_{n2}},...,\frac{\partial^4 f(\cdot)}{\partial x_{nK} \partial x_{nK} \partial x_{nK} \partial x_{nK}})

The function trind() provides the index for the corresponding derivatives. The derivs class object allows for a modular system which can be easily extended and is faster than numerical derivatives. The advantage compared to analytical derivatives provided by 'mathematica' or deriv() is that asymptotics and approximations can be used for individual parts. Handwritten derivatives can be tedious at times and may be prone to errors. Thus, the derivs class object can be used by lazy users. Mainly intended for internal use.

### Value

Integer, the index for a derivs object.

Other derivs: chainrule(), derivs_transform(), differencerule(), ind2joint(), list2derivs(), productrule(), quotientrule(), sumrule(), trind_generator()
tri=trind_generator(3)