function X = IntervalNewton(f,X1,varargin)

% X = IntervalNewton(f,X1,varargin)
%
% applies interval Newton method until convergence
%
%   f           interval function, must be enabled for automatic 
%                   differentiation, call f(x,varargin)
%   X1          initial interval
%   varargin    additional arguments for f
%
%   X           converged interval

X = intval(inf(X1));
while X ~= X1
    X = X1;
    x = intval(mid(X));
    F = feval(f,gradientinit(X),varargin{:});
    fx = feval(f,x,varargin{:});
    X1 = intersect(x-fx/F.dx,X);
end

return