% Define function and derivative
f = @(x) 100 * exp(-x) - 5 * sin(pi * x / 2);
df = @(x) -100 * exp(-x) - (5 * pi / 2) * cos(pi * x / 2);

% Define range and tolerance
x_range = [4, 10];
x = linspace(x_range(1), x_range(2), 100);
tol = 1e-6;
imax = 50;

% Step 1: Bracketing
intervals = bracket_roots(f, x);

% Step 2: Refine roots
roots_bisection = find_roots(f, df, intervals, 'bisection', tol, imax);
roots_newton = find_roots(f, df, intervals, 'newton', tol, imax);

% Step 3: Plotting
fprintf('Roots found using Bisection: %.6f\n', roots_bisection);
fprintf('Roots found using Newton: %.6f\n', roots_newton);

plot_roots(f, roots_bisection, x_range);
