# Numerical Differentiation Toolbox Documentation

Copyright © 2021 Tamas Kis

## Contents

## Technical Documentation

Click here.

## Methodology

All of these functions are implemented using the complex-step approximation of the derivative (this is why each function is prefixed with an "i"; it is meant to indicate the imaginary unit). A complete technical documentation is available that details the implementation in depth.

## 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_using_the_Complex_Step_Approximation.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_using_the_Complex-Step_Approximation.pdf) for the various algorithms.**tests**→ Code for unit tests.**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.

## Differentiation Functions

Derivative of a univariate, scalar or vector-valued function.`iderivative`Partial derivative of a multivariate, scalar or vector-valued function.`ipartial`Gradient of a multivariate, scalar-valued function.`igradient`Directional derivative of a multivariate, scalar-valued function.`idirectional`Jacobian matrix of a multivariate, vector-valued function.`ijacobian`Hessian matrix of a multivariate, scalar-valued function.`ihessian`

## Complexified Functions

"Complexified" version of the absolute value (`iabs``iabs`) function."Complexified" version of the four quadrant inverse tangent (`iatan2``atan2`) function (in radians)."Complexified" version of the four quadrant inverse tangent (`iatan2d``atan2d`) function (in degrees)."Complexified" version of the 2-norm (`inorm``norm`) function.

## 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 1.4 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`, 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 (likely due to complexification issues) are summarized in Section 1.3.3 of the technical documentation.
- The functions in this toolbox cannot perform higher-order derivatives (this limitation is discussed in Section 1.3.1 of the technical documentation).
- All of the functions are (generally) accurate to double precision
**with the exception of**`ihessian`. An alternative that will perform better is the`hessian`function provided by the Adaptive Robust Numerical Differentiation toolbox. - No error estimates are provided.