function roots = newtonsAllRoots(f, tol, imax)
    % Define the interval
    a = 4; % Start of interval
    b = 10; % End of interval

    % Define starting guesses within the interval (spaced grid)
    start_points = linspace(a, b, 100);

    % Container for storing unique roots
    roots = [];

    % Loop through each starting guess
    for i = 1:length(start_points)
        x_guess = start_points(i);
        [x_root, ~] = Newton(f, @(x) numerical_derivative(f, x), imax, tol, x_guess);

        % Check if the root is unique within the tolerance
        if all(abs(roots - x_root) > tol) && x_root >= a && x_root <= b
            roots = [roots; x_root]; % Add new root to the list
        end
    end

    % Display the found roots
    fprintf('Roots found in the interval [%d, %d]:\n', a, b);
    for i = 1:length(roots)
        fprintf('Root %d: %10.6f\n', i, roots(i));
    end
end

function df = numerical_derivative(f, x)
    h = 1e-6; % Small step for numerical differentiation
    df = (f(x + h) - f(x - h)) / (2 * h);
end