# Numerical Differentiation Toolbox Documentation

Copyright © 2021 Tamas Kis

## Contents

## Technical Documentation

Click here.

## Opening this documentation using the MATLAB Command Window.

To open the home page (this page) of the toolbox documentation in MATLAB, type

doc_NDT

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

```
doc_NDT function_name
```

To open the PDF file with the technical documentation (Numerical_Differentiation.pdf) from the Command Window, type

```
doc_NDT tech
```

## Installation

The toolbox can be downloaded from File Exchange or GitHub. The downloaded zip folder contains the following:

**docs**→ Contains the HTML documentation needed by GitHub to deploy the online version of the toolbox documentation.**INSTALL**→ Contains the toolbox installer (Numerical Differentiation Toolbox.mltbx).**licenses**→ Contains the software licenses.**README.md**→ Markdown documentation for GitHub repository.**Technical Documentation**→ Contains the technical documentation (Numerical_Differentiation.pdf) for the various algorithms.**tests**→ Code for unit tests (requires the Simple Unit Testing Toolbox).**toolbox**→ Contains all the functions specific to this toolbox.**toolbox/doc**→ Contains a copy of all the files and functions needed to open both the toolbox documentation and the technical documentation directly from the MATLAB command window using the`doc_NDT`function.

**To install as a toolbox**, simply open "Numerical Differentiation Toolbox.mltbx" in the "INSTALL" folder. MATLAB will automatically perform the installation and add all the functions included in the toolbox to the MATLAB search path.

Alternatively, all of the functions in the "toolbox" folder can be used independently.

## 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 approximation.`ihessian`

## Complexified Functions

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

## 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`

## 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`

## 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.1 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 various 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 can only perform first-order derivatives.
- All of the complex-step approximation functions are (generally) accurate to double precision
**with the exception of**`ihessian`. An alternative that may perform better is the`hessian`function provided by the Adaptive Robust Numerical Differentiation toolbox. - No error estimates are provided.