
On Fri, 30 Sep 2005, Lanny Ripple wrote:
newton_h, next_x_h, dy_h :: (Fractional a, Ord a) => (a -> a) -> a -> a -> a newton_h f x h = until ((<= h) . abs . f) (next_x_h f h) x
If this shall be more than a disposable example, I suggest to separate the Newton iteration from the abort of the iteration. Newton's method could return a list of the interim results, a sequence in the mathematical sense. newton :: Fractional a => (a -> (a,a)) -> a -> [a] The function would compute both the value and the derivative, e.g. (\x -> (sin x, cos x)) Then you can easily apply various implementations of a numeric limit. limit :: [a] -> a The most simple implementation is certainly: limit = (!!100) Eventually a function numericDiff :: Fractional a => a -> (a -> a) -> (a -> (a,a)) could extend a function by some difference quotient.