# fminnewton.m

From Spinach Documentation Wiki

Finds a local minimum (or maximum) of a function of several variables, based on fminlbfgs.m code from D. Kroon, University of Twente (Nov 2010).

## Syntax

[x,fx,grad,hess,data]=fminnewton(cost_function,x_0,optim,hess_init,cost_fun_vars)

## Description

This is the most developed optimisation algorithm within Spinach. It uses a line search

The `cost_function` is a function handle to that which produces as cost, gradient, and\or Hessian as a function of an initial guess, `x_0`. `optim` is an optional argument containing the optimisation options as a pair-wise cell structure.

## Arguments

cost_function - Function handle, e.g. @cost_function, x_0 - Initial guess for the waveform. optim - Structure providing the options for the numerical optimisation algorithm. See optim_tols.m for all options. hess_init - (optional) an initial Hessian to use for quasi-newton methods. If not provided, the identity is used as a default. cost_fun_vars - (optional) an set of variable to pass to the cost function. These can be modified within the cost function.

## Returns

x - Output waveform at the end of the optimisation. Should be the waveform at a local minimum (or maximum) cost. fx - Output cost at the end of the optimisation. grad - Output gradient at the end of the optimisation. hess - Output Hessian matrix at the end of the optimisation. Has meaning from 'bfgs', 'sr1', or 'newton', returns the identity otherwise. data - data structure containing diagnostics of the optimisation algorithm.

## Notes

This function is coded both for minimisation (default) and maximisation. This option is defined in the `optim` structure from optim_tols.m.

## See also

linesearch.m, optim_tols.m, hessreg.m, hessprep.m

*Version 1.9, authors: David Goodwin*