function [root, iter] = secant(func, x0, x1, tol, max_iter)
    iter = 0;
    while iter < max_iter
        iter = iter + 1;
        f0 = func(x0);
        f1 = func(x1);
        x_new = x1 - f1 * (x1 - x0) / (f1 - f0);
        if abs(x_new - x1) < tol
            break;
        end
        x0 = x1;
        x1 = x_new;
    end
    root = x1;
end
