Skip to content

Commit

Permalink
update the documentation
Browse files Browse the repository at this point in the history
The streams might be finite.
  • Loading branch information
Borgvall committed Feb 18, 2012
1 parent 51bdf34 commit 69842ab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
11 changes: 8 additions & 3 deletions Numeric/AD/Halley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ import Numeric.AD.Internal.Composition

-- | The 'findZero' function finds a zero of a scalar function using
-- Halley's method; its output is a stream of increasingly accurate
-- results. (Modulo the usual caveats.)
-- results. (Modulo the usual caveats.) If the stream becomes constant
-- ("it converges"), no further elements are returned.
--
-- Examples:
--
Expand All @@ -60,7 +61,8 @@ findZero f = go

-- | The 'inverse' function inverts a scalar function using
-- Halley's method; its output is a stream of increasingly accurate
-- results. (Modulo the usual caveats.)
-- results. (Modulo the usual caveats.) If the stream becomes constant
-- ("it converges"), no further elements are returned.
--
-- Note: the @take 10 $ inverse sqrt 1 (sqrt 10)@ example that works for Newton's method
-- fails with Halley's method because the preconditions do not hold.
Expand All @@ -72,6 +74,8 @@ inverse f x0 y = findZero (\x -> f x - lift y) x0
-- | The 'fixedPoint' function find a fixedpoint of a scalar
-- function using Halley's method; its output is a stream of
-- increasingly accurate results. (Modulo the usual caveats.)
-- If the stream becomes constant ("it converges"), no further
-- elements are returned.
--
-- > take 10 $ fixedPoint cos 1 -- converges to 0.7390851332151607
fixedPoint :: (Fractional a, Eq a) => UU a -> a -> [a]
Expand All @@ -80,7 +84,8 @@ fixedPoint f = findZero (\x -> f x - x)

-- | The 'extremum' function finds an extremum of a scalar
-- function using Halley's method; produces a stream of increasingly
-- accurate results. (Modulo the usual caveats.)
-- accurate results. (Modulo the usual caveats.) If the stream becomes
-- constant ("it converges"), no further elements are returned.
--
-- > take 10 $ extremum cos 1 -- convert to 0
extremum :: (Fractional a, Eq a) => UU a -> a -> [a]
Expand Down
11 changes: 8 additions & 3 deletions Numeric/AD/Newton.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ import Numeric.AD.Internal.Composition

-- | The 'findZero' function finds a zero of a scalar function using
-- Newton's method; its output is a stream of increasingly accurate
-- results. (Modulo the usual caveats.)
-- results. (Modulo the usual caveats.) If the stream becomes constant
-- ("it converges"), no further elements are returned.
--
-- Examples:
--
Expand All @@ -57,7 +58,8 @@ findZero f = go

-- | The 'inverseNewton' function inverts a scalar function using
-- Newton's method; its output is a stream of increasingly accurate
-- results. (Modulo the usual caveats.)
-- results. (Modulo the usual caveats.) If the stream becomes
-- constant ("it converges"), no further elements are returned.
--
-- Example:
--
Expand All @@ -70,6 +72,8 @@ inverse f x0 y = findZero (\x -> f x - lift y) x0
-- | The 'fixedPoint' function find a fixedpoint of a scalar
-- function using Newton's method; its output is a stream of
-- increasingly accurate results. (Modulo the usual caveats.)
-- If the stream becomes constant ("it converges"), no further
-- elements are returned.
--
-- > take 10 $ fixedPoint cos 1 -- converges to 0.7390851332151607
fixedPoint :: (Fractional a, Eq a) => UU a -> a -> [a]
Expand All @@ -78,7 +82,8 @@ fixedPoint f = findZero (\x -> f x - x)

-- | The 'extremum' function finds an extremum of a scalar
-- function using Newton's method; produces a stream of increasingly
-- accurate results. (Modulo the usual caveats.)
-- accurate results. (Modulo the usual caveats.) If the stream
-- becomes constant ("it converges"), no further elements are returned.
--
-- > take 10 $ extremum cos 1 -- convert to 0
extremum :: (Fractional a, Eq a) => UU a -> a -> [a]
Expand Down

0 comments on commit 69842ab

Please sign in to comment.