x0 = 1;        % Adjust initial guess
imax = 100;    % Increase max iterations
tol = 1e-6;    % Relax tolerance

% Example function and derivative
func2 = @(x) x^2 - 2;     % Function: x^2 - 2
dfunc2 = @(x) 2*x;        % Derivative: 2x

% Call Newton's method
root = newton(x0, func2, dfunc2, imax, tol);
fprintf('Root found: %.6f\n', root);
