úÎƂūt      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijk lmnopqrstuvwx y z{|} ~ (c) 2014 Bryan O'SullivanBSD3bos@serpentine.com experimentalportableNone 0:<=DR đ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 =   [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)." €‚ƒ„…†‡ˆ‰"#$%&Š "#$# "$  ‚€…†„ƒ‰"#$%&Šˆ‡(c) 2009, 2011 Bryan O'SullivanBSD3bos@serpentine.com experimentalportableNone:*NEvaluate 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...]‹ŒŽ*Parameter of each function.:Coefficients of each polynomial term, in increasing order.+Parameter of each function.:Coefficients of each polynomial term, in increasing order.*+*+‹ŒŽ*+(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^2-qEvaluate 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^4.pEvaluate 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^5,x Coefficients-x Coefficients.x Coefficients/01,-./01,-./01,-./01(c) 2009, 2011 Bryan O'SullivanBSD3bos@serpentine.com experimentalportableSafe2#Largest representable finite value.35The smallest representable positive normalized value.4 The largest  x such that 2**(x)-1) is approximately representable as a .5Positive infinity.6Negative infinity.7 Not a number.8!Maximum possible finite value of log x9)Logarithm of smallest normalized double (3): sqrt 2;  sqrt (2 * pi)<  2 / sqrt pi=  1 / sqrt 2> The smallest  ĩ such that 1 + ĩ "` 1.? log(sqrt((2*pi))@*Euler Mascheroni constant (ģ = 0.57721...)23456789:;<=>?@23456789:;<=>?@>23456789=<?:;@23456789:;<=>?@(c) 2016 Alexey KhudyakovBSD3-alexey.skladnoy@gmail.com, bos@serpentine.com experimentalportableSafeAT AGInfinite series. It's represented as opaque state and step function.CenumSequenceFrom x generate sequence: a_n = x + n DenumSequenceFromStep x d generate sequence: a_n = x + nd E Analog of ‘ for sequence.FCalculate sum of series \sum_{i=0}^\infty a_i Summation is stopped when' a_{n+1} < \varepsilon\sum_{i=0}^n a_i where ĩ is machine precision (>)GCalculate sum of series \sum_{i=0}^\infty x^ia_i ECalculation is stopped when next value in series is less than ĩ·sum.HConvert series to infinite listI€Evaluate continued fraction using modified Lentz algorithm. Sequence contain pairs (a[i],b[i]) which form following expression:B b_0 + \frac{a_1}{b_1+\frac{a_2}{b_2+\frac{a_3}{b_3 + \cdots}}} cModified Lentz algorithm is described in Numerical recipes 5.2 "Evaluation of Continued Fractions"J%Elementwise operations with sequencesK%Elementwise operations with sequences ABCDEFGHIJKLM ABCDEFGHI ABCDEFGHI ABCDEFGHIJKLM(c) 2011 Bryan O'SullivanBSD3bos@serpentine.com experimentalportableNoneN(Calculate relative error of two numbers: \frac{|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 NaNO.Check that relative error between two numbers a and b. If N returns NaN it returns False.P)Add N ULPs (units of least precision) to Double number.QMeasure distance between two DoubleEs in ULPs (units of least precision). Note that it's different from abs (ulpDelta a b), since it returns correct result even when R overflows.R$Measure signed distance between two Double8s in ULPs (units of least precision). Note that unlike Q it can overflow.  >>> ulpDelta 1 (1 + m_epsilon) 1S Compare two 9 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.NOeps( relative error should be in [0,1) rangeabPQRS#Number of ULPs of accuracy desired.NOPQRSNOPQRSNOPQRS(c) 2011 Bryan O'SullivanBSD3bos@serpentine.com experimentalportableNone05T>The result of searching for a root of a mathematical function.UfThe function does not have opposite signs when evaluated at the lower and upper bounds of the search.VhThe search failed to converge to within the given error tolerance after the given number of iterations.WA root was successfully found.X]Returns either the result of a search for a root, or the default value if the search failed.Y:Use the method of Ridders to compute a root of a function.„The function must have opposite signs when evaluated at the lower and upper bounds of the search (i.e. the root must be bracketed).Z/Solve equation using Newton-Raphson iterations.ŠThis method require both initial guess and bounds for root. If Newton step takes us out of bounds on root function reverts to bisection. TUVWXDefault value.Result of search for a root.YAbsolute error tolerance.&Lower and upper bounds for the search.Function to find the roots of.ZRequired precisionY(lower bound, initial guess, upper bound). Iterations will no go outside of the intervalNFunction to finds roots. It returns pair of function value and its derivative[\]^_TWUVXYZTUVWXYZ TUVWXYZ[\]^_ %(c) 2009, 2011, 2012 Bryan O'SullivanBSD3bos@serpentine.com experimentalportableNoneTeError function.K \operatorname{erf}(x) = \frac{2}{\sqrt{\pi}} \int_{0}^{x} \exp(-t^2) dt Function limits are:Ķ[ begin{aligned} &operatorname{erf}(-infty) &=& -1 -- &operatorname{erf}(0) &=& phantom{-},0 -- &operatorname{erf}(+infty) &=& phantom{-},1 -- end{aligned}fComplementary error function.6 \operatorname{erfc}(x) = 1 - \operatorname{erf}(x) Function limits are:’[ begin{aligned} &operatorname{erf}(-infty) &=&, 2 -- &operatorname{erf}(0) &=&, 1 -- &operatorname{erf}(+infty) &=&, 0 -- end{aligned}g Inverse of e.h Inverse of f.i/Compute the logarithm of the gamma function, “(x).; \Gamma(x) = \int_0^{\infty}t^{x-1}e^{-t}\,dt = (x - 1)! oThis implementation uses Lanczos approximation. It gives 14 or more significant decimal digits, 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).j Synonym for i. Retained for compatibilitykHCompute the log gamma correction factor for Stirling approximation for xl "e 10. This correction factor is suitable for an alternate (but less numerically accurate) definition of i:l \log\Gamma(x) = \frac{1}{2}\log(2\pi) + (x-\frac{1}{2})\log x - x + \operatorname{logGammaCorrection}(x) l:Compute the normalized lower incomplete gamma function ģ(z,x). Normalization means that ģ(z,")=1@ \gamma(z,x) = \frac{1}{\Gamma(z)}\int_0^{x}t^{z-1}e^{-t}\,dt Uses Algorithm AS 239 by Shea.mDInverse incomplete gamma function. It's approximately inverse of l for the same z/. So following equality approximately holds: -invIncompleteGamma z . incompleteGamma z "H idn3Compute the natural logarithm of the beta function.U B(a,b) = \int_0^1 t^{a-1}(1-t)^{1-b}\,dt = \frac{\Gamma(a)\Gamma(b)}{\Gamma(a+b)} o%Regularized incomplete beta function.? I(x;a,b) = \frac{1}{B(a,b)} \int_0^x t^{a-1}(1-t)^{1-b}\,dt YUses algorithm AS63 by Majumder and Bhattachrjee and quadrature approximation for large p and q.p.Regularized incomplete beta function. Same as o9 but also takes logarithm of beta function as parameter.q‹Compute inverse of regularized incomplete beta function. Uses initial approximation from AS109, AS64 and Halley method to solve equation.rCompute sinc function sin(x)/xsCompute log(1+x)-x:tO(log n)4 Compute the logarithm in base 2 of the given value.uCompute the factorial function ne!. Returns +" if the input is above 170 (above which the result cannot be represented by a 64-bit ).v`Compute the natural logarithm of the factorial function. Gives 16 decimal digits of precision.wgCalculate the error term of the Stirling approximation. This is only defined for non-negative values.Q \operatorname{stirlingError}(n) = \log(n!) - \log(\sqrt{2\pi n}\frac{n}{e}^n) x)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 . fromIntegraly2Calculate binomial coefficient using exact formulaz.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 Č(x=), the first logarithmic derivative of the gamma function.T \psi(x) = \frac{d}{dx} \ln \left(\Gamma(x)\right) = \frac{\Gamma'(x)}{\Gamma(x)} EUses Algorithm AS 103 by Bernardo, based on Minka's C implementation.$’“”•efgp " [-1,1]hp " [0,2]ijklz " (0,")x " (0,")mz " (0,")p " [0,1]na > 0b > 0oa > 0b > 0x, must lie in [0,1] rangep%logarithm of beta function for given p and qa > 0b > 0x, must lie in [0,1] range–—qa > 0b > 0x " [0,1]˜™rstuvwxyz{|š›œ$’“”•efghijklmnop–—q˜™rstuvwxyz{|š›œ#’“”•efghijklmnop–—q˜™rstuvwxyz{|š›œ%(c) 2009, 2011, 2012 Bryan O'SullivanBSD3bos@serpentine.com experimentalportableNoneefghijlmnopqrstuvwz{|efghijlm|nopqrstuvw{z (c) 2009, 2011 Bryan O'SullivanBSD3bos@serpentine.com experimentalportableNone}Evaluate the deviance term x log(x/np) + np - x.~.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  logGammaL.4Returns " if the input is outside of the range (0 < x "d 1e305).} x np~kxy}~}yx~k}~ž  !""#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKKLMNOPQRSTUVWXYZ[\]^_]`abcdefghijkl m n o p q r s t u v w x y z { | } ~  €  ‚ ƒ „ … †‡ˆ‰Š‹ŒŽ‘’““””•–—•–˜ ™š › › œ  ž Ÿ   Ą Ē Ģ Ī ĨĶ-math-functions-0.2.1.0-1xj0AjyFCzA6BCtmp8lCTANumeric.SpecFunctions Numeric.SumNumeric.Polynomial.ChebyshevNumeric.PolynomialNumeric.MathFunctions.ConstantsNumeric.Series Numeric.MathFunctions.ComparisonNumeric.RootFindingNumeric.SpecFunctions.ExtraNumeric.SpecFunctions.Internalbase GHC.Floatexpm1log1pKahanSum Summationzeroaddsum$fSummationDouble $fEqKahanSum$fShowKahanSum$fDataKahanSumKBNSumkahan$fNFDataKahanSum$fSummationKahanSum$fVectorVectorKahanSum$fMVectorMVectorKahanSum$fUnboxKahanSum $fEqKBNSum $fShowKBNSum $fDataKBNSumKB2Sumkbn$fNFDataKBNSum$fSummationKBNSum$fVectorVectorKBNSum$fMVectorMVectorKBNSum $fUnboxKBNSum $fEqKB2Sum $fShowKB2Sum $fDataKB2Sumkb2 sumVector pairwiseSum$fNFDataKB2Sum$fSummationKB2Sum$fVectorVectorKB2Sum$fMVectorMVectorKB2Sum $fUnboxKB2Sum chebyshevchebyshevBrouckeevaluatePolynomialevaluateEvenPolynomialevaluateOddPolynomialevaluatePolynomialLevaluateEvenPolynomialLevaluateOddPolynomialLm_hugem_tiny m_max_exp m_pos_inf m_neg_infm_NaN m_max_log m_min_logm_sqrt_2 m_sqrt_2_pi m_2_sqrt_pi m_1_sqrt_2 m_epsilonm_ln_sqrt_2_pim_eulerMascheroniSequenceenumSequenceFromenumSequenceFromStep scanSequence sumSeriessumPowerSeriessequenceToListevalContFractionB$fFractionalSequence $fNumSequence$fApplicativeSequence$fFunctorSequence relativeErroreqRelErraddUlps ulpDistanceulpDeltawithinRoot NotBracketed SearchFailedfromRootridders newtonRaphson$fAlternativeRoot$fApplicativeRoot$fMonadPlusRoot $fMonadRoot $fFunctorRoot$fEqRoot $fReadRoot $fShowRoot $fDataRoot $fGenericRooterferfcinvErfinvErfclogGamma logGammaLlogGammaCorrectionincompleteGammainvIncompleteGammalogBetaincompleteBetaincompleteBeta_invIncompleteBetasinclog1pmxlog2 factorial logFactorial stirlingError logChooseFast chooseExact logChoosechoosedigammabd0 logGammaAS245 V_KahanSum MV_KahanSumkahanAddD:R:VectorKahanSum0V_KBNSum MV_KBNSumkbnAddD:R:VectorKBNSum0V_KB2Sum MV_KB2Sumkb2AddD:R:VectorKB2Sum0BCghc-prim GHC.TypesIntDoubleGHC.ListscanlLc_erfcc_erfincompleteBetaApproxincompleteBetaWorkerinvIncompleteBetaWorkerinvIncBetaGuesscoefWcoefY trigamma1modErr