AllRoots, indented and functionalized .....
- To: MATHGROUP at yoda.physics.unc.edu, PAUL at earwax.pd.uwa.edu.au
- Subject: AllRoots, indented and functionalized .....
- From: "Mathematical Institute, (0865) 2-73525" <AKYILDIZ at vax.ox.ac.uk>
- Date: Sat, 10 Oct 92 16:42 BST
(* WARNING..... The built in function Real Interval is not (yet) bug-free. For example, in Allan Hayes' code, f and (a-b) must be padded by N. Programme below will also work with symbolic, i.e. Pi, interval limits as well. Thanks go to A.W. Wickstead of Queens Univ., Belfast and Allan Hayes of Leicester Univ.. Yilmaz Akyildiz *) 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]}; intbisecF[f_Function, a_, b_, tol_] := With[ {step = Select[(bisect/@#)//Flatten, containszero[N[f[#]]]&]& }, Nest[step, {RealInterval[N[{a,b}]]}, Ceiling[Log[2,N[(b-a)]/tol]]] ];