File Exchange

image thumbnail

Automatic Differentiation for Matlab

version (116 KB) by Martin Fink
This package provides automatic first and second derivatives for vector-functions and matrices.


Updated 11 Jun 2007

View License

This package uses forward automatic differentiation to calculate the first and second derivatives of provided user functions. It is 25-30 times faster than
commercially available packages (June 2006).

To calculate the derivatives of function myFunc with respect to x at x=x0 you call

x = myAD(x0);
result = myFunc(x);
functionValue = getvalues(result);
derivatives = getderivs(result);

Cite As

Martin Fink (2021). Automatic Differentiation for Matlab (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (12)

Jorge Sabat

I am getting this error, do you have any idea of what can be happening?

The following error occurred converting from myAD to double:
Error using double
Conversion to double from myAD is not possible.

Changjie Guan


I run into the same problem as described by David, input_variable(1)*internal_function_vector(1:N) couldn't go through, the operation is not covered. Otherwise it'll be a terrific package.


Gabriel Peyre

Achim Schaedle

nice and usefull


This package is only useful if there are no matrix operations in your function, and this includes repmat on vectors. An operation as simple as

est = input_variable(1) * internal_function_vector(1:N)

falls outside the bounds of this routine, so be warned!

Adam Attarian

masharvi shams

how to use this?plz, help me

Cristian Montes

This is great! Thanks so much. Would you like to port it to R?

Julian Montanez Vega

is very insteresting
excellent work

carlos david vinante bewaller

MATLAB Release Compatibility
Created with R14SP2
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!