# Numerical Differentiation Toolbox Documentation

Copyright © 2021 Tamas Kis

## Contents

## Technical Documentation

Click here.

## Installation

- Download the toolbox from File Exchange or GitHub.
- Open the
`INSTALL`folder. - Double-click on
`Numerical Differentiation Toolbox.mltbx`.

MATLAB will automatically perform the installation and add all the contents of the `toolbox` folder to the MATLAB search path. Alternatively, all of the functions in the `toolbox` folder can be used independently.

## Opening this documentation using the MATLAB Command Window.

To open the home page (this page) of the toolbox documentation in MATLAB, type the following in the Command Window:

doc_NDT

To open the documentation of a specific function with name `function_name`, type the following in the Command Window:

```
doc_NDT function_name
```

To open the technical documentation PDF (`Numerical_Differentiation.pdf`), type the following in the Command Window:

```
doc_NDT tech
```

## Differentiator Class

Class defining a differentiator.`Differentiator`

## Central Difference Differentiation Functions

Derivative of a univariate, vector-valued function using the central difference approximation.`cderivative`Partial derivative of a multivariate, vector-valued function using the central difference approximation.`cpartial`Gradient of a multivariate, scalar-valued function using the central difference approximation.`cgradient`Directional derivative of a multivariate, scalar-valued function using the central difference approximation.`cdirectional`Jacobian of a multivariate, vector-valued function using the central difference approximation.`cjacobian`Hessian of a multivariate, scalar-valued function using the central difference approximation.`chessian`Vector Hessian of a multivariate, vector-valued function using the central difference approximation.`cvechessian`

## Forward Difference Differentiation Functions

Derivative of a univariate, vector-valued function using the forward difference approximation.`fderivative`Partial derivative of a multivariate, vector-valued function using the forward difference approximation.`fpartial`Gradient of a multivariate, scalar-valued function using the forward difference approximation.`fgradient`Directional derivative of a multivariate, scalar-valued function using the forward difference approximation.`fdirectional`Jacobian of a multivariate, vector-valued function using the forward difference approximation.`fjacobian`Hessian of a multivariate, scalar-valued function using the forward difference approximation.`fhessian`Vector Hessian of a multivariate, vector-valued function using the forward difference approximation.`fvechessian`

## Complex-Step Differentiation Functions

Derivative of a univariate, vector-valued function using the complex-step approximation.`iderivative`Partial derivative of a multivariate, vector-valued function using the complex-step approximation.`ipartial`Gradient of a multivariate, scalar-valued function using the complex-step approximation.`igradient`Directional derivative of a multivariate, scalar-valued function using the complex-step approximation.`idirectional`Jacobian of a multivariate, vector-valued function using the complex-step approximation.`ijacobian`Hessian of a multivariate, scalar-valued function using the complex-step and central difference approximations.`ihessian`Vector Hessian of a multivariate, vector-valued function using the complex-step and central difference approximations.`ivechessian`

## Complexified Functions

Absolute value (complexified version of`iabs``abs`).Four-quadrant inverse tangent in radians (complexified version of`iatan2``atan2`).Four-quadrant inverse tangent in degrees (complexified version of`iatan2d``atan2d`).Vector dot product (complexified version of`idot``dot`).Maximum of two numbers (complexified version of`imax``max`).Minimum of two numbers (complexified version of`imin``min`).Remainder after division with divisor's sign (complexified version of`imod``mod`).2-norm of a vector (complexified version of`inorm``norm`).Remainder after division with dividend's sign (complexified version of`irem``rem`).

## Warnings/Disclaimers

- Whenever a transpose is used in a function that is being differentiated using the complex-step approximation, special care must be taken to use the non-conjugate transpose (
`.'`) instead of the conjugate transpose (`'`) → see Section 3.3 of the technical documentation. - There are some special cases of functions where the complex-step approximation will not work directly; for example, trying to differentiate functions using MATLAB's
`atan2`or`abs`would result in errors. We can "complexify" these functions to make them suitable for use with the complex-step approximation; in this toolbox, we have included`iabs`,`iatan2`,`iatan2d`,`idot`,`imax`,`imin`,`imod`, and`inorm`in src/complexified. However, more complexified functions can be found (programmed in Fortran) at https://mdolab.engin.umich.edu/misc/files/complexify.f90. - Most differentiable functions can be used with the complex-step approximation functions of this toolbox. Functions that result in errors when using the complex-step approximation functions are summarized in Section 3.4.2 of the technical documentation.
- The functions in this toolbox cannot be nested to obtain higher-order derivatives.
- All of the complex-step approximation functions are accurate to double precision
**with the exception of**`ihessian`. - No error estimates are provided.