-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Fast robust numeric integration via tanh-sinh quadrature
--   
--   Fast robust numeric integration via tanh-sinh quadrature
@package integration
@version 0.2.1


-- | An implementation of Takahashi and Mori's <a>Tanh-Sinh quadrature</a>.
--   
--   Tanh-Sinh provides good results across a wide-range of functions and
--   is pretty much as close to a universal quadrature scheme as is
--   possible. It is also robust against error in the presence of
--   singularities at the endpoints of the integral.
--   
--   The change of basis is precomputed, and information is gained
--   quadratically in the number of digits.
--   
--   <pre>
--   ghci&gt; absolute 1e-6 $ parTrap sin (pi/2) pi
--   Result {result = 0.9999999999999312, errorEstimate = 2.721789573237518e-10, evaluations = 25}
--   </pre>
--   
--   <pre>
--   ghci&gt; confidence $ absolute 1e-6 $ trap sin (pi/2) pi
--   (0.9999999997277522,1.0000000002721101)
--   </pre>
--   
--   Unlike most quadrature schemes, this method is also fairly robust
--   against singularities at the end points.
--   
--   <pre>
--   ghci&gt; absolute 1e-6 $ trap (recip . sqrt . sin) 0 1
--   Result {result = 2.03480500404275, errorEstimate = 6.349514558579017e-8, evaluations = 49}
--   </pre>
--   
--   See John D. Cook's <a>"Care and Treatment of Singularities"</a> for a
--   sense of how more naïve quadrature schemes fare.
module Numeric.Integration.TanhSinh

-- | Integration using a truncated trapezoid rule under tanh-sinh
--   quadrature
trap :: (Double -> Double) -> Double -> Double -> [Result]

-- | Integration using a truncated Simpson's rule under tanh-sinh
--   quadrature
simpson :: (Double -> Double) -> Double -> Double -> [Result]

-- | Integration using a truncated trapezoid rule and tanh-sinh quadrature
--   with a specified evaluation strategy
trap' :: Strategy [Double] -> (Double -> Double) -> Double -> Double -> [Result]

-- | Integration using a truncated Simpson's rule under tanh-sinh
--   quadrature with a specified evaluation strategy
simpson' :: Strategy [Double] -> (Double -> Double) -> Double -> Double -> [Result]

-- | Integration using a truncated trapezoid rule under tanh-sinh
--   quadrature with buffered parallel evaluation
parTrap :: (Double -> Double) -> Double -> Double -> [Result]

-- | Integration using a truncated Simpson's rule under tanh-sinh
--   quadrature with buffered parallel evaluation
parSimpson :: (Double -> Double) -> Double -> Double -> [Result]

-- | Integral with an result and an estimate of the error such that
--   <tt>(result - errorEstimate, result + errorEstimate)</tt>
--   <i>probably</i> bounds the actual answer.
data Result
Result :: {-# UNPACK #-} !Double -> {-# UNPACK #-} !Double -> {-# UNPACK #-} !Int -> Result
[result] :: Result -> {-# UNPACK #-} !Double
[errorEstimate] :: Result -> {-# UNPACK #-} !Double
[evaluations] :: Result -> {-# UNPACK #-} !Int

-- | Filter a list of results using a specified absolute error bound
absolute :: Double -> [Result] -> Result

-- | Filter a list of results using a specified relative error bound
relative :: Double -> [Result] -> Result

-- | Convert a Result to a confidence interval
confidence :: Result -> (Double, Double)

-- | Integrate a function from 0 to infinity by using the change of
--   variables <tt>x = t/(1-t)</tt>
--   
--   This works <i>much</i> better than just clipping the interval at some
--   arbitrary large number.
nonNegative :: ((Double -> Double) -> Double -> Double -> r) -> (Double -> Double) -> r

-- | Integrate from -inf to inf using tanh-sinh quadrature after using the
--   change of variables <tt>x = tan t</tt>
--   
--   <pre>
--   everywhere trap (\x -&gt; exp(-x*x))
--   </pre>
--   
--   This works <i>much</i> better than just clipping the interval at
--   arbitrary large and small numbers.
everywhere :: ((Double -> Double) -> Double -> Double -> r) -> (Double -> Double) -> r
instance GHC.Show.Show Numeric.Integration.TanhSinh.DD
instance GHC.Classes.Ord Numeric.Integration.TanhSinh.Result
instance GHC.Classes.Eq Numeric.Integration.TanhSinh.Result
instance GHC.Show.Show Numeric.Integration.TanhSinh.Result
instance GHC.Read.Read Numeric.Integration.TanhSinh.Result
