X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FIntegration%2FTrapezoid.hs;h=06350fcf54a70da55ac317610c1a7dca2f3b8a62;hb=c160f3101ddb9797fd30007d6f628da394628538;hp=444d92d2eb9a0ed2e6911970f54cd88aafd71b3a;hpb=2f54e89d36e835c58efcc281741632d457859b20;p=numerical-analysis.git diff --git a/src/Integration/Trapezoid.hs b/src/Integration/Trapezoid.hs index 444d92d..06350fc 100644 --- a/src/Integration/Trapezoid.hs +++ b/src/Integration/Trapezoid.hs @@ -38,8 +38,9 @@ trapezoid_1 :: (Field.C a, ToRational.C a, Field.C b) -> a -- ^ The \"right\" endpoint, @b@ -> b trapezoid_1 f a b = - (((f a) + (f b)) / 2) * (fromRational' $ toRational (b - a)) - + (((f a) + (f b)) / 2) * coerced_interval_length + where + coerced_interval_length = fromRational' $ toRational (b - a) -- | Use the composite trapezoid rule to numerically integrate @f@ -- over @n@ subintervals of [@a@, @b@].