# Numerical Differentiation Toolbox Documentation

## Installation

2. Open the INSTALL folder.
3. 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.

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

## Central Difference Differentiation Functions

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

## Forward Difference Differentiation Functions

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

## Complex-Step Differentiation Functions

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

## Complexified Functions

• iabs Absolute value (complexified version of abs).
• iatan2d Four-quadrant inverse tangent in degrees (complexified version of atan2d).
• idot Vector dot product (complexified version of dot).
• imax Maximum of two numbers (complexified version of max).
• imin Minimum of two numbers (complexified version of min).
• imod Remainder after division with divisor's sign (complexified version of mod).
• inorm 2-norm of a vector (complexified version of norm).
• irem Remainder after division with dividend's sign (complexified version of 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.