View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Teaching Numerical Gradients and Hessians

5.0 | 1 rating Rate this file 8 Downloads (last 30 days) File Size: 4.53 KB File ID: #30408 Version: 1.1

Teaching Numerical Gradients and Hessians



14 Feb 2011 (Updated )

Simple, well-commented Matlab code to demonstrate how to take numerical derivatives and Hessians.

| Watch this File

File Information

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.

Required Products Symbolic Math Toolbox
MATLAB release MATLAB 7.11 (R2010b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
19 Aug 2012 Oleg Komarov

Oleg Komarov (view profile)

I like this submission but as Leo pointed out an illustrative script would complete the submission.

Also, I would use in that case an anonymous function.

Comment only
14 Aug 2012 Leo Simon

Thanks for this! It *looks* like there should be a script somewhere that calls each of the various functions, but there isn't one in the download zip. Was there meant to be?

Comment only
15 Feb 2011 Pi Ting


14 Aug 2012 1.1

Updated license to include my full name.

Contact us