function intervals = bracket_roots(f, x)
    % BRACKET_ROOTS Find intervals containing roots of f(x)
    % Inputs:
    %   f - Function handle
    %   x - Array of x values
    % Outputs:
    %   intervals - Nx2 array containing intervals with roots

    intervals = [];

    % Loop through the x values to check for sign changes
    for i = 1:length(x) - 1
        if f(x(i)) * f(x(i + 1)) < 0
         
            intervals = [intervals; x(i), x(i + 1)];
        end
    end 
    
end 
