The user gives an interval and the program tries to find all the roots of a function in this interval, doing all the guesses automatically.

Each time the program calls the built-in solver (with Guess in the middle of an interval) and finds a root or extremum, a new interval is submitted (with new Lower and Upper bounds) and, if necessary, another one is put on a stack for later use (PUSH).

If an interval is too small (the user defines tolerance xtol) or if the built-in solvers does not returns a root or extremum, the next interval is taken from the stack (POP), until the stack is empty.

If the built-in solver returns a root (or extremum), the program displays it (if root) and explores these cases:

Case 1: Lower+xtol < Root/Extremum < Guess < Upper:

"Assume" that Interval(Root/Extremum,Guess) is empty (what a shame:)
PUSH Interval(Lower,Root/Extremum)
SOLVE with guess in the middle of Interval(Guess,Upper)

Case 2: Lower < Guess < Root/Extremum < Upper-xtol

"Assume" that Interval(Guess,Root/extremum) is empty (what a shame:)
PUSH Interval(Lower,Guess)
SOLVE with guess in the middle of Interval(Root/Extremum,Upper)

Case 3: Lower < Guess < Upper-xtol <= Root/extremum

"Assume" Interval(Guess,Upper) is empty (what a shame:)
SOLVE with guess in the middle of Interval(Lower,Guess)

Case 4: Root/Extremum <= Lower+xtol < Guess < Upper

"Assume" Interval(Lower,Guess) is empty (what a shame:)
SOLVE with guess in the middle of Interval(Guess,Upper)

IN the subroutine called by the built-in solver for evaluating the function to solve, I added code to more quickly round the function to 0 or detect extremum (f(x) very close to previous one) (the user defines tolerance ytol). A root or extremum will be then more easily found by the built-in solver.

This lazy algorithm seems to be working and useful for a quick tour of the roots of a "well-behaved" function.

For finding the roots of sin(x) in [-10,10], with xtol=1E-3 and ytol=1E-15, on Free42, this algorithm quickly finds the 7 roots and needed at most 3 intervals on stack and ... hum ... 95 calls to solver (what a shame :).