úΈÿƒÖA      !"#$%&'()*+,-./0123456789:;<=>?@(c) 2014 Bryan O'SullivanBSD3bos@serpentine.com experimentalportableNone +47>L ¹Kahan summation. This is the least accurate of the compensated summation methods. In practice, it only beats naive summation for inputs with large magnitude. Kahan summation can be less; accurate than naive summation for small-magnitude inputs._This summation method is included for completeness. Its use is not recommended. In practice, ' is both 30% faster and more accurate.0A class for summation of floating point numbers.The identity for summation.Add a value to a sum.Sum a collection of values. Example: foo = A   [1,2,3]sKahan-Babuaka-Neumaier summation. This is a little more computationally costly than plain Kahan summation, but is always at least as accurate.!Return the result of a Kahan sum. éSecond-order Kahan-Babuaka summation. This is more computationally costly than Kahan-Babuaka-Neumaier summation, running at about a third the speed. Its advantage is that it can lose less precision (in admittedly obscure cases).‡This method compensates for error in both the sum and the first-order compensation term, hence the use of "second order" in the name. 2Return the result of a Kahan-Babuaka-Neumaier sum. 2Return the result of an order-2 Kahan-Babuaka sum. O(n) Sum a vector of values.O(n)1 Sum a vector of values using pairwise summation.)This approach is perhaps 10% faster than ¹, but has poorer bounds on its error growth. Instead of having roughly constant error regardless of the size of the input vector, in the worst case its accumulated error grows with O(log n)."BCDEFGH IJK LMNOPQ RST   BEFGHDC  K LMNJIQ RSTPO(c) 2009, 2011 Bryan O'SullivanBSD3bos@serpentine.com experimentalportableNone4NEvaluate a Chebyshev polynomial of the first kind. Uses Clenshaw's algorithm.§Evaluate a Chebyshev polynomial of the first kind. Uses Broucke's ECHEB algorithm, and his convention for coefficient handling. It treat 0th coefficient different so =chebyshev x [a0,a1,a2...] == chebyshevBroucke [2*a0,a1,a2...]UVWXParameter of each function.:Coefficients of each polynomial term, in increasing order.Parameter of each function.:Coefficients of each polynomial term, in increasing order.UVWX(c) 2012 Aleksey KhudyakovBSD3bos@serpentine.com experimentalportableNone[Evaluate polynomial using Horner's method. Coefficients starts from lowest. In pseudocode: 1evaluateOddPolynomial x [1,2,3] = 1 + 2*x + 3*x^2qEvaluate polynomial with only even powers using Horner's method. Coefficients starts from lowest. In pseudocode: 3evaluateOddPolynomial x [1,2,3] = 1 + 2*x^2 + 3*x^4pEvaluate polynomial with only odd powers using Horner's method. Coefficients starts from lowest. In pseudocode: 5evaluateOddPolynomial x [1,2,3] = 1*x + 2*x^3 + 3*x^5x Coefficientsx Coefficientsx Coefficients(c) 2011 Bryan O'SullivanBSD3bos@serpentine.com experimentalportableNone(Calculate relative error of two numbers: |a - b| / max |a| |b|ÙIt lies in [0,1) interval for numbers with same sign and (1,2] for numbers with different sign. If both arguments are zero or negative zero function returns 0. If at least one argument is transfinite it returns NaN.Check that relative error between two numbers a and b. If  returns NaN it returns False.)Add N ULPs (units of least precision) to Double number.Measure distance between two Double&s in ULPs (units of least precision). Compare two Y9 values for approximate equality, using Dawson's method.ŸThe required accuracy is specified in ULPs (units of least precision). If the two numbers differ by the given number of ULPs or less, this function returns True.eps( relative error should be in [0,1) range a b#Number of ULPs of accuracy desired.(c) 2009, 2011 Bryan O'SullivanBSD3bos@serpentine.com experimentalportableSafe A very large number. The largest Z x such that 2**(x)-1) is approximately representable as a Y.Positive infinity. Negative infinity.! Not a number." sqrt 2#  sqrt (2 * pi)$  2 / sqrt pi%  1 / sqrt 2& The smallest Y µ such that 1 + µ "` 1.' log(sqrt((2*pi))(*Euler Mascheroni constant (³ = 0.57721...)  !"#$%&'(  !"#$%&'( & !%$'"#(  !"#$%&'(%(c) 2009, 2011, 2012 Bryan O'SullivanBSD3bos@serpentine.com experimentalportableNoneN)Error function. #erf -" = -1 erf 0 = 0 erf +" = 1*Complementary error function. #erfc -" = 2 erfc 0 = 1 errc +" = 0+ Inverse of )., Inverse of *.-.Compute the logarithm of the gamma function “(x&). Uses Algorithm AS 245 by Macleod.XGives an accuracy of 10-12 significant decimal digits, except for small regions around x = 1 and xC = 2, where the function goes to zero. For greater accuracy, use ..4Returns " if the input is outside of the range (0 < x "d 1e305)../Compute the logarithm of the gamma function, “(x"). Uses a Lanczos approximation.This function is slower than -N, but gives 14 or more significant decimal digits of accuracy, except around x = 1 and x& = 2, where the function goes to zero.4Returns " if the input is outside of the range (0 < x "d 1e305).[,Compute the log gamma correction factor for xl "e 10. This correction factor is suitable for an alternate (but less numerically accurate) definition of -: Dlgg x = 0.5 * log(2*pi) + (x-0.5) * log x - x + logGammaCorrection x/:Compute the normalized lower incomplete gamma function ³(s,x). Normalization means that ³(s%,")=1. Uses Algorithm AS 239 by Shea.0DInverse incomplete gamma function. It's approximately inverse of / for the same s/. So following equality approximately holds: -invIncompleteGamma s . incompleteGamma s = id13Compute the natural logarithm of the beta function.2€Regularized incomplete beta function. Uses algorithm AS63 by Majumder and Bhattachrjee and quadrature approximation for large p and q.3.Regularized incomplete beta function. Same as 29 but also takes logarithm of beta function as parameter.4‹Compute inverse of regularized incomplete beta function. Uses initial approximation from AS109, AS64 and Halley method to solve equation.5Compute sinc function sin(x)/x6%Compute the natural logarithm of 1 + x(. This is accurate even for values of x near zero, where use of log(1+x) would lose precision.7O(log n)4 Compute the logarithm in base 2 of the given value.8Compute the factorial function ne!. Returns +" if the input is above 170 (above which the result cannot be represented by a 64-bit Y).9`Compute the natural logarithm of the factorial function. Gives 16 decimal digits of precision.:gCalculate the error term of the Stirling approximation. This is only defined for non-negative values. 8stirlingError @n@ = @log(n!) - log(sqrt(2*pi*n)*(n/e)^n);)Quickly compute the natural logarithm of n > k, with no checking.Less numerically stable: Kexp $ lg (n+1) - lg (k+1) - lg (n-k+1) where lg = logGamma . fromIntegral<2Calculate binomial coefficient using exact formula=.Compute logarithm of the binomial coefficient.>!Compute the binomial coefficient n `>` k. For values of k‚ > 50, this uses an approximation for performance reasons. The approximation is accurate to 12 decimal places in the worst caseExample: 7 `choose` 3 == 35? Compute È0(x‚), the first logarithmic derivative of the gamma function. Uses Algorithm AS 103 by Bernardo, based on Minka's C implementation.!\])*+p " [-1,1],p " [0,2]-.[/s " (0,")x " (0,")0s " (0,")p " [0,1]12p > 0q > 0x, must lie in [0,1] range3%logarithm of beta function for given p and qp > 0q > 0x, must lie in [0,1] range^_4p > 0q > 0a " [0,1]`56789:;<=>?abcd!\])*+,-.[/0123^_4`56789:;<=>?abcd \])*+,-.[/0123^_4`56789:;<=>?abcd%(c) 2009, 2011, 2012 Bryan O'SullivanBSD3bos@serpentine.com experimentalportableNoneN)*+,-./0123456789:=>?)*+,-./0?123456789:>=(c) 2009, 2011 Bryan O'SullivanBSD3bos@serpentine.com experimentalportableNone@Evaluate the deviance term x log(x/np) + np - x.@ x np;<@@<;@e       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGH IJKLMNOPQRSTUVWXYZ[\\]]^_`^_abccdefghijkmathf_BN6S7j0ar3LC4TsnYu0us5 Numeric.SumNumeric.Polynomial.ChebyshevNumeric.Polynomial Numeric.MathFunctions.ComparisonNumeric.MathFunctions.ConstantsNumeric.SpecFunctionsNumeric.SpecFunctions.ExtraNumeric.SpecFunctions.InternalKahanSum SummationzeroaddsumKBNSumkahanKB2Sumkbnkb2 sumVector pairwiseSum chebyshevchebyshevBrouckeevaluatePolynomialevaluateEvenPolynomialevaluateOddPolynomialevaluatePolynomialLevaluateEvenPolynomialLevaluateOddPolynomialL relativeErroreqRelErraddUlps ulpDistancewithinm_hugem_tiny m_max_exp m_pos_inf m_neg_infm_NaNm_sqrt_2 m_sqrt_2_pi m_2_sqrt_pi m_1_sqrt_2 m_epsilonm_ln_sqrt_2_pim_eulerMascheronierferfcinvErfinvErfclogGamma logGammaLincompleteGammainvIncompleteGammalogBetaincompleteBetaincompleteBeta_invIncompleteBetasinclog1plog2 factorial logFactorial stirlingError logChooseFast chooseExact logChoosechoosedigammabd0base Data.Foldable$fSummationDouble V_KahanSum MV_KahanSumkahanAdd$fNFDataKahanSum$fSummationKahanSumTFCo:R:VectorKahanSumV_KBNSum MV_KBNSumkbnAdd$fNFDataKBNSum$fSummationKBNSumTFCo:R:VectorKBNSumV_KB2Sum MV_KB2Sumkb2Add$fNFDataKB2Sum$fSummationKB2SumTFCo:R:VectorKB2SumBCghc-prim GHC.TypesDoubleIntlogGammaCorrectionLincompleteBetaApproxincompleteBetaWorkerinvIncompleteBetaWorkercoefWcoefY trigamma1modErr