+{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE RebindableSyntax #-}
-module Integration.Simpson
+module Integration.Simpson (
+ simpson,
+ simpson_1 )
where
-import Misc (partition)
+import Misc ( partition )
-import NumericPrelude hiding (abs)
-import qualified Algebra.RealField as RealField
-import qualified Algebra.ToInteger as ToInteger
-import qualified Algebra.ToRational as ToRational
+import NumericPrelude hiding ( abs )
+import qualified Algebra.RealField as RealField ( C )
+import qualified Algebra.ToInteger as ToInteger ( C )
+import qualified Algebra.ToRational as ToRational ( C )
-- | Use the Simpson's rule to numerically integrate @f@ over the
-- interval [@a@, @b@].
simpson_1 f a b =
coefficient * ((f a) + 4*(f midpoint) + (f b))
where
- coefficient = (fromRational' $ toRational (b - a)) / 6
+ coefficient = fromRational' $ (toRational (b - a)) / 6
midpoint = (a + b) / 2