diff -crB old/fminbnd.m new/fminbnd.m
*** old/fminbnd.m	2016-01-04 14:06:09.685629516 +0100
--- new/fminbnd.m	2016-01-04 14:53:34.701632071 +0100
***************
*** 60,66 ****
  ## PKG_ADD: ## Discard result to avoid polluting workspace with ans at startup.
  ## PKG_ADD: [~] = __all_opts__ ("fminbnd");
  
! function [x, fval, info, output] = fminbnd (fun, xmin, xmax, options = struct ())
  
    ## Get default options if requested.
    if (nargin == 1 && ischar (fun) && strcmp (fun, 'defaults'))
--- 60,66 ----
  ## PKG_ADD: ## Discard result to avoid polluting workspace with ans at startup.
  ## PKG_ADD: [~] = __all_opts__ ("fminbnd");
  
! function [x, fval, info, output] = fminbnd (fun, xmin, xmax, options = struct (), varargin)
  
    ## Get default options if requested.
    if (nargin == 1 && ischar (fun) && strcmp (fun, 'defaults'))
***************
*** 69,78 ****
      return;
    endif
  
!   if (nargin < 2 || nargin > 4)
      print_usage ();
    endif
  
    if (xmin > xmax)
      error ("Octave:invalid-input-arg",
             "fminbnd: the lower bound cannot be greater than the upper one");
--- 69,91 ----
      return;
    endif
  
!   if (nargin < 2)
      print_usage ();
    endif
  
+   if (ischar (fun))
+     fun = str2func (fun, "global");
+   endif
+ 
+   ## varargin handling
+   if isempty (options)
+     options = struct ();
+   elseif ~isstruct (options)
+     error ('options must be a structure (or empty matrix)')
+   endif
+   fun = @(x) fun (x, varargin{:});
+   ## end of varargin handling
+   
    if (xmin > xmax)
      error ("Octave:invalid-input-arg",
             "fminbnd: the lower bound cannot be greater than the upper one");
diff -crB old/fminsearch.m new/fminsearch.m
*** old/fminsearch.m	2016-01-04 14:06:09.685629516 +0100
--- new/fminsearch.m	2016-01-04 14:53:54.481849788 +0100
***************
*** 58,64 ****
  ## FIXME: Add support for OutputFcn.  See fminunc for a template
  ## FIXME: Add support for exiting based on TolFun.  See fminunc for an idea.
  
! function [x, fval] = fminsearch (fun, x0, options = struct ())
  
    ## Get default options if requested.
    if (nargin == 1 && ischar (fun) && strcmp (fun, "defaults"))
--- 58,64 ----
  ## FIXME: Add support for OutputFcn.  See fminunc for a template
  ## FIXME: Add support for exiting based on TolFun.  See fminunc for an idea.
  
! function [x, fval] = fminsearch (fun, x0, options = struct (), varargin)
  
    ## Get default options if requested.
    if (nargin == 1 && ischar (fun) && strcmp (fun, "defaults"))
***************
*** 69,78 ****
      return;
    endif
  
!   if (nargin < 2 || nargin > 3)
      print_usage ();
    endif
  
    x = nmsmax (fun, x0, options);
  
    if (isargout (2))
--- 69,91 ----
      return;
    endif
  
!   if (nargin < 2)
      print_usage ();
    endif
  
+   if (ischar (fun))
+     fun = str2func (fun, "global");
+   endif
+ 
+   ## varargin handling
+   if isempty (options)
+     options = struct ();
+   elseif ~isstruct (options)
+     error ('options must be a structure (or empty matrix)')
+   endif
+   fun = @(x) fun (x, varargin{:});
+   ## end of varargin handling
+ 
    x = nmsmax (fun, x0, options);
  
    if (isargout (2))
diff -crB old/fminunc.m new/fminunc.m
*** old/fminunc.m	2016-01-04 14:06:09.685629516 +0100
--- new/fminunc.m	2016-01-04 14:54:02.809941555 +0100
***************
*** 93,99 ****
  ## PKG_ADD: ## Discard result to avoid polluting workspace with ans at startup.
  ## PKG_ADD: [~] = __all_opts__ ("fminunc");
  
! function [x, fval, info, output, grad, hess] = fminunc (fcn, x0, options = struct ())
  
    ## Get default options if requested.
    if (nargin == 1 && ischar (fcn) && strcmp (fcn, 'defaults'))
--- 93,99 ----
  ## PKG_ADD: ## Discard result to avoid polluting workspace with ans at startup.
  ## PKG_ADD: [~] = __all_opts__ ("fminunc");
  
! function [x, fval, info, output, grad, hess] = fminunc (fcn, x0, options = struct (), varargin)
  
    ## Get default options if requested.
    if (nargin == 1 && ischar (fcn) && strcmp (fcn, 'defaults'))
***************
*** 105,118 ****
      return;
    endif
  
!   if (nargin < 2 || nargin > 3 || ! ismatrix (x0))
      print_usage ();
    endif
! 
    if (ischar (fcn))
      fcn = str2func (fcn, "global");
    endif
  
    xsiz = size (x0);
    n = numel (x0);
  
--- 105,127 ----
      return;
    endif
  
!   if (nargin < 2 || ! ismatrix (x0))
      print_usage ();
    endif
!   
    if (ischar (fcn))
      fcn = str2func (fcn, "global");
    endif
  
+   ## varargin handling
+   if isempty (options)
+     options = struct ();
+   elseif ~isstruct (options)
+     error ('options must be a structure (or empty matrix)')
+   endif
+   fcn = @(x) fcn (x, varargin{:});
+   ## end of varargin handling
+ 
    xsiz = size (x0);
    n = numel (x0);
  
