AllRoots
- To: mathgroup at yoda.physics.unc.edu
 - Subject: AllRoots
 - From: akyildiz at maths.ox.ac.uk ( Yilmaz Akyildiz tel 2-73558)
 - Date: Mon, 19 Oct 92 11:27:13 BST
 
(*
The previous  version of the programme does not work for the initial
interval [0, 2 Pi].
It must be because of the limitations with RealInterval.
One way to get around this problem is to fatten the initial interval 
a bit in case it involves symbolic numbers.
The following version is OK now.
akyildiz at maths.oxford.ac.uk
*)
lefthalf[RealInterval[{x_, y_}]]    := RealInterval[{x,(x+y)/2.}];             
righthalf[RealInterval[{x_, y_}]]   := RealInterval[{(x+y)/2.,y}];             
containszero[RealInterval[{x_,y_}]] :=  (x <= 0 <= y);                         
bisect[int_RealInterval]            := {lefthalf[int],righthalf[int]};         
									       
									       
intbisec[f_, a_, b_, tol_] :=                                         
   With[                                                                       
      {step =   Select[(bisect/@#)//Flatten, containszero[N[f[#]]]&]& },          
      Nest[step, {RealInterval[N[{a-tol/2.,b+tol/2.}]]}, 
					Ceiling[Log[2,N[(b-a)]/tol]]]             
	  ];