Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1992

[Date Index] [Thread Index] [Author Index]

Search the Archive


  • To: mathgroup <mathgroup at>
  • Subject: Re:AllRoots
  • From: HAY at
  • Date: Sat, 10 OCT 92 00:39:22 GMT

RE the recent note from akyildiz at

A more functional form of the code is

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]};

step[f_][{ints__RealInterval}] := 
   Select[(bisect/@{ints})//Flatten, containszero[f[#]]&];
intbisecF[f_Function, a_, b_, tol_] :=
   Nest[step[f], {RealInterval[{a,b}]}, Ceiling[Log[2,(b-a)/tol]]];


It might be better style to combine the last two functions:

intbisecF[f_Function, a_, b_, tol_] :=
      {step =	Select[(bisect/@#)//Flatten, containszero[f[#]]&]& },
      Nest[step, {RealInterval[{a,b}]}, Ceiling[Log[2,(b-a)/tol]]]

These seem to take about 75% of the time: the second form is marginally quicker
than the first

Allan Hayes
Department of Mathematics
The University
Leicester LE1 7RH
hay at

  • Prev by Date: Fortran Format
  • Next by Date: Memory management by Share[]?
  • Previous by thread: AllRoots
  • Next by thread: AllRoots