h*t#o      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~0.9.3 Safe-Inferred7(c) Edward Kmett 2010-2013BSD3ekmett@gmail.com experimentalDeriveDataTypeable Safe-Inferred7<#2 intervalsThe whole real number linewhole-Infinity ... Infinity intervalsAn empty intervalemptyEmpty intervalsCheck if an interval is emptynull (1 ... 5)Falsenull (1 ... 1)False null emptyTrue intervalsA singleton point singleton 11 ... 1 intervals(The infimum (lower bound) of an intervalinf (1.0 ... 20.0)1.0 inf empty*** Exception: empty interval intervals)The supremum (upper bound) of an intervalsup (1.0 ... 20.0)20.0 sup empty*** Exception: empty interval intervalsIs the interval a singleton point? N.B. This is fairly fragile and likely will not hold after even a few operations that only involve singletonssingular (singleton 1)Truesingular (1.0 ... 20.0)False intervals#Calculate the width of an interval.width (1 ... 20)19width (singleton 1)0 width empty0 intervals Magnitudemagnitude (1 ... 20)20magnitude (-20 ... 10)20magnitude (singleton 5)5throws  if the interval is empty.magnitude empty*** Exception: empty interval intervals "mignitude"mignitude (1 ... 20)1mignitude (-20 ... 10)0mignitude (singleton 5)5throws  if the interval is empty.mignitude empty*** Exception: empty interval intervals%Hausdorff distance between intervals.distance (1 ... 7) (6 ... 10)0distance (1 ... 7) (15 ... 24)8distance (1 ... 7) (-10 ... -2)3distance Empty (1 ... 1)*** Exception: empty interval intervals1Inflate an interval by enlarging it at both ends.inflate 3 (-1 ... 7) -4 ... 10inflate (-2) (0 ... 4)-2 ... 6inflate 1 emptyEmpty  intervals3Deflate an interval by shrinking it from both ends.deflate 3.0 (-4.0 ... 10.0) -1.0 ... 7.0deflate 2.0 (-1.0 ... 1.0)Emptydeflate 1.0 emptyEmpty! intervals%Scale an interval about its midpoint.scale 1.1 (-6.0 ... 4.0) -6.5 ... 4.5scale (-2.0) (-1.0 ... 1.0)Emptyscale 3.0 emptyEmpty" intervalsConstruct a symmetric interval. symmetric 3-3 ... 3symmetric (-2)-2 ... 2# intervals#Bisect an interval at its midpoint.bisect (10.0 ... 20.0)(10.0 ... 15.0,15.0 ... 20.0)bisect (singleton 5.0)(5.0 ... 5.0,5.0 ... 5.0) bisect Empty (Empty,Empty)% intervals.Nearest point to the midpoint of the interval.midpoint (10.0 ... 20.0)15.0midpoint (singleton 5.0)5.0midpoint empty*** Exception: empty interval& intervals(Determine if a point is in the interval.member 3.2 (1.0 ... 5.0)Truemember 5 (1.0 ... 5.0)Truemember 1 (1.0 ... 5.0)Truemember 8 (1.0 ... 5.0)Falsemember 5 emptyFalse' intervals4Determine if a point is not included in the intervalnotMember 8 (1.0 ... 5.0)TruenotMember 1.4 (1.0 ... 5.0)False9And of course, nothing is a member of the empty interval.notMember 5 emptyTrue( intervals(Determine if a point is in the interval.elem 3.2 (1.0 ... 5.0)Trueelem 5 (1.0 ... 5.0)Trueelem 1 (1.0 ... 5.0)Trueelem 8 (1.0 ... 5.0)False elem 5 emptyFalse) intervals4Determine if a point is not included in the intervalnotElem 8 (1.0 ... 5.0)TruenotElem 1.4 (1.0 ... 5.0)False9And of course, nothing is a member of the empty interval.notElem 5 emptyTrue intervals9lift a monotone increasing function over a given interval intervals9lift a monotone decreasing function over a given interval* intervals,Calculate the intersection of two intervals.intersection (1 ... 10 :: Interval Double) (5 ... 15 :: Interval Double) 5.0 ... 10.0+ intervals*Calculate the convex hull of two intervalshull (0 ... 10 :: Interval Double) (5 ... 15 :: Interval Double) 0.0 ... 15.0hull (15 ... 85 :: Interval Double) (0 ... 10 :: Interval Double) 0.0 ... 85.0, intervalsFor all x in X, y in Y. x  y?(5 ... 10 :: Interval Double) ! (10 ... 19 :: Interval Double)True?(5 ... 20 :: Interval Double) >! (15 ... 40 :: Interval Double)False1 intervalsFor all x in X, y in Y. x  y(20 ... 40 :: Interval Double) >=! (10 ... 20 :: Interval Double)True(5 ... 20 :: Interval Double) >=! (15 ... 40 :: Interval Double)False2 intervalsFor all x in X, y in Y. x op y3 intervalsCheck if interval X totally contains interval Y(20 ... 40 :: Interval Double) `contains` (25 ... 35 :: Interval Double)True(20 ... 40 :: Interval Double) `contains` (15 ... 35 :: Interval Double)False4 intervalsFlipped version of 3. Check if interval X a subset of interval Y(25 ... 35 :: Interval Double) `isSubsetOf` (20 ... 40 :: Interval Double)True(20 ... 40 :: Interval Double) `isSubsetOf` (15 ... 35 :: Interval Double)False5 intervalsDoes there exist an x in X, y in Y such that x  y?6 intervalsDoes there exist an x in X, y in Y such that x  y?7 intervalsDoes there exist an x in X, y in Y such that x  y?8 intervalsDoes there exist an x in X, y in Y such that x  y?9 intervalsDoes there exist an x in X, y in Y such that x  y?: intervalsDoes there exist an x in X, y in Y such that x  y?; intervalsDoes there exist an x in X, y in Y such that x op y?< intervals*id function. Useful for type specification:t idouble (1 ... 3)$idouble (1 ... 3) :: Interval Double= intervals*id function. Useful for type specification:t ifloat (1 ... 3)"ifloat (1 ... 3) :: Interval Float> intervalsan interval containing all x  y >>> (5  3) & ((4...6) > (2...4)) True >>> (1...10) >* ((-5)...4) *** Exception: divide by zero? intervalsan interval containing all x  y >>> (5  3) & ((4...6) ? (2...4)) True >>> (1...10) ?* ((-5)...4) *** Exception: divide by zero@ intervalsan interval containing all x  y >>> (5  3) & ((4...6) @ (2...4)) True >>> (1...10) @* ((-5)...4) *** Exception: divide by zeroA intervalsan interval containing all x  y >>> (5  3) & ((4...6) A (2...4)) True >>> (1...10) A* ((-5)...4) *** Exception: divide by zeroB intervalsWe have to play some semantic games to make these methods make sense. Most compute with the midpoint of the interval.F intervals will use the midpointJ intervals is +4&'()%*+#$ !"342,-./10;5678:9<=>?@A4&'()%*+#$ !"342,-./10;5678:9<=>?@A63(c) Edward Kmett 2010-2014BSD3ekmett@gmail.com experimentalDeriveDataTypeable Safe-Inferred$2&'()%*+#$ !"342,-./10;5678:9<=>?@A2&'()%*+#$ !"342,-./10;5678:9<=>?@A(c) Edward Kmett 2010-2014BSD3ekmett@gmail.com experimentalDeriveDataTypeable Safe-Inferred7<D5R intervalsCreate a directed interval.S intervals#Try to create a non-empty interval.T intervalsThe whole real number linewhole-Infinity ... InfinityU intervalsAn empty intervalempty NaN ... NaNV intervalsnegation handles NaN properlynull (1 ... 5)Falsenull (1 ... 1)False null emptyTrueW intervalsA singleton point singleton 11 ... 1X intervals*The infinumum (lower bound) of an intervalinf (1 ... 20)1Y intervals)The supremum (upper bound) of an intervalsup (1 ... 20)20Z intervalsIs the interval a singleton point? N.B. This is fairly fragile and likely will not hold after even a few operations that only involve singletonssingular (singleton 1)Truesingular (1.0 ... 20.0)False[ intervals#Calculate the width of an interval.width (1 ... 20)19width (singleton 1)0 width emptyNaN\ intervals Magnitudemagnitude (1 ... 20)20magnitude (-20 ... 10)20magnitude (singleton 5)5] intervals "mignitude"mignitude (1 ... 20)1mignitude (-20 ... 10)0mignitude (singleton 5)5mignitude emptyNaN^ intervals/Hausdorff distance between non-empty intervals.distance (1 ... 7) (6 ... 10)0distance (1 ... 7) (15 ... 24)8distance (1 ... 7) (-10 ... -2)3distance empty (1 ... 1)NaN_ intervals1Inflate an interval by enlarging it at both ends.inflate 3 (-1 ... 7) -4 ... 10inflate (-2) (0 ... 4)2 ... 2` intervals3Deflate an interval by shrinking it from both ends.deflate 3.0 (-4.0 ... 10.0) -1.0 ... 7.0deflate 2.0 (-1.0 ... 1.0) 1.0 ... -1.0a intervals%Scale an interval about its midpoint.scale 1.1 (-6.0 ... 4.0) -6.5 ... 4.5scale (-2.0) (-1.0 ... 1.0) 2.0 ... -2.0b intervalsConstruct a symmetric interval. symmetric 3-3 ... 3symmetric (-2)2 ... -2c intervals#Bisect an interval at its midpoint.bisect (10.0 ... 20.0)(10.0 ... 15.0,15.0 ... 20.0)bisect (singleton 5.0)(5.0 ... 5.0,5.0 ... 5.0) bisect empty(NaN ... NaN,NaN ... NaN)d intervals.Nearest point to the midpoint of the interval.midpoint (10.0 ... 20.0)15.0midpoint (singleton 5.0)5.0midpoint emptyNaNe intervals(Determine if a point is in the interval.member 3.2 (1.0 ... 5.0)Truemember 5 (1.0 ... 5.0)Truemember 1 (1.0 ... 5.0)Truemember 8 (1.0 ... 5.0)Falsemember 5 emptyFalsef intervals4Determine if a point is not included in the intervalnotMember 8 (1.0 ... 5.0)TruenotMember 1.4 (1.0 ... 5.0)False9And of course, nothing is a member of the empty interval.notMember 5 emptyTrueg intervals(Determine if a point is in the interval.elem 3.2 (1.0 ... 5.0)Trueelem 5 (1.0 ... 5.0)Trueelem 1 (1.0 ... 5.0)Trueelem 8 (1.0 ... 5.0)False elem 5 emptyFalseh intervals4Determine if a point is not included in the intervalnotElem 8 (1.0 ... 5.0)TruenotElem 1.4 (1.0 ... 5.0)False9And of course, nothing is a member of the empty interval.notElem 5 emptyTrue intervals9lift a monotone increasing function over a given interval intervals9lift a monotone decreasing function over a given intervali intervals,Calculate the intersection of two intervals.intersection (1 ... 10 :: Interval Double) (5 ... 15 :: Interval Double) 5.0 ... 10.0j intervals*Calculate the convex hull of two intervalshull (0 ... 10 :: Interval Double) (5 ... 15 :: Interval Double) 0.0 ... 15.0hull (15 ... 85 :: Interval Double) (0 ... 10 :: Interval Double) 0.0 ... 85.0hull (10 ... 20 :: Interval Double) (15 ... 0 :: Interval Double) 10.0 ... 20.0k intervalsFor all x in X, y in Y. x  y?(5 ... 10 :: Interval Double) ! (10 ... 19 :: Interval Double)True?(5 ... 20 :: Interval Double) >! (15 ... 40 :: Interval Double)Falsep intervalsFor all x in X, y in Y. x  y(20 ... 40 :: Interval Double) >=! (10 ... 20 :: Interval Double)True(5 ... 20 :: Interval Double) >=! (15 ... 40 :: Interval Double)Falseq intervalsFor all x in X, y in Y. x op yr intervalsCheck if interval X totally contains interval Y(20 ... 40 :: Interval Double) `contains` (25 ... 35 :: Interval Double)True(20 ... 40 :: Interval Double) `contains` (15 ... 35 :: Interval Double)Falses intervalsFlipped version of r. Check if interval X a subset of interval Y(25 ... 35 :: Interval Double) `isSubsetOf` (20 ... 40 :: Interval Double)True(20 ... 40 :: Interval Double) `isSubsetOf` (15 ... 35 :: Interval Double)Falset intervalsDoes there exist an x in X, y in Y such that x  y?u intervalsDoes there exist an x in X, y in Y such that x  y?v intervalsDoes there exist an x in X, y in Y such that x  y?w intervalsDoes there exist an x in X, y in Y such that x  y?x intervalsDoes there exist an x in X, y in Y such that x  y?y intervalsDoes there exist an x in X, y in Y such that x  y?z intervalsDoes there exist an x in X, y in Y such that x op y?{ intervalsThe nearest value to that supplied which is contained in the interval.| intervals*id function. Useful for type specification:t idouble (1 ... 3)$idouble (1 ... 3) :: Interval Double} intervals*id function. Useful for type specification:t ifloat (1 ... 3)"ifloat (1 ... 3) :: Interval Float~ intervalsan interval containing all x  y >>> (5  3) e ((4...6) ~ (2...4)) True >>> (1...10) ~* ((-5)...4) *** Exception: divide by zero intervalsan interval containing all x  y >>> (5  3) e ((4...6)  (2...4)) True >>> (1...10) * ((-5)...4) *** Exception: divide by zero intervalsan interval containing all x  y >>> (5  3) e ((4...6)  (2...4)) True >>> (1...10) * ((-5)...4) *** Exception: divide by zero intervalsan interval containing all x  y >>> (5  3) e ((4...6)  (2...4)) True >>> (1...10) * ((-5)...4) *** Exception: divide by zero intervalsWe have to play some semantic games to make these methods make sense. Most compute with the midpoint of the interval. intervals will use the midpoint intervals is j2PQRSTUVWefghXYZ[dijc\]^_`abrsqklmnpoztuvwyx{|}~2PQRSTUVWefghXYZ[dijc\]^_`abrsqklmnpoztuvwyx{|}~R3(c) Edward Kmett 2010-2014BSD3ekmett@gmail.com experimentalDeriveDataTypeable Safe-Inferred7<m6 intervals;Create a non-empty interval, turning it around if necessary intervals#Try to create a non-empty interval. intervalsThe whole real number linewhole-Infinity ... Infinity(x :: Double) `elem` whole intervalsA singleton point singleton 11 ... 1x `elem` (singleton x)$x /= y ==> y `notElem` (singleton x) intervals*The infinumum (lower bound) of an intervalinf (1 ... 20)1min x y == inf (x ... y)inf x <= sup x intervals)The supremum (upper bound) of an intervalsup (1 ... 20)20sup x `elem` xmax x y == sup (x ... y)inf x <= sup x intervalsIs the interval a singleton point? N.B. This is fairly fragile and likely will not hold after even a few operations that only involve singletonssingular (singleton 1)Truesingular (1.0 ... 20.0)False intervals#Calculate the width of an interval.width (1 ... 20)19width (singleton 1)0 0 <= width x intervals Magnitudemagnitude (1 ... 20)20magnitude (-20 ... 10)20magnitude (singleton 5)50 <= magnitude x intervals "mignitude"mignitude (1 ... 20)1mignitude (-20 ... 10)0mignitude (singleton 5)50 <= mignitude x intervals#Bisect an interval at its midpoint.bisect (10.0 ... 20.0)(10.0 ... 15.0,15.0 ... 20.0)bisect (singleton 5.0)(5.0 ... 5.0,5.0 ... 5.0) Interval Double -> Double)0 <= distance x y intervals(Determine if a point is in the interval.member 3.2 (1.0 ... 5.0)Truemember 5 (1.0 ... 5.0)Truemember 1 (1.0 ... 5.0)Truemember 8 (1.0 ... 5.0)False intervals4Determine if a point is not included in the intervalnotMember 8 (1.0 ... 5.0)TruenotMember 1.4 (1.0 ... 5.0)False intervals(Determine if a point is in the interval.elem 3.2 (1.0 ... 5.0)Trueelem 5 (1.0 ... 5.0)Trueelem 1 (1.0 ... 5.0)Trueelem 8 (1.0 ... 5.0)False intervals4Determine if a point is not included in the intervalnotElem 8 (1.0 ... 5.0)TruenotElem 1.4 (1.0 ... 5.0)False intervals9lift a monotone increasing function over a given interval intervals9lift a monotone decreasing function over a given interval intervals,Calculate the intersection of two intervals.intersection (1 ... 10 :: Interval Double) (5 ... 15 :: Interval Double)Just (5.0 ... 10.0) intervals*Calculate the convex hull of two intervalshull (0 ... 10 :: Interval Double) (5 ... 15 :: Interval Double) 0.0 ... 15.0hull (15 ... 85 :: Interval Double) (0 ... 10 :: Interval Double) 0.0 ... 85.0conservative2 const hullconservative2 (flip const) hull intervalsFor all x in X, y in Y. x  y?(5 ... 10 :: Interval Double) ! (10 ... 19 :: Interval Double)True?(5 ... 20 :: Interval Double) >! (15 ... 40 :: Interval Double)False intervalsFor all x in X, y in Y. x  y(20 ... 40 :: Interval Double) >=! (10 ... 20 :: Interval Double)True(5 ... 20 :: Interval Double) >=! (15 ... 40 :: Interval Double)False intervalsFor all x in X, y in Y. x op y intervalsCheck if interval X totally contains interval Y(20 ... 40 :: Interval Double) `contains` (25 ... 35 :: Interval Double)True(20 ... 40 :: Interval Double) `contains` (15 ... 35 :: Interval Double)False intervalsFlipped version of . Check if interval X a subset of interval Y(25 ... 35 :: Interval Double) `isSubsetOf` (20 ... 40 :: Interval Double)True(20 ... 40 :: Interval Double) `isSubsetOf` (15 ... 35 :: Interval Double)False intervalsDoes there exist an x in X, y in Y such that x  y? intervalsDoes there exist an x in X, y in Y such that x  y? intervalsDoes there exist an x in X, y in Y such that x  y? intervalsDoes there exist an x in X, y in Y such that x  y? intervalsDoes there exist an x in X, y in Y such that x  y? intervalsDoes there exist an x in X, y in Y such that x  y? intervalsDoes there exist an x in X, y in Y such that x op y? intervalsThe nearest value to that supplied which is contained in the interval.(clamp xs y) `elem` xs intervals1Inflate an interval by enlarging it at both ends.inflate 3 (-1 ... 7) -4 ... 10inflate (-2) (0 ... 4)-2 ... 6inflate x i `contains` i intervalsDeflate an interval by shrinking it from both ends. Note that in cases that would result in an empty interval, the result is a singleton interval at the midpoint.deflate 3.0 (-4.0 ... 10.0) -1.0 ... 7.0deflate 2.0 (-1.0 ... 1.0) 0.0 ... 0.0 intervals%Scale an interval about its midpoint.scale 1.1 (-6.0 ... 4.0) -6.5 ... 4.5scale (-2.0) (-1.0 ... 1.0) -2.0 ... 2.06- The property test below is currently disabled (#66)./- prop> abs x >= 1 ==> (scale (x :: Double) i) - i prop> forAll (choose (0,1)) $ x -> abs x  =1 == i  (scale (x :: Double) i) intervalsConstruct a symmetric interval. symmetric 3-3 ... 3symmetric (-2)-2 ... 2x `elem` symmetric x0 `elem` symmetric x intervals*id function. Useful for type specification:t idouble (1 ... 3)$idouble (1 ... 3) :: Interval Double intervals*id function. Useful for type specification:t ifloat (1 ... 3)"ifloat (1 ... 3) :: Interval Float intervalsan interval containing all x  y prop> forAll (memberOf xs) $ x -> forAll (memberOf ys) $ y -> 0  ys ==> (x  y)  (xs  ys) prop> 0 / ys ==> ioProperty $ do z <- try (evaluate (xs ' ys)); return $ z === Left DivideByZero intervalsan interval containing all x  y prop> forAll (memberOf xs) $ x -> forAll (memberOf ys) $ y -> 0  ys ==> (x  y)  (xs  ys) prop> 0 / ys ==> ioProperty $ do z <- try (evaluate (xs ' ys)); return $ z === Left DivideByZero intervalsan interval containing all x  y prop> forAll (memberOf xs) $ x -> forAll (memberOf ys) $ y -> 0  ys ==> (x  y)  (xs  ys) prop> 0 / ys ==> ioProperty $ do z <- try (evaluate (xs ' ys)); return $ z === Left DivideByZero intervalsan interval containing all x  y prop> forAll (memberOf xs) $ x -> forAll (memberOf ys) $ y -> 0  ys ==> (x  y)  (xs  ys) prop> 0 / ys ==> ioProperty $ do z <- try (evaluate (xs ' ys)); return $ z === Left DivideByZero intervalsWe have to play some semantic games to make these methods make sense. Most compute with the midpoint of the interval. intervals'Transcendental functions for intervals.*conservative (exp :: Double -> Double) exp3conservativeExceptNaN (log :: Double -> Double) log*conservative (sin :: Double -> Double) sin*conservative (cos :: Double -> Double) cos*conservative (tan :: Double -> Double) tan5conservativeExceptNaN (asin :: Double -> Double) asin5conservativeExceptNaN (acos :: Double -> Double) acos,conservative (atan :: Double -> Double) atan,conservative (sinh :: Double -> Double) sinh,conservative (cosh :: Double -> Double) cosh,conservative (tanh :: Double -> Double) tanh7conservativeExceptNaN (asinh :: Double -> Double) asinh7conservativeExceptNaN (acosh :: Double -> Double) acosh7conservativeExceptNaN (atanh :: Double -> Double) atanhcos (0 ... (pi + 0.1)) -1.0 ... 1.0 intervals"Fractional instance for intervals.8- The property tests below are currently disabled (#66). - prop> ys "= singleton 0 ==> conservative2 ((*) :: Double -> Double -> Double) (/) xs ys- prop> xs /= singleton 0 ==> conservative (recip :: Double -> Double) recip xs intervals will use the midpoint intervalsNum instance for intervals.5conservative2 ((+) :: Double -> Double -> Double) (+)5conservative2 ((-) :: Double -> Double -> Double) (-)5conservative2 ((*) :: Double -> Double -> Double) (*)*conservative (abs :: Double -> Double) abs intervals is 113(c) Edward Kmett 2010-2013BSD3ekmett@gmail.com experimentalDeriveDataTypeable Safe-Inferred7<n00       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTU !"#$%&'()+,-./0123456789:;<=>?@AVBCDEFGHIJKLMNWXYZ[\PQRSTU !"#)*+$,-./0123456789:;<=>?@AV%&'(BCDEFGHIJKLMNPQRSTU]^_`a_`b_`c_`d_`e_`fghighjghkghlghmgno]^]^&intervals-0.9.3-Kq5dDsHgggCAmbfNgApWrTNumeric.Interval.ExceptionNumeric.IntervalNumeric.Interval.InternalNumeric.Interval.KaucherNumeric.Interval.NonEmpty"Numeric.Interval.NonEmpty.Internal intervalsAmbiguousComparison EmptyInterval$fExceptionEmptyInterval$fShowEmptyInterval$fExceptionAmbiguousComparison$fShowAmbiguousComparison$fEqAmbiguousComparison$fOrdAmbiguousComparison$fDataAmbiguousComparison$fEqEmptyInterval$fOrdEmptyInterval$fDataEmptyIntervalIntervalIEmpty+/-interval...wholeemptynull singletoninfsupsingularwidth magnitude mignitudedistanceinflatedeflatescale symmetricbisectbisectIntegralmidpointmember notMemberelemnotElem intersectionhull!>=! certainlycontains isSubsetOf?>=?possiblyidoubleifloatiquotiremidivimod$fRealFloatInterval$fFloatingInterval$fRealFracInterval$fFractionalInterval$fRealInterval $fNumInterval$fShowInterval$fMonoidInterval$fSemigroupInterval $fEqInterval $fOrdInterval$fDataInterval$fGenericInterval$fGeneric1TYPEIntervalclamp$fDistributiveInterval$fMonadInterval$fApplicativeInterval$fTraversableInterval$fFoldableInterval$fFunctorInterval increasing decreasingghc-prim GHC.Classes<<===/=>>=baseGHC.Realquotremdivmod realToFracGHC.Base<>