úÎ](YD           .General interface for numerical root finders. initRootFinder f x0 x1): Initialize a root finder for the given 8 function with the initial bracketing interval (x0,x1). CStep a root finder for the given function (which should generally  be the same one passed to initRootFinder), refining the finder's % estimate of the location of a root. Extract the finder'.s current estimate of the position of a root. Extract the finder'.s current estimate of the upper bound of the  distance from  estimateRoot$ to an actual root in the function.  Generally, estimateRoot r +- estimateError r should bracket  a root of the function. @Test whether a root finding algorithm has converged to a given  relative accuracy. ADefault number of steps after which root finding will be deemed D to have failed. Purely a convenience used to control the behavior  of built-in functions such as  and . The  default value is 250. traceRoot f x0 x1 mbEps* initializes a root finder and repeatedly M steps it, returning each step of the process in a list. When the algorithm  terminates or the # limit is exceeded, the list ends. ! Termination criteria depends on mbEps; if it is of the form Just eps  then convergence to eps is used (using the  converged method of the H root finder). Otherwise, the trace is not terminated until subsequent  states are equal (according to &). This is a stricter condition than L convergence to 0; subsequent states may have converged to zero but as long 8 as any internal state changes the trace will continue. findRoot f x0 x1 eps* initializes a root finder and repeatedly , steps it. When the algorithm converges to eps or the  A limit is exceeded, the current best guess is returned, with the Right 6 constructor indicating successful convergence or the Left constructor ! indicating failure to converge. A useful constant:   is (for most  types) the smallest  positive number such that 1 + eps /= 1.     7Bisect an interval in search of a root. At all times, f (estimateRoot _)  is less than or equal to 0 and $f (estimateRoot _ + estimateError _) is  greater than or equal to 0.  !" MUsing bisection, return a root of a function known to lie between x1 and x2. N The root will be refined till its accuracy is +-xacc. If convergence fails, ( returns the final state of the search.     # dekker f x1 x2 xacc2: attempt to find a root of a function known to $ lie between x1 and x2, using Dekker'$s method. The root will be refined G till its accuracy is +-xacc. If convergence fails, returns the final  state of the search. $%IIncorporates a new point, maintaining invariant 1, assuming invariant 3,  and using & to restore invariant 2. &#Re-establishes invariant 2 (abs fb <0= abs fa) without affecting invariants 1 and 3.     0Iteratively refine a bracketing interval [x1, x2] of a root of f H until total convergence (which may or may not ever be achieved) using  the false-position method. '()*+,-falsePosition f x1 x2 xacc-: Using the false-position method, return a J root of a function known to lie between x1 and x2. The root is refined  until its accuracy is += xacc. .inverseQuadratic f x1 x2 xacc): attempt to find a root of a function L known to lie between x1 and x2, using the inverse quadratic interpolation D method. The root will be refined till its accuracy is +-xacc. If ; convergence fails, returns the final state of the search. /01newton f x1 x2 xacc: using Newton's method, return a root of a I function known to lie between x1 and x2. The root is refined until its  accuracy is += xacc. EThe function passed should return a pair containing the value of the , function and its derivative, respectively. 234567ridders f x1 x2 xacc2: attempt to find a root of a function known to % lie between x1 and x2, using Ridders'# method. The root will be refined G till its accuracy is +-xacc. If convergence fails, returns the final  state of the search.  BIteratively refine 2 estimates x1, x2 of a root of f until total ? convergence (which may or may not ever be achieved) using the  secant method. 89:;<=>secant f x1 x2 xacc0: Using the secant method, return the root of a K function thought to lie between x1 and x2. The root is refined until its  accuracy is +-xacc.  Predicate that returns ?, whenever the given pair of points brackets  a root of the given function. bracket f x1 x2:: Given a function and an initial guessed range x1 to x2, M this function expands the range geometrically until a root is bracketed by N the returned values, returning a list of the successively expanded ranges. O The list will be finite if and only if the sequence yields a bracketing pair. subdivideAndBracket f x1 x2 n+: Given a function defined on the interval  [x1,x2]D, subdivide the interval into n equally spaced segments and search J for zero crossings of the function. The returned list will contain all  bracketing pairs found.  Working state for Brent's root-finding method. @ABCDEFGbrent f x1 x2 xacc2: attempt to find a root of a function known to # lie between x1 and x2, using Brent'$s method. The root will be refined G till its accuracy is +-xacc. If convergence fails, returns the final  state of the search. H>Updates the state by incorporating a new estimate and setting G,  maintaining all invariants. IJKIdebugging function to show a nice trace of the progress of the algorithm L    !" # $ % & '()*(+,-./0123456789:;<=>?!@ABCDEFGH & I J K L M N O P Q R ST roots-0.1Math.Root.FinderMath.Root.Finder.BisectionMath.Root.Finder.DekkerMath.Root.Finder.FalsePosition!Math.Root.Finder.InverseQuadraticMath.Root.Finder.NewtonMath.Root.Finder.RiddersMath.Root.Finder.SecantMath.Root.BracketMath.Root.Finder.Brent RootFinderinitRootFinderstepRootFinder estimateRoot estimateError converged defaultNSteps traceRootfindRootepsBisect bisectionDekkerdekker FalsePosition falsePositionInverseQuadraticinverseQuadraticNewtonnewton RiddersMethodridders SecantMethodsecantbracketsbracketsubdivideAndBracketBrentbrentbase GHC.Classes== GHC.Float RealFloat_bisX_bisF_bisDXbetweenstepacceptfpRootfpDX_fpXL_fpFL_fpXH_fpFHnewtRTNnewtDXridXL_ridFLridXH_ridFHConvergedRidderssecDXsecXL_secFL_secRTS_secFRTSConvergedSecantMethodghc-primGHC.BoolTruebrAbrFAbrBbrFBbrCbrFCbrEupdatefixSigns fixMagnitudes _traceBrent