Mercurial > hg > octave-nkf
diff scripts/optimization/fzero.m @ 10687:a8ce6bdecce5
Improve documentation strings.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Tue, 08 Jun 2010 20:22:38 -0700 |
parents | 9500a66118dc |
children | 693e22af08ae |
line wrap: on
line diff
--- a/scripts/optimization/fzero.m +++ b/scripts/optimization/fzero.m @@ -19,21 +19,26 @@ ## Author: Jaroslav Hajek <highegg@gmail.com> ## -*- texinfo -*- -## @deftypefn {Function File} {[@var{x}, @var{fval}, @var{info}, @var{output}] =} fzero (@var{fun}, @var{x0}, @var{options}) -## Find a zero point of a univariate function. @var{fun} should be a function -## handle or name. @var{x0} should be a two-element vector specifying the initial -## bracketing. It should hold +## @deftypefn {Function File} {} fzero (@var{fun}, @var{x0}) +## @deftypefnx {Function File} {} fzero (@var{fun}, @var{x0}, @var{options}) +## @deftypefnx {Function File} {[@var{x}, @var{fval}, @var{info}, @var{output}] =} fzero (@dots{}) +## Find a zero of a univariate function. +## +## @var{fun} should be a function handle or name. @var{x0} should be a +## two-element vector specifying two points which bracket a zero. In +## other words, there must be a change in sign of the function between +## @var{x0}(1) and @var{x0}(2). More mathematically, the following must hold ## @example ## sign (@var{fun}(@var{x0}(1))) * sign (@var{fun}(@var{x0}(2))) <= 0 ## @end example -## If only a single scalar is given as @var{x0}, several nearby and distant -## values are probed in an attempt to obtain a valid bracketing. If this +## If @var{x0} is a single scalar then several nearby and distant +## values are probed in an attempt to obtain a valid bracketing. If this ## is not successful, the function fails. ## @var{options} is a structure specifying additional options. ## Currently, @code{fzero} ## recognizes these options: @code{"FunValCheck"}, @code{"OutputFcn"}, ## @code{"TolX"}, @code{"MaxIter"}, @code{"MaxFunEvals"}. -## For description of these options, see @ref{doc-optimset,,optimset}. +## For a description of these options, see @ref{doc-optimset,,optimset}. ## ## On exit, the function returns @var{x}, the approximate zero point ## and @var{fval}, the function value thereof. @@ -41,14 +46,28 @@ ## ## @itemize ## @item 1 -## The algorithm converged to a solution. +## The algorithm converged to a solution. ## @item 0 -## Maximum number of iterations or function evaluations has been exhausted. +## Maximum number of iterations or function evaluations has been reached. ## @item -1 ## The algorithm has been terminated from user output function. ## @item -5 ## The algorithm may have converged to a singular point. ## @end itemize +## +## @var{output} is a structure containing runtime information about the +## @code{fzero} algorithm. Fields in the structure are: +## +## @itemize +## @item iterations +## Number of iterations through loop. +## @item nfev +## Number of function evaluations. +## @item bracketx +## A two-element vector with the final bracketing of the zero along the x-axis. +## @item brackety +## A two-element vector with the final bracketing of the zero along the y-axis. +## @end itemize ## @seealso{optimset, fsolve} ## @end deftypefn @@ -310,8 +329,8 @@ output.iterations = niter; output.funcCount = nfev; - output.bracket = [a, b]; - output.bracketf = [fa, fb]; + output.bracketx = [a, b]; + output.brackety = [fa, fb]; endfunction