optimization – Newton method using automatic differentiation


I wrote a large Matlab code which solves partial differential equations. Now I would like to test the code on nonlinear problems, for which I need the Newton-Raphson iteration for systems of nonlinear algebraic equations.

How do I employ automatic differentiation in Matlab to use the Newton-Raphson iteration?