Statistics.Math.RootFinding

statistics-0.13.3.0: A library of statistical types, data, and functions

Copyright | (c) 2011 Bryan O'Sullivan
License | BSD3
Maintainer | bos@serpentine.com
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell98

Statistics.Math.RootFinding

Contents

- References

Description

Haskell functions for finding the roots of mathematical functions.

Synopsis

- data Root a
  - = NotBracketed
  - | SearchFailed
  - | Root a
- fromRoot :: a -> Root a -> a
- ridders :: Double -> (Double, Double) -> (Double -> Double) -> Root Double

# Documentation

data Root a #

The result of searching for a root of a mathematical function.

Constructors

NotBracketed | The function does not have opposite signs when evaluated at the lower and upper bounds of the search.
SearchFailed | The search failed to converge to within the given error tolerance after the given number of iterations.
Root a | A root was successfully found.

Instances

Monad Root # |
Methods (>>=) :: Root a -> (a -> Root b) -> Root b # (>>) :: Root a -> Root b -> Root b # return :: a -> Root a # fail :: String -> Root a #
Functor Root # |
Methods fmap :: (a -> b) -> Root a -> Root b # (<$) :: a -> Root b -> Root a #
Applicative Root # |
Methods pure :: a -> Root a # (<*>) :: Root (a -> b) -> Root a -> Root b # (*>) :: Root a -> Root b -> Root b # (<*) :: Root a -> Root b -> Root a #
Alternative Root # |
Methods empty :: Root a # (<|>) :: Root a -> Root a -> Root a # some :: Root a -> Root [a] # many :: Root a -> Root [a] #
MonadPlus Root # |
Methods mzero :: Root a # mplus :: Root a -> Root a -> Root a #
Eq a => Eq (Root a) # |
Methods (==) :: Root a -> Root a -> Bool # (/=) :: Root a -> Root a -> Bool #
Data a => Data (Root a) # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Root a -> c (Root a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Root a) # toConstr :: Root a -> Constr # dataTypeOf :: Root a -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (Root a)) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Root a)) # gmapT :: (forall b. Data b => b -> b) -> Root a -> Root a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Root a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Root a -> r # gmapQ :: (forall d. Data d => d -> u) -> Root a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Root a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Root a -> m (Root a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Root a -> m (Root a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Root a -> m (Root a) #
Read a => Read (Root a) # |
Methods readsPrec :: Int -> ReadS (Root a) # readList :: ReadS [Root a] # readPrec :: ReadPrec (Root a) # readListPrec :: ReadPrec [Root a] #
Show a => Show (Root a) # |
Methods showsPrec :: Int -> Root a -> ShowS # show :: Root a -> String # showList :: [Root a] -> ShowS #
Generic (Root a) # |
Associated Types type Rep (Root a) :: * -> * # Methods from :: Root a -> Rep (Root a) x # to :: Rep (Root a) x -> Root a #
FromJSON a => FromJSON (Root a) # |
Methods parseJSON :: Value -> Parser (Root a) # parseJSONList :: Value -> Parser [Root a] #
ToJSON a => ToJSON (Root a) # |
Methods toJSON :: Root a -> Value # toEncoding :: Root a -> Encoding # toJSONList :: [Root a] -> Value # toEncodingList :: [Root a] -> Encoding #
Binary a => Binary (Root a) # |
Methods put :: Root a -> Put # get :: Get (Root a) # putList :: [Root a] -> Put #
type Rep (Root a) # |
type Rep (Root a) = D1 (MetaData "Root" "Statistics.Math.RootFinding" "statistics-0.13.3.0-A6M5lvDj6Zg1bzI7OU7tSj" False) ((:+:) (C1 (MetaCons "NotBracketed" PrefixI False) U1) ((:+:) (C1 (MetaCons "SearchFailed" PrefixI False) U1) (C1 (MetaCons "Root" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))))

fromRoot #

Arguments

:: a | Default value.
-> Root a | Result of search for a root.
-> a |

Returns either the result of a search for a root, or the default value if the search failed.

ridders #

Arguments

:: Double | Absolute error tolerance.
-> (Double, Double) | Lower and upper bounds for the search.
-> (Double -> Double) | Function to find the roots of.
-> Root Double |

Use the method of Ridders to compute a root of a function.

The function must have opposite signs when evaluated at the lower and upper bounds of the search (i.e. the root must be bracketed).

# References

- Ridders, C.F.J. (1979) A new algorithm for computing a single root of a real continuous function. IEEE Transactions on Circuits and Systems 26:979–980.