math-functions 0.3.0.2 → 0.3.1.0
raw patch · 4 files changed
+16/−107 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Numeric.RootFinding: NewtonBisection :: !Double -> !Double -> NewtonStep
+ Numeric.RootFinding: NewtonNoBracket :: NewtonStep
+ Numeric.RootFinding: NewtonRoot :: !Double -> NewtonStep
+ Numeric.RootFinding: NewtonStep :: !Double -> !Double -> NewtonStep
+ Numeric.RootFinding: RiddersBisect :: !Double -> !Double -> RiddersStep
+ Numeric.RootFinding: RiddersNoBracket :: RiddersStep
+ Numeric.RootFinding: RiddersRoot :: !Double -> RiddersStep
+ Numeric.RootFinding: RiddersStep :: !Double -> !Double -> RiddersStep
+ Numeric.RootFinding: data NewtonStep
+ Numeric.RootFinding: data RiddersStep
- Numeric.Polynomial: evaluateEvenPolynomialL :: (Num a) => a -> [a] -> a
+ Numeric.Polynomial: evaluateEvenPolynomialL :: Num a => a -> [a] -> a
- Numeric.Polynomial: evaluateOddPolynomialL :: (Num a) => a -> [a] -> a
+ Numeric.Polynomial: evaluateOddPolynomialL :: Num a => a -> [a] -> a
- Numeric.Polynomial: evaluatePolynomialL :: (Num a) => a -> [a] -> a
+ Numeric.Polynomial: evaluatePolynomialL :: Num a => a -> [a] -> a
- Numeric.Polynomial.Chebyshev: chebyshev :: (Vector v Double) => Double -> v Double -> Double
+ Numeric.Polynomial.Chebyshev: chebyshev :: Vector v Double => Double -> v Double -> Double
- Numeric.Polynomial.Chebyshev: chebyshevBroucke :: (Vector v Double) => Double -> v Double -> Double
+ Numeric.Polynomial.Chebyshev: chebyshevBroucke :: Vector v Double => Double -> v Double -> Double
- Numeric.Sum: pairwiseSum :: (Vector v Double) => v Double -> Double
+ Numeric.Sum: pairwiseSum :: Vector v Double => v Double -> Double
- Numeric.Sum: sum :: (Summation s, (Foldable f)) => (s -> Double) -> f Double -> Double
+ Numeric.Sum: sum :: (Summation s, Foldable f) => (s -> Double) -> f Double -> Double
Files
- Numeric/RootFinding.hs +8/−4
- changelog.md +7/−0
- math-functions.cabal +1/−1
- tests/view.hs +0/−102
Numeric/RootFinding.hs view
@@ -30,10 +30,12 @@ , RiddersParam(..) , ridders , riddersIterations+ , RiddersStep(..) -- * Newton-Raphson algorithm , NewtonParam(..) , newtonRaphson , newtonRaphsonIterations+ , NewtonStep(..) -- * References -- $references ) where@@ -172,9 +174,10 @@ -- | Parameters for 'ridders' root finding data RiddersParam = RiddersParam { riddersMaxIter :: !Int- -- ^ Maximum number of iterations.+ -- ^ Maximum number of iterations. Default = 100 , riddersTol :: !Tolerance- -- ^ Error tolerance for root approximation.+ -- ^ Error tolerance for root approximation. Default is relative+ -- error 4·ε, where ε is machine precision. } deriving (Eq, Read, Show, Typeable, Data #if __GLASGOW_HASKELL__ > 704@@ -287,9 +290,10 @@ -- | Parameters for 'ridders' root finding data NewtonParam = NewtonParam { newtonMaxIter :: !Int- -- ^ Maximum number of iterations.+ -- ^ Maximum number of iterations. Default = 50 , newtonTol :: !Tolerance- -- ^ Error tolerance for root approximation.+ -- ^ Error tolerance for root approximation. Default is relative+ -- error 4·ε, where ε is machine precision } deriving (Eq, Read, Show, Typeable, Data #if __GLASGOW_HASKELL__ > 704
changelog.md view
@@ -1,3 +1,10 @@+## Changes in 0.3.1.0++ * Exported data types for iteration steps in root finding++ * Defaults for root finding algorithm are documented++ ## Changes in 0.3.0.2 * Fix license field in cabal file
math-functions.cabal view
@@ -1,5 +1,5 @@ name: math-functions-version: 0.3.0.2+version: 0.3.1.0 cabal-version: >= 1.10 license: BSD2 license-file: LICENSE
− tests/view.hs
@@ -1,102 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}-import Control.Applicative-import Control.Monad-import Numeric.SpecFunctions-import Numeric.MathFunctions.Constants-import CPython.Sugar-import CPython.MPMath-import qualified CPython as Py--import HEP.ROOT.Plot----------------------------------------------------------------------viewBetaDelta = runPy $ do- addToPythonPath "."- m <- loadMPMath- mpmSetDps m 100- xs <- forM pqBeta $ \(p,q) -> do x <- fromMPNum =<< mpmLog m =<< mpmBeta m (MPDouble p) (MPDouble q)- return (p,q, relErr x (logBeta p q))- draws $ do- -- let xs = [ (p,q, logBeta p q `relErr` (logGammaL p + logGammaL q - logGammaL (q+p)))- -- | (p,q) <- pqBeta- -- ]- add $ Graph2D xs---pqBeta = [ (p,q)- | p <- logRange 50 0.3 0.6- , q <- logRange 50 5 6- ]- where-----viewIBeta x = runPy $ do- addToPythonPath "."- m <- loadMPMath- mpmSetDps m 30- --- let n = 40- let pq = (,)- <$> logRange n 100 1000- <*> logRange n 100 1000- --- xs <- forM pq $ \(p,q) -> do- i <- fromMPNum =<< mpmIncompleteBeta m (MPDouble p) (MPDouble q) (MPDouble x)- return (p,q, incompleteBeta p q x `relErr` i)- --- draws $ do- add $ Graph2D xs---go = runPy $ do- addToPythonPath "."- m <- loadMPMath- mpmSetDps m 16- --- print =<< fromMPNum =<< mpmIncompleteBeta m (MPDouble 10) (MPDouble 10) (MPDouble 0.4)- print $ incompleteBeta 10 10 0.4-----viewLancrox = runPy $ do- addToPythonPath "."- m <- loadMPMath- mpmSetDps m 50- --- let xs = logRange 10000 (1e-8) (1e-1)- pl <- forM xs $ \x -> do y0 <- fromMPNum =<< mpmLog m =<< mpmGamma m (MPDouble x)- return (x, y0)- draws $ do- add $ Graph $ [ (x, abs $ y `relErr` logGammaL x) | (x,y) <- pl ]- set $ lineColor RED- --- add $ Graph $ [ (x, abs $ y `relErr` logGamma x) | (x,y) <- pl ]- set $ lineColor BLUE- --- set $ xaxis $ logScale ON- -- set $ yaxis $ logScale ON- --- add $ HLine m_epsilon- add $ HLine $ negate m_epsilon---------------------------------------------------------------------relErr :: Double -> Double -> Double-relErr 0 0 = 0-relErr x y = (x - y) / max (abs x) (abs y)----logRange :: Int -> Double -> Double -> [Double]-logRange n a b- = [ a * r^i | i <- [0 .. n] ]- where- r = (b / a) ** (1 / fromIntegral n)-