Teaching Numerical Gradients and Hessians

Simple, well-commented Matlab code to demonstrate how to take numerical derivatives and Hessians.
1.6K Downloads
Updated 14 Aug 2012

View License

This submission is a set of m-files to demonstrate how to take a simple numerical derivative and Hessian of an arbitrary function. Each step in the code is documented. There is a test script included which computes the numerical Hessian of a test function and compares it to a symbolically-determined result (with a numerical point substituted into the symbolic Hessian). The gradient and Hessian functions support varying tolerance, and also counting the number of function evaluations in order to give a sense of just how expensive numerical derivatives can be.

The test script requires the Symbolic Math Toolbox.

Cite As

Brendan Wood (2024). Teaching Numerical Gradients and Hessians (https://www.mathworks.com/matlabcentral/fileexchange/30408-teaching-numerical-gradients-and-hessians), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010b
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!
Version Published Release Notes
1.1.0.0

Updated license to include my full name.

1.0.0.0