Plotting Search Data

The utility functions and show search data for FindMinimum and FindRoot for one- and two-dimensional functions. They work with essentially the same arguments as FindMinimum and FindRoot except that they additionally take options, which affect the graphics functions they call to provide the plots, and they do not have the HoldAll attribute as do FindMinimum and FindRoot.

FindMinimumPlot[f,{x,xst},opts]plot the steps and the points at which the function f and any of its derivatives that were evaluated in FindMinimum[f,{x,xst}], superimposed on a plot of f versus x; opts may include options from both FindMinimum and Plot
FindMinimumPlot[f,{{x,xst},{y,yst}},opts]plot the steps and the points at which the function f and any of its derivatives that were evaluated in FindMinimum[f,{{x,xst},{y,yst}}], superimposed on a contour plot of f as a function of x and y; opts may include options from both FindMinimum and ContourPlot
FindRootPlot[f,{x,xst},opts]plot the steps and the points at which the function f and any of its derivatives that were evaluated in FindRoot[f,{x,xst}], superimposed on a plot of f versus x; opts may include options from both FindRoot and Plot
FindRootPlot[f,{{x,xst},{y,yst}},opts]plot the steps and the points at which the function f and any of its derivatives that were evaluated in FindRoot[f,{{x,xst},{y,yst}}], superimposed on a contour plot of the merit function f as a function of x and y; opts may include options from both FindRoot and ContourPlot

Plotting search data.

Note that to simplify processing and reduce possible confusion about the function f, does not accept equations; it finds a root .

Steps and evaluation points are color coded for easy detection as follows:

  • Steps are shown with blue lines and blue points.
  • Function evaluations are shown with green points.
  • Gradient evaluations are shown with red points.
  • Hessian evaluations are shown with cyan points.
  • Residual function evaluations are shown with yellow points.
  • Jacobian evaluations are shown with purple points.
    • The search termination is shown with a large black point.

    and return a list containing , where:

  • summary is a list of rules showing the number of steps and evaluations of the function and its derivatives.
    • plot is the graphics object shown.
    This loads the package.
    In[1]:=
    Click for copyable input
    This shows in two dimensions the steps and evaluations used by FindMinimum to find a local minimum of the function starting at the point . Options are given to ContourPlot so that no contour lines are shown and the function value is indicated by grayscale. Since FindMinimum by default uses the quasi-Newton method, there are only evaluations of the function and gradient that occur at the same points, indicated by the red circles with green centers.
    In[2]:=
    Click for copyable input
    Out[2]=
    This shows in two dimensions the steps and evaluations used by FindMinimum to find a local minimum of the function starting at the point . Since the problem is a sum of squares, FindMinimum by default uses the GaussNewton/LevenbergMarquardt method that derives a residual function and only evaluates it and its Jacobian. Points at which the residual function is evaluated are shown with yellow dots. The yellow dots surrounded by a large purple circle are points at which the Jacobian was evaluated as well.
    In[3]:=
    Click for copyable input
    Out[3]=
    This shows in two dimensions the steps and evaluations used by FindMinimum to find a local minimum of the function starting at the point using Newton's method. Points at which the function, gradient, and Hessian were all evaluated are shown by concentric green, red, and cyan circles. Note that in this example, all the Newton steps satisfied the Wolfe conditions, so there were no points where the function and gradient were evaluated separately from the Hessian, which is not always the case. Note also that Newton's method finds a different local minimum than the default method.
    In[4]:=
    Click for copyable input
    Out[4]=
    This shows the steps and evaluations used by FindMinimum to find a local minimum of the function with two starting values superimposed on the plot of the function. Options are given to Plot so that the curve representing the function is thick and purple. With two starting values, FindMinimum uses the derivative-free principal axis method, so there are only function evaluations, indicated by the green dots.
    In[5]:=
    Click for copyable input
    Out[5]=
    This shows in two dimensions the steps and evaluations used by FindRoot to find a root of the function starting at the point . As described earlier, the function is a residual, and the default method in FindRoot evaluates the residual and its Jacobian as shown by the yellow dots and purple circles. Note that this plot is nearly the same as the one produced by with the default method for the function since the residual is the same. also shows the zero contour of each component of the residual function in red and green.
    In[6]:=
    Click for copyable input
    Out[6]=