!!      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijkl m n o p q r s t u v w x y z { | } ~   !!!!!!""""""""""#$%%%%%%%%&&&&&&&&''''( ( ( ( ( (((((())))))))))))) )!)")#)$)%)&)')()))*)+),)-).)/*0*1*2*3+4+5+6+7+8+9+:+;+<+=+>+?,@-A.B/C/D/E/F/G/H/I0J0K0L0M0N0O0P0Q1R2S2T2U2V2W2X2Y3Z3[3\3]3^3_3`3a3b4c4d4e5f5g5h5i5j5k5l5m5n5o5p5q5r6s7t7u7v7w7x7y7z7{8|9}9~9999999Safe[factory Describes an  exponential, in terms of its base and exponent.factory Accessor.factory Accessor.factory Construct an  merely raised to the 1st power.@The value of the resulting exponential is the same as specified base;  .https://en.wikipedia.org/wiki/Identity_element.factoryEvaluate the specified !, returning the resulting number.factory True if the bases are equal.factoryRaise the specified  to a power.factory+Invert the value, by negating the exponent.factory The operand.factory3The power to which the exponential is to be raised.factory The result.48NoneO`factory<Defines a closed (inclusive) interval of consecutive values. factory Accessor. factory Accessor. factoryConstruct the unsigned closed unit-interval;  +https://en.wikipedia.org/wiki/Unit_interval. factory Construct an interval from a bounded type. factory Construct an interval from a single value.factoryShift of both  end-points of the interval by the specified amount.factoryBTrue if the specified value is within the inclusive bounds of the interval.factoryTrue if   exceeds   extent.factory Swap the  end-points? where they were originally reversed, but otherwise do nothing.factory Bisect the interval at the specified  end-point+; which should be between the two existing  end-points.factory/The distance between the endpoints, which for o quantities is the same as the number of items in closed interval; though the latter concept would return type .CAVEAT: the implementation accounts for the potential fence-post error, for closed intervals of integers, but this results in the opposite error when used with  Fractional< quantities. So, though most of the module merely requires ), this function is further restricted to .factory Converts % to a list by enumerating the values.(CAVEAT: produces rather odd results for R types, but no stranger than considering such types Enumerable in the first place.factoryReduces . to a single integral value encapsulated in a  , using a divide-and-conquer strategy, bisecting the interval' and recursively evaluating each part;  :https://en.wikipedia.org/wiki/Divide_and_conquer_algorithm.By choosing a ratio other than (1 % 2), the bisection can be made asymmetrical. The specified ratio represents the length of the left-hand portion over the original list-length; eg. (1 % 3): results in the first part, half the length of the second.jThis process of recursive bisection, is terminated beneath the specified minimum length, after which the 3 are expanded into the corresponding list, and the monoid's binary operator is directly folded over it.One can view this as a  Ahttps://en.wikipedia.org/wiki/Hylomorphism_%28computer_science%29 , in which X is exploded into a binary tree-structure (each leaf of which contains a list of up to  minLength integers, and each node of which contains an associative binary operator), and then collapsed to a scalar, by application of the operators.factory7Multiplies the consecutive sequence of integers within .Since the result can be large, { is used to form operands of a similar order of magnitude, thus improving the efficiency of the big-number multiplication.factory#The magnitude of the require shift.factoryThe interval to be shifted.factoryThe monoid's constructor.factory7The ratio of the original span, at which to bisect the .factoryFor efficiency, the intervalG will not be bisected, when it's length has been reduced to this value.factoryThe resulting scalar.factory!The ratio at which to bisect the .factoryFor efficiency, the intervalG will not be bisected, when it's length has been reduced to this value.factoryThe resulting product.     Safe_%factory"The type of an arbitrary monomial.CAVEAT: though a monomialM has an integral power, this contraint is only imposed at the function-level.factory Accessor.factory Accessor.factory if the exponent is both integral and non-negative.5CAVEAT: one can't even call this function unless the exponent is integral.factory Compares the  exponents of the specified s.factory True if the  exponents are equal.factoryMultiply the two specified s.factoryDivide the two specified s.factorySquare the specified .factoryDouble the specified .factory Shift the  coefficient, by the specified amount. factory Shift the exponent, by the specified amount.!factoryNegate the coefficient."factoryReduce the coefficient using modular arithmetic.#factoryConvert the type of the  coefficient.factory Numerator.factory Denominator.factoryThe magnitude of the shift. factoryThe magnitude of the shift."factoryModulus. !"#"!# 4477Safe$factory!Couples a candidate prime with a  rolling wheel , to define the distance rolled.%factoryThe size of the wheel=, measured by the number of primes from which it is composed.factoryDefines a container for the &.&factoryFAn infinite increasing sequence, of the multiples of a specific prime.'factory A conceptual wheel", with irregularly spaced spokes;  Khttp://www.haskell.org/haskellwiki/Prime_numbers_miscellaneous#Prime_Wheels.JOn being rolled, the trace of the spokes, identifies candidates which are coprime to those primes from which the wheel was composed.OOne can alternatively view this as a set of vertical nested rings, each with a prime circumferenceC, and touching at its lowest point. Each has a single mark on its  circumference1, which when rolled identifies multiples of that  circumference. When the complete set is rolled, from the state where all marks are coincident, all multiples of the set of primes, are traced.CCAVEAT: The distance required to return to this state (the wheel's  circumference+), grows rapidly with the number of primes:  zip [0 ..] . scanl (*) 1 $ [2,3,5,7,11,13,17,19,23,29,31] [(0,1),(1,2),(2,6),(3,30),(4,210),(5,2310),(6,30030),(7,510510),(8,9699690),(9,223092870),(10,6469693230),(11,200560490130)]BThe number of spokes also grows rapidly with the number of primes:  zip [0 ..] . scanl (*) 1 . map pred $ [2,3,5,7,11,13,17,19,23,29,31] [(0,1),(1,1),(2,2),(3,8),(4,48),(5,480),(6,5760),(7,92160),(8,1658880),(9,36495360),(10,1021870080),(11,30656102400)](factoryAAccessor: the ordered sequence of initial primes, from which the wheel was composed.)factoryBAccessor: the sequence of spoke-gaps, the sum of which equals its  circumference.*factoryThe  circumference of the specified '.+factory&The number of spokes in the specified '.factoryUses a Sieve of Eratosthenes ( 3https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes-), to generate an initial sequence of primes.JAlso generates an infinite sequence of candidate primes, each of which is coprime" to the primes just found, e.g.: filter ((== 1) . (gcd (2 * 3 * 5 * 7))) [11 ..] = [11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,121 ..]; NB 121 isn't prime.$CAVEAT: the use, for efficiency, of  Data.IntMapP, limits the maximum bound of this sequence, though not to a significant extent.,factory9The optimal number of low primes from which to build the wheel1, grows with the number of primes required; the  circumference should be approximately the  square-root8 of the number of integers it will be required to sieve.JCAVEAT: one greater than this is returned, which empirically seems better.-factorySmart constructor for a wheel) from the specified number of low primes.9The optimal number of low primes from which to build the wheel1, grows with the number of primes required; the  circumference should be approximately the  square-root8 of the number of integers it will be required to sieve.+The sequence of gaps between spokes on the wheel is symmetrical under reflection; though two values lie on1 the axis, that aren't part of this symmetry. Eg: { nPrimes Gaps ====== ==== 0 [1] 1 [2] -- The terminal gap for all subsequent wheels is '2'; [(succ circumference `mod` circumference) - (pred circumference `mod` circumference)]. 2 [4,2] -- Both points are on the axis, so the symmetry isn't yet clear. 3 [6,4,2,4,2,4,6,2] 4 [10,2,4,2,4,6,2,6,4,2,4,6,6,2,6,4,2,6,4,6,8,4,2,4,2,4,8,6,4,6,2,4,6,2,6,6,4,2,4,6,2,6,4,2,4,2,10,2]ZExploitation of this property has proved counter-productive, probably because it requires strict evaluationB, exposing the user to the full cost of inadvertently choosing a wheel/, which in practice, is rotated less than once..factory(Generates a new candidate prime, from a  rolling wheel, and the current candidate./factoryRGenerate an infinite, increasing sequence of candidate primes, from the specified wheel.0factory>Generates multiples of the specified prime, starting from its squareG, skipping those multiples of the low primes from which the specified ') was composed, and which therefore, the wheel" won't generate as candidates. Eg:  Prime Rotating PrimeWheel 3 Output ===== ===================== ====== 7 [4,2,4,2,4,6,2,6] [49,77,91,119,133,161,203,217,259 ..] 11 [2,4,2,4,6,2,6,4] [121,143,187,209,253,319,341,407 ..] 13 [4,2,4,6,2,6,4,2] [169,221,247,299,377,403,481,533,559 ..]0factory!The number to square and multiplyfactoryA  rolling wheel0, the track of which, delimits the gaps between coprime candidates. $%&'()*+,-./0 $%&'(),0/.-*+None2factory5The list-length beneath which to terminate bisection.3factory9The ratio of the original list-length at which to bisect.CAVEAT: the value can overflow.4factory4Reduces a list to a single scalar encapsulated in a  , using a divide-and-conquerE strategy, bisecting the list and recursively evaluating each part;  :https://en.wikipedia.org/wiki/Divide_and_conquer_algorithm.By choosing a bisectionRatio other than (1 % 2), the bisection can be made asymmetrical. The specified ratio represents the length of the left-hand portion, over the original list-length; eg. (1 % 3): results in the first part, half the length of the second.oThis process of recursive bisection, is terminated beneath the specified minimum list-length, after which the monoid's binary operator is directly folded over the list.One can view this as a  Ahttps://en.wikipedia.org/wiki/Hylomorphism_%28computer_science%29l, in which the list is exploded into a binary tree-structure (each leaf of which contains a list of up to  minLength integers, and each node of which contains an associative binary operator), and then collapsed to a scalar, by application of the operators.5factory)Multiplies the specified list of numbers.Since the result can be large, 4 is used in an attempt to form operands of a similar order of magnitude, which creates scope for the use of more efficient multiplication-algorithms.6factory#Sums the specified list of numbers.Since the result can be large, 4 is used in an attempt to form operands of a similar order of magnitude, which creates scope for the use of more efficient multiplication-algorithms. Multiplication is required for the addition of \ numbers by cross-multiplication; this function is unlikely to be useful for other numbers.4factory9The ratio of the original list-length at which to bisect.factory_For efficiency, the list will not be bisected, when it's length has been reduced to this value.factoryThe list on which to operate.factoryThe resulting scalar.5factory9The ratio of the original list-length at which to bisect.factory_For efficiency, the list will not be bisected, when it's length has been reduced to this value.factory&The numbers whose product is required.factoryThe resulting product.6factory9The ratio of the original list-length at which to bisect.factory_For efficiency, the list will not be bisected, when it's length has been reduced to this value.factory"The numbers whose sum is required.factoryThe resulting sum.2345632456Nonefactory Does for 7, what  does for type %, in that it makes it an instance of  under addition.factoryAccess the polymorphic payload.factory Does for 7, what  does for type %, in that it makes it an instance of  under multiplication.factoryAccess the polymorphic payload.7factory<Define both the operations applicable to all members of the ring, and its mandatory members.Minimal definition; 8, 9, :, ;, <.?factoryRaise a ring1-member to the specified positive integral power.]Exponentiation is implemented as a sequence of either squares of, or multiplications by, the ring -member;  8https://en.wikipedia.org/wiki/Exponentiation_by_squaring.@factory Returns the product of the list of ring -members.Afactory Returns the sum of the list of ring -members.8factory(Addition of two members; required to be  commutative;  +https://en.wikipedia.org/wiki/Commutativity.9factoryMultiplication of two members.:factoryThe operand required to yield zero under addition;  .https://en.wikipedia.org/wiki/Additive_inverse.;factoryThe identity-member under multiplication;  9https://mathworld.wolfram.com/MultiplicativeIdentity.html.<factoryThe identity-member under addition (AKA zero);  /https://en.wikipedia.org/wiki/Additive_identity.=factorySubtract the two specified ring -members.>factorySquare the ring. 798=>:;<?@A 798=>:;<@A?8697=6?8NoneJfactoryDefines a sub-class of 7#, in which division is implemented.Lfactory Returns the quotient&, after division of the two specified Js.Mfactory Returns the  remainder&, after division of the two specified Js.Nfactory if the two specified Js are  congruent in modulo-arithmetic, where the modulus is a third J. 3http://www.usna.edu/Users/math/wdj/book/node74.html.OfactoryTrue if the second operand divides the first.KfactoryKDivides the first operand by the second, to yield a pair composed from the quotient and the  remainder.Lfactory Numerator.factory Denominator.Mfactory Numerator.factory Denominator.NfactoryLHS.factoryRHS.factoryModulus.Ofactory Numerator.factory Denominator.JKLMNOJKLMNONone1PfactoryThe type of an arbitrary  univariateL polynomial; actually it's more general, since it permits negative powers ( 0https://en.wikipedia.org/wiki/Laurent_polynomials). It can't describe  multivariate, polynomials, which would require a list of  exponents. Rather than requiring the exponent to implement the  type-class 9, this is implemented at the function-level, as required.#The structure permits gaps between  exponents , in which  coefficientsW are inferred to be zero, thus enabling efficient representation of sparse polynomials. CAVEAT: the  is required to; be ordered by  descending exponent (ie. reverse  ,https://en.wikipedia.org/wiki/Monomial_order9); have had zero coefficients removed; and to have had like; terms merged; so the raw data-constructor isn't exported.factory Accessor.factoryThe guts of a P.Qfactory+Transforms the data behind the constructor.CAVEAT: similar to :;, but P isn't an instance of :<& since we may want to operate on both type-parameters.%CAVEAT: the caller is required to re-TT the resulting polynomial depending on the nature of the transformation of the data.Rfactory7Returns the number of non-zero terms in the polynomial.Sfactory#Return the highest-degree monomial.factoryRemoves terms with a  coefficient of zero.Tfactory Sorts into descending order of exponents, groups like exponents, and calls .UfactoryConstructs an arbitrary zeroeth-degree polynomial, ie. independent of the  indeterminate.VfactoryConstructs an arbitrary first-degree polynomial.Wfactory+Smart constructor. Constructs an arbitrary  polynomial.Xfactory Constructs a  polynomial with zero terms.YfactoryConstructs a constant monomial, independent of the  indeterminate.factory True if all  exponents6 are in the order defined by the specified comparator.Zfactory True if the  exponents of successive terms are in  ascending order.[factory True if the  exponents of successive terms are in  descending order.factoryTrue if no term has a  coefficient of zero.\factoryTrue if no term has a  coefficient of zero and the  exponents of successive terms are in  descending order.]factory if the leading coefficient is one. >https://en.wikipedia.org/wiki/Monic_polynomial#Classifications.^factoryTrue if there are zero terms._factory!True if there's exactly one term.`factory True if all  exponents are positive integers as required.afactory if the two specified  polynomials are  congruent in modulo -arithmetic. =https://planetmath.org/encyclopedia/PolynomialCongruence.html.bfactory Return the degree (AKA order ) of the  polynomial. 4https://en.wikipedia.org/wiki/Degree_of_a_polynomial. 3https://mathworld.wolfram.com/PolynomialDegree.html.cfactoryScale-up the specified  polynomial by a constant monomial factor. 3https://en.wikipedia.org/wiki/Scalar_multiplication.dfactoryRaise a  polynomial5 to the specified positive integral power, but using modulo -arithmetic.+Whilst one could naively implement this as (x Data.Ring.=^ n)  mI, this will result in arithmetic operatons on unnecessarily big integers.efactory#Reduces all the coefficients using modular arithmetic.ffactory Evaluate the  polynomial at a specific  indeterminate.ACAVEAT: requires positive exponents; but it wouldn't really be a  polynomial otherwise.If the  polynomial4 is very sparse, this may be inefficient, since it memoizes8 the complete sequence of powers up to the polynomial's degree.gfactoryConvert the type of the  coefficients.hfactoryDefines the ability to divide  polynomials.ifactoryMakes  Polynomial a 7 , over the field composed from all possible  coefficients;  -https://en.wikipedia.org/wiki/Polynomial_ring.Vfactory Gradient.factory Constant.afactoryLHS.factoryRHS.factoryModulus.dfactory The base.factory0The exponent to which the base should be raised.factory The modulus.factory The result.efactoryModulus.ffactoryThe  indeterminate.factory The Result.PQRSTUVWXYZ[\]^_`abcdefgPXYfbSQeTdgRUVWcaZ[]_\`^c7 None4lfactory A type of P, in which the  leading term is required to have a  coefficient of one.nfactory+Smart constructor. Constructs an arbitrary monic polynomial.lmnlmn NoneO sfactory)Each element of this list represents one  prime-factor, expressed as an  exponential with a prime base, of the original integer.(Whilst it only makes sense for both the base and exponentP to be integral, these constrains are applied at the function-level as required.tfactory'Sorts a list representing a product of  prime factors by increasing base. Multiplies  s of similar base.factory Multiplies  s of similar base.ufactory Insert a (, into a list representing a product of  prime factors), multiplying with any incumbent of like base.(The list should be sorted by increasing base.Preserves the sort-order.RCAVEAT: this is tolerably efficient for sporadic insertion; to insert a list, use v.vfactory4Multiplies two lists each representing a product of  prime factors, and sorted by increasing base.Preserves the sort-order.factoryInvert the product of a list  prime factors, by negating each of the  exponents.wfactory2Divides two lists, each representing a product of  prime factors, and sorted by increasing base.Preserves the sort-order.xfactoryRaise the product of a list  prime factors to the specified power.XCAVEAT: this merely involves raising each element to the specified power; cf. raising a  polynomial to a power.factorySum the  exponentsL of the specified list; as required to multiply exponentials with identical base.yfactoryMultiply a list of  prime factors.wfactory The list of  prime factors in the  numerator.factory The list of  prime factors in the  denominator.factory The ratio of  numerator and  denominator , after like  prime factors are cancelled.yfactoryThe list on which to operate.factory The result.stuvwxysuytvwxv7w7x8 SafeQ]zfactory"Defines the methods expected of a  factorial -algorithm.z{z{ SafeTv|factoryA constant ordered list of the  Fibonacci -numbers.}factoryThe subset of |, indexed by a prime-number. <https://primes.utm.edu/glossary/page.php?sort=FibonacciPrime.|}|} Safeb@~factory%Merely to enhance self-documentation.CAVEAT: whilst  and ~# can be independent types for both  and , they interact for other hyper-exponents.factory%Merely to enhance self-documentation."CAVEAT: whilst it may appear that  could be non-, the recursive definition for hyper-exponents above , prevents this.factory Returns the  power-tower of the specified base;  -https://mathworld.wolfram.com/PowerTower.html.A synonym for  tetration;  'https://en.wikipedia.org/wiki/Tetration,  3https://www.tetration.org/Fractals/Atlas/index.html.factoryThe hyperoperation -sequence;  ,https://en.wikipedia.org/wiki/Hyperoperation.factoryThe Ackermann-Peter -function;  Bhttps://en.wikipedia.org/wiki/Ackermann_function#Ackermann_numbers.factoryTrue if !hyperoperation base hyperExponent' has the same value for each specified rank. ~ ~NonesfactoryThe algorithms by which  factorial has been implemented.factoryThe integers from which the  factorial# is composed, are multiplied using Data.Interval.product'.factoryThe  prime factors of the  factorialL are extracted, then raised to the appropriate power, before multiplication.factory Returns the  prime factors , of the  factorial of the specifed integer.EPrecisely all the primes less than or equal to the specified integer n, are included in n!T; only the multiplicity of each of these known prime components need be determined. 5https://en.wikipedia.org/wiki/Factorial#Number_theory.CAVEAT: currently a hotspot.factoryThe number of times a specific prime, can be factored from the  factorial of the specified integer.General purpose prime-factorisation has exponential time-complexity , so use Legendre's Theorem, which relates only to the  prime factors of  factorials. Hhttps://www.proofwiki.org/wiki/Multiplicity_of_Prime_Factor_in_Factorial.factory Returns the rising factorial; 2https://mathworld.wolfram.com/RisingFactorial.htmlfactory Returns the falling factorial; 3https://mathworld.wolfram.com/FallingFactorial.htmlfactory$Returns the ratio of two factorials.HIt is more efficient than evaluating both factorials, and then dividing.<For more complex combinations of factorials, such as in the Binomial coefficient, extract the  prime factors using ( then manipulate them using the module Data.PrimeFactors, and evaluate it using by Data.PrimeFactors.product'.factoryThe number, whose  factorial is to be factorised.factoryThe base and exponent of each  prime factor in the  factorial, ordered by increasing base (and decreasing exponent).factoryA prime number.factory:The integer, the factorial of which the prime is a factor.factory6The number of times the prime occurs in the factorial.factory@The lower bound of the integer-range, whose product is returned.factory*The number of integers in the range above.factory The result.factory@The upper bound of the integer-range, whose product is returned.factory,The number of integers in the range beneath.factory The result.factoryThe  numerator.factoryThe  denominator.factoryThe resulting fraction.7Safe`factory-Defines a series corresponding to a specific BBP -formula.factoryGThe constant numerators from which each term in the series is composed.factoryYGenerates the term-dependent denominators from which each term in the series is composed.factoryRThe ratio by which the sum to infinity of the series, must be scaled to result in Pi.factory:The geometric ratio, by which successive terms are scaled.Safefactory/Defines the parameters of this specific series.Safefactory/Defines the parameters of this specific series.None factoryA specialisation of .factoryA specialisation of .factory Combine a queue , with a map/, to form a repository to hold prime-multiples.factory!A map of the multiples of primes.factory,An ordered queue of the multiples of primes.factoryThe  counterpart to =>.factoryThe  counterpart to =?.CAVEAT: because  Data.List.tail []  returns an error, whereas  tail' Data.Sequence.empty  returns *, this function is for internal use only.factoryA refinement of the Sieve Of Eratosthenes4, which pre-sieves candidates, selecting only those coprime6 to the specified short sequence of low prime-numbers.:The short sequence of initial primes are represented by a '', of parameterised, but static, size;  1https://en.wikipedia.org/wiki/Wheel_factorization.YThe algorithm requires one to record multiples of previously discovered primes, allowing  composite+ candidates to be eliminated by comparison. Because each list of multiples, starts with the squareq of the prime from which it was generated, the vast majority will be larger than the maximum prime ultimately demanded, and the effort of constructing and storing this list, is consequently wasted. Many implementations solve this, by requiring specification of the maximum prime required, thus allowing the construction of redundant lists of multiples to be avoided.NThis implementation doesn't impose that constraint, leaving a requirement for rapid! storage, which is supported by  appending the list of prime-multiples, to a queue?. If a large enough candidate is ever generated, to match the head of the list of prime-multiples, at the head of this queue, then the whole list( of prime-multiples is dropped from the queue , but the tail of this listq of prime-multiples, for which there is now a high likelyhood of a subsequent match, must now be re-recorded. A queue" doesn't support efficient random  insertion, so a T is used for these subsequent multiples. This solution is faster than just using a Data.PQueue.Min.CAVEAT: has linear O(n) space-complexity.factoryA specialisation of , which approximately doubles* the speed and reduces the space required.'CAVEAT: because the algorithm involves squaresP of primes, this implementation will overflow when finding primes greater than 2^16 on a 32-bit machine.SafefactoryMainly for convenience.factoryJust for convenience.factory Iteratively generate sequential squares<, from the specified initial value, based on the fact that (x + 1)^2 = x^2 + 2 * x + 1.AThe initial value doesn't need to be either positive or integral.factoryJust for convenience.factoryJRaise an arbitrary number to the specified positive integral power, using modular arithmetic.2Implements exponentiation as a sequence of either squares" or multiplications by the base;  8https://en.wikipedia.org/wiki/Exponentiation_by_squaring. 4https://en.wikipedia.org/wiki/Modular_exponentiation.factory Lower bound.factory [(n, n^2)] .factoryBase.factoryModulus.factoryResult.NonefactoryReturns  (Just . sqrt) if the specified integer is a  square number (AKA perfect square). +https://en.wikipedia.org/wiki/Square_number. /https://mathworld.wolfram.com/SquareNumber.html.(Math.Power.square . sqrt)` is expensive, so the modulus of the operand is tested first, in an attempt to prove it isn't a perfect squarer. The set of tests, and the valid moduli within each test, are ordered to maximize the rate of failure-detection.factory An integer (> 1)- which can be expressed as an integral power (> 1) of a smaller natural number.CAVEAT: zero and one% are normally excluded from this set. +https://en.wikipedia.org/wiki/Perfect_power. /https://mathworld.wolfram.com/PerfectPower.html.#A generalisation of the concept of perfect squares, in which only the exponent '2' is significant.factoryA specialisation of .SafeRfactory For each prime3, the infinite list of candidates greater than its square#, is filtered for indivisibility;  Rhttp://www.haskell.org/haskellwiki/Prime_numbers#Turner.27s_sieve_-_Trial_division.$CAVEAT: though one can easily add a @A, it proved counterproductive.NoneCfactoryDefines the types of  quadraticC, available to test the potential primality of a candidate integer.factory/Suitable for primality-testing numbers meeting (n  4 == 1).factory/Suitable for primality-testing numbers meeting (n  6 == 1).factory/Suitable for primality-testing numbers meeting (n  12 == 11).factoryUThere's no polynomial which can assess primality, because the candidate is composite.factoryTThe constant modulus used to select the appropriate quadratic for a prime candidate.factoryFThe constant list of primes factored-out by the unoptimised algorithm.factoryHThe constant number of primes factored-out by the unoptimised algorithm.factoryETypically the set of primes which have been built into the specified wheel, but never fewer than .factory+The period over which the data returned by  repeats.factory$Defines which, if any, of the three  quadratics: is appropriate for the primality-test for each candidate.Since this algorithm uses modular arithmetic, the range! of results repeat after a short domain related to the modulus. Thus one need calculate at most one period of this cycle, but fewer if the maximum prime required falls within the first cycle of results.Because the results are bounded%, they're returned in a zero-indexed arrays, to provide efficient random access; the first few elements should never be required, but it makes query clearer. ,https://en.wikipedia.org/wiki/Sieve_of_Atkin.factory#The constant, infinite list of the squares, of integers increasing from 1.factory Returns the ordered list of those values with an odd( number of occurrences in the specified  unordered list.CAVEAT: this is expensive in both execution-time and space. The typical imperative-style implementation accumulates polynomial-solutions in a  mutable arrayM indexed by the candidate integer. This doesn't translate seamlessly to the pure functional domain where arrays naturally immutable, so we sort a list{ of polynomial-solutions, then measure the length of the solution-spans, corresponding to viable candidates. Regrettably,  (implemented in GHC by  mergesort) has a time-complexity  O(n*log n)( which is greater than the theoretical O(n) of the whole Sieve of Atkin; GHC's old qsort!-implementation is even slower :(factoryDReturns the ordered list of solutions aggregated from each of three bivariate quadratics;  z = f(x, y).YFor a candidate integer to be prime, it is necessary but insufficient, that there are an odd number of solutions of value  candidate.`At most one of these three polynomials is suitable for the validation of any specific candidate z, depending on lookupPolynomialTypeJ. so the three sets of solutions are mutually exclusive. One coordinate (x, y)?, can have solutions in more than one of the three polynomials.1This algorithm exhaustively traverses the domain (x, y), for resulting z of the required modulus. Whilst it tightly constrains the bounds of the search-space, it searches the domain methodically rather than intelligently.factoryGenerates the bounded list of multiples, of the square> of the specified prime, skipping those which aren't required.factoryGenerates the constant bounded list of  prime-numbers. 0https://cr.yp.to/papers/primesieves-19990826.pdffactoryA specialisation of ?, which reduces both the execution-time and the space required.factoryThe maximum prime required.factory"The maximum prime-number required.factory@Used to generate the gaps between prime multiples of the square.factoryThe prime.factoryThe maximum bound.factory@Other implementations effectively use a hard-coded value either 2 or 3, but 6 seems better.factoryThe maximum prime required.factoryThe bounded list of primes.Safe+ factory0A number of decimal digits; presumably positive.factoryThe rate of convergence;  1https://en.wikipedia.org/wiki/Rate_of_convergence.factoryThe order of convergence;  1https://en.wikipedia.org/wiki/Rate_of_convergence.factoryLinear1 convergence-rate; which may be qualified by the rate of convergence.factory Quadratic convergence-rate.factoryCubic convergence-rate.factoryQuartic convergence-rate.factoryXThe predicted number of iterations, required to achieve a specific accuracy, at a given order of convergence.factoryThe predicted number of terms which must be extracted from a series, if it is to converge to the required accuracy, at the specified linear convergence-rate.The convergence-rate< of a series, is the error in the series after summation of (n+1)th) terms, divided by the error after only n9 terms, as the latter tends to infinity. As such, for a  convergent] series (in which the error get smaller with successive terms), it's value lies in the range 0 .. 1. 1https://en.wikipedia.org/wiki/Rate_of_convergence.factory5Rounds the specified number, to a positive number of .factory7Promotes the specified number, by a positive number of .factory Reduces a : to the minimal form required for the specified number of  fractionalH decimal places; irrespective of the number of integral decimal places.A  approximation to an irrational number, may be very long, and provide an unknown excess precision. Whilst this doesn't sound harmful, it costs in performance and memory-requirement, and being unpredictable isn't actually useful.factory&The precision of the initial estimate.factoryThe required precision.factory0The additional number of correct decimal digits.factoryAThe number of places after the decimal point, which are required. Safe:factory#Categorises the various algorithms.factoryAlgorithms based on the Arithmetic-geometric Mean.factory Lhttps://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80%93Plouffe_formula.factory 3https://en.wikipedia.org/wiki/Borwein%27s_algorithm.factory &http://www.pi314.net/eng/ramanujan.php.factory$Algorithms from which the digits of Pi slowly drip, one by one.factory"Defines the methods expected of a Pi -algorithm./Most of the implementations naturally return a 0, but the spigot-algorithms naturally produce a [Int]; though representing PiF as a big integer with the decimal point removed is clearly incorrect.Since representing Pi as either a  or promoted to an *, is inconvenient, an alternative decimal -representation is provided.factoryReturns the value of Pi as a .factoryReturns the value of Pi8, promoted by the required precision to form an integer.factoryReturns the value of Pi as a decimal . SafeAfactorylDefines a series composed from a sum of terms, each one of which is the product of a coefficient and a base.9The coefficents and bases of the series are described in  Horner form; .Pi = c1 + (b1 * (c2 + b2 * (c3 + b3 * (...)))).factory^The width of the spigot-table, required to accurately generate the requested number of digits.factory Combines  and <, and as a side-effect, expresses the ratio in lowest terms.Safe[factory(Coerce the polymorphic type returned by  to our specific requirements.factoryCoerce the polymorphic type % to suit the base used in our series.factory.The type in which all arithmetic is performed.>A small dynamic range, 32 bits or more, is typically adequate.factory:The constant base in which we want the resulting value of Pi to be expressed.factory{For a digit on one row of the spigot-table, add any numerator carried from the similar calculation one column to the right.gDivide the result of this summation, by the denominator of the base, to get the quotient and remainder.Determine the quantity to carry to the similar calculation one column to the left, by multiplying the quotient by the numerator of the base.factoryFold h, from right to left, over the columns of a row in the spigot-table, continuously checking for overflow.mRelease any previously withheld result-digits, after any adjustment for overflow in the current result-digit.kWithhold the current result-digit until the risk of overflow in subsequent result-digits has been assessed.Call .factory.Multiply the remainders from the previous row.Zip them with the constant bases, with an addition one stuck on the front to perform the conversion to decimal, to create a new row of the spigot-table.Call .factoryInitialises a spigot-table with the row of .]Ensures that the row has suffient terms to accurately generate the required number of digits.?Extracts only those digits which are guaranteed to be accurate.%CAVEAT: the result is returned as an !, i.e. without any decimal point.factory Data-row.Safe\factory$Defines a series which converges to Pi.Safe]factory$Defines a series which converges to Pi.Safeafactory Define those Spigot(-algorithms which have been implemented.factoryA continued fraction discovered by Gosper.factoryA continued fraction discovered by  Rabinowitz and Wagon.Safefofactory-Defines a series corresponding to a specific  Ramanujan -formula.factoryGThe sequence of terms, the sum to infinity of which defines the series.factoryTThe ratio by which the sum to infinity of the sequence, must be scaled to result in Pi.factory!The expected number of digits of Pi, per term in the series.Safei factory-Defines a series corresponding to a specific Borwein -formula.factory!The expected number of digits of Pi, per term in the series. NoneofactoryReturns Pi5, accurate to the specified number of decimal digits.factoryThis PiC-algorithm is parameterised by the type of other algorithms to use.factory The specific  square-root( algorithm to apply to the above series.factory The specific  factorial(-algorithm to apply to the above series.factory&The number of decimal digits required.!Safefactory>Defines the methods expected of a primality-testing algorithm.factory# if the two specified integers are relatively prime<, i.e. if they share no common positive factors except one.1 and -1 are the only numbers which are coprime to themself. %https://en.wikipedia.org/wiki/Coprime. 2https://mathworld.wolfram.com/RelativelyPrime.html.factoryTests Fermat's Little Theorem> for all applicable values, as a probabilistic primality-test. 7https://en.wikipedia.org/wiki/Fermat%27s_little_theorem. 3https://en.wikipedia.org/wiki/Fermat_primality_test. 0https://en.wikipedia.org/wiki/Fermat_pseudoprime.*CAVEAT: this primality-test fails for the Carmichael numbers.-TODO: confirm that all values must be tested.factoryA Carmichael number is an odd  composite number which satisfies Fermat's little theorem. /https://en.wikipedia.org/wiki/Carmichael_number. 3https://mathworld.wolfram.com/CarmichaelNumber.html.factoryAn ordered list of the  Carmichael numbers;  /https://en.wikipedia.org/wiki/Carmichael_number."None factory"Defines the methods expected of a  factorisation -algorithm.factory[The upper limit for a prime to be considered as a candidate factor of the specified number.+One might naively think that this limit is (x  2)0 for an even number, but though a prime-factor greater than the  square-root' of the number can exist, its smaller cofactor3 decomposes to a prime which must be less than the  square-root.N.B.: rather then using (primeFactor <= sqrt numerator)X to filter the candidate prime-factors of a given numerator, one can alternatively use (numerator >= primeFactor ^ 2)D to filter what can potentially be factored by a given prime-factor.OCAVEAT: suffers from rounding-errors, though no consequence has been witnessed.factory>A constant, zero-indexed, conceptually infinite, list, of the smoothness of all positive integers. +https://en.wikipedia.org/wiki/Smooth_number. /https://mathworld.wolfram.com/SmoothNumber.html.factory=A constant, zero-indexed, conceptually infinite, list of the  power-smoothness of all positive integers. ?https://en.wikipedia.org/wiki/Smooth_number#Powersmooth_numbers.factoryFilters !, to derive the constant list of Hamming-numbers. ,https://en.wikipedia.org/wiki/Regular_number.factoryEuler's Totient for a power of a prime-number.By Olofsson; (phi(n^k) = n^(k - 1) * phi(n)) and since (phi(prime) = prime - 1)lCAVEAT: checks neither the primality nor the bounds of the specified value; therefore for internal use only.factoryThe number of coprimes6 less than or equal to the specified positive integer. 8https://en.wikipedia.org/wiki/Euler%27s_totient_function. 2https://mathworld.wolfram.com/TotientFunction.html.AKA EulerPhi.factory=A constant, zero-indexed, conceptually infinite, list of the  small omega numbers (i.e. the number of distinct prime factors); cf.  big omega. Hhttps://oeis.org/wiki/Omega%28n%29,_number_of_distinct_primes_dividing_n. 7https://mathworld.wolfram.com/DistinctPrimeFactors.html Mhttps://planetmath.org/encyclopedia/NumberOfDistinctPrimeFactorsFunction.html.factory/A constant, conceptually infinite, list of the  square-free3 numbers, i.e. those which aren't divisible by any perfect square. 1https://en.wikipedia.org/wiki/Square-free_integer.factory The operand #NonepfactoryThe smallest positive integral power to which the specified integral base must be raised, to be congruent with one, in the specified modular arithmetic. Based on  9https://rosettacode.org/wiki/Multiplicative_order#Haskell. 2https://en.wikipedia.org/wiki/Multiplicative_order. 6https://mathworld.wolfram.com/MultiplicativeOrder.html.factoryBase.factoryModulus.factoryResult.$NonefactoryUses Trial Divisiont, to determine whether the specified candidate is indivisible by all potential denominators from the specified list.factory3For each candidate, confirm indivisibility, by all primes smaller than its  square-root.,The candidates to sieve, are generated by a '', of parameterised, but static, size;  1https://en.wikipedia.org/wiki/Wheel_factorization.factoryThe numerator.factory4The denominators of which it must not be a multiple.%NoneafactoryAThe algorithms by which prime-factorisation has been implemented.factory <https://en.wikipedia.org/wiki/Dixon%27s_factorization_method.factory =https://en.wikipedia.org/wiki/Fermat%27s_factorization_method.factory ,https://en.wikipedia.org/wiki/Trial_division.factory <https://en.wikipedia.org/wiki/Dixon%27s_factorization_method.factory =https://en.wikipedia.org/wiki/Fermat%27s_factorization_method. =https://mathworld.wolfram.com/FermatsFactorizationMethod.html. 3https://en.wikipedia.org/wiki/Congruence_of_squares. i = f1 * f2Y Assume a non-trivial factorisation, ie. one in which both factors exceed one. => +i = (larger + smaller) * (larger - smaller)9 Represent the co-factors as a sum and difference. => i = larger^2 - smaller^2' Which has an integral solution if i is neither even nor a perfect square. => sqrt (larger^2 - i) = smaller Search for larger), which results in an integral value for smaller.Given that the smaller factor f2, can't be less than 3 (i isn't even), then the larger f1, can't be greater than (i  3). So: (f2 >= 3) && (f1 <= i  3)1 Two equations which can be used to solve for larger. => 2(larger - smaller >= 3) && (larger + smaller <= i  3) Add these to eliminate smaller. => larger <= (i + 9)  6) The upper bound of the search-space.=This algorithm works best when there's a factor close to the  square-root.factory4Decomposes the specified integer, into a product of prime-factors, using  <https://mathworld.wolfram.com/DirectSearchFactorization.html, AKA  ,https://en.wikipedia.org/wiki/Trial_division.+This works best when the factors are small.&NonefactoryThe algorithms by which  primality-testing has been implemented.factory 0https://en.wikipedia.org/wiki/AKS_primality_test.factory Ahttps://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test.factoryAn implementation of the Agrawal-Kayal-Saxena primality-test;  0https://en.wikipedia.org/wiki/AKS_primality_test , using the Lenstra and  Pomerance algorithm.JCAVEAT: this deterministic algorithm has a theoretical time-complexity of O(log^6)J, and therefore can't compete with the performance of probabilistic ones.The formal polynomials9 used in this algorithm, are conceptually different from polynomial functions; the  indeterminateM and its powers, are merely used to name a sequence of pigeon-holes in which  coefficientsu are stored, and is never substituted for a specific value. This mind-shift, allows one to introduce concepts like modular arithmetic on polynomials, which merely represent an operation on their coefficients and the pigeon-hole in which they're placed. /Manindra Agrawal, Neeraj Kayal and Nitin Saxena Bhttps://www.cse.iitk.ac.in/users/manindra/algebra/primality_v6.pdf.%H. W. Lenstra, Jr. and Carl Pomerance :https://www.math.dartmouth.edu/~carlp/PDF/complexity12.pdf.Salembier and Southerington `https://ece.gmu.edu/courses/ECE746/project/F06_Project_resources/Salembier_Southerington_AKS.pdf,R. Crandall and J. Papadopoulos )https://images.apple.com/acg/pdf/aks3.pdf,Andreas Klappenecker -https://faculty.cs.tamu.edu/klappi/629/aks.ps,Vibhor Bhatt and G. K. Patra Fhttps://www.cmmacs.ernet.in/cmmacs/Publications/resch_rep/rrcm0307.pdf,factoryUses the specified base in an attempt to prove the  compositeness of an integer.This is the opposite of the  Miller Test;  7https://mathworld.wolfram.com/MillersPrimalityTest.html.If the result is , then the candidate is  compositec; regrettably the converse isn't true. Amongst the set of possible bases, over three-quarters are  witnesses to the compositeness of a  composite3 candidate, the remainder belong to the subset of liarsp. In consequence, many false results must be accumulated for different bases, to convincingly identify a prime.factoryRepeatedly calls ;, to progressively increase the probability of detecting a  compositeG number, until ultimately the candidate integer is proven to be prime.QShould all bases be tested, then the test is deterministic, but at an efficiency lower% than performing prime-factorisation.qThe test becomes deterministic, for any candidate integer, when the number of tests reaches the limit defined by  Eric Bach.aA testing of smaller set of bases, is sufficient for candidates smaller than various thresholds;  *https://primes.utm.edu/prove/prove2_3.html. 9https://en.wikipedia.org/wiki/Miller-Rabin_primality_test. Dhttps://mathworld.wolfram.com/Rabin-MillerStrongPseudoprimeTest.html 4https://mathworld.wolfram.com/StrongPseudoprime.html. https://oeis.org/A014233,  https://oeis.org/A006945.factoryCandidate integer.factoryBase.'Safefactory"Defines the methods expected of a  prime-number generator.factory(Returns the constant list, defining the  Primorial. 'https://en.wikipedia.org/wiki/Primorial. ,https://mathworld.wolfram.com/Primorial.html.factory.Returns the constant ordered infinite list of Mersenne numbers.^Only the subset composed from a prime exponent is returned; which is a strict superset of the Mersenne Primes. ,https://en.wikipedia.org/wiki/Mersenne_prime. 1https://mathworld.wolfram.com/MersenneNumber.htmlfactory/Returns the constant, infinite, list of primes.(Nonefactory=The implemented methods by which the primes may be generated. factoryThe Sieve of Atkin, optimised using a '@ of optimal size, for primes up to the specified maximum bound;  ,https://en.wikipedia.org/wiki/Sieve_of_Atkin. factoryThe Sieve of Eratosthenes ( 3https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes), optimised using a '. factory3For each candidate, confirm indivisibility, by all primes smaller than its  square-root, optimised using a '. factory For each prime3, the infinite list of candidates greater than its square", is filtered for indivisibility;  Shttps://www.haskell.org/haskellwiki/Prime_numbers#Turner.27s_sieve_-_Trial_division. factory.          )NoneIefactory9Defines a common interface for probability-distributions.factory Describes "discrete probability-distributions;  Vhttps://en.wikipedia.org/wiki/List_of_probability_distributions#Discrete_distributions.factory Defines an Poisson -distribution with a particular lambda;  2https://en.wikipedia.org/wiki/Poisson_distribution.factory Defines an  Geometric8-distribution with a particular probability of success;  4https://en.wikipedia.org/wiki/Geometric_distribution.factory Describes $continuous probability-distributions;  Xhttps://en.wikipedia.org/wiki/List_of_probability_distributions#Continuous_distributions.factory Defines an  Exponential -distribution with a particular lambda;  6https://en.wikipedia.org/wiki/Exponential_distribution.factoryQDefines a distribution whose logarithm is normally distributed with a particular mean & variance;  'https://en.wikipedia.org/wiki/Lognormal.factory Defines a Normal -distribution with a particular mean & variance;  1https://en.wikipedia.org/wiki/Normal_distribution.factory Defines a Uniform-distribution within a closed interval;  2https://en.wikipedia.org/wiki/Uniform_distribution. factoryDThe maximum integer which can be accurately represented as a Double.factorynDetermines the minimum positive floating-point number, which can be represented by using the parameter's type.:Only the type of the parameter is relevant, not its value.!factoryConverts a pair of independent uniformly distributed random numbers, within the semi-closed unit interval (0,1], to a pair of independent normally distributed! random numbers, of standardized mean=0, and variance=1. :https://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform."factoryYUses the supplied random-number generator, to generate a conceptually infinite list, of normally distributed# random numbers, with standardized mean=0, and variance=1. 1https://en.wikipedia.org/wiki/Normal_distribution,  5https://mathworld.wolfram.com/NormalDistribution.html.factoryStretches and shifts a  distribution to achieve the required mean and standard-deviation.#factoryUses the supplied random-number generator, to generate a conceptually infinite population, with the specified continuous probability-distribution.factoryUses the supplied random-number generator, to generate a conceptually infinite population, of random integers conforming to the Poisson distribution;  2https://en.wikipedia.org/wiki/Poisson_distribution.5CAVEAT: uses an algorithm by Knuth, which having a linear time-complexity in lambda,, can be intolerably slow; also, the term exp $ negate lambda, underflows for large lambda; so for large lambda., this implementation returns the appropriate .$factoryUses the supplied random-number generator, to generate a conceptually infinite population, with the specified discrete probability-distribution.factoryA generator of uniformly distributed random numbers.factorydCAVEAT: the integers generated for discrete distributions are represented by a fractional type; use $ if this is a problem.factoryThe theoretical mean.factory#The theoretical standard-deviation.factoryThe theoretical variance.!factory Independent, uniformly distributed* random numbers, which must be within the semi-closed unit interval, (0,1].factory Independent, normally distributed# random numbers, with standardized mean=0 and variance=1.#factoryA generator of uniformly distributed random numbers.factory/Defines the required approximate value of both mean and variance.$factoryA generator of uniformly distributed random numbers. !"#$ !"#$*SafeVfactory6Characters used to represent the digits of numbers in (-36 <= base <= 36).factory"Constant random-access lookup for .factoryConstant reverse-lookup for ./factory_Convert the specified integral quantity, to an alternative base, and represent the result as a .:Both negative integers and negative bases are permissible.The conversion to  can only succeed where printable and intelligible characters exist to represent all digits in the chosen base; which in practice means (-36 <= base <= 36).0factory Convert the A-representation of a number in the specified base, to an integer.9Both negative numbers and negative bases are permissible.1factory +https://mathworld.wolfram.com/DigitSum.html. 'https://en.wikipedia.org/wiki/Digit_sum.2factory *https://en.wikipedia.org/wiki/Digital_root./012120/+Safet! 3factoryeThe interface required to iterate, from an estimate of the required value, to the next approximation.6factory"Defines the methods expected of a  square-root algorithm.9factoryContains an estimate for the  square-root of a value, and its accuracy.:factory<The result-type; actually, only the concrete return-type of +, stops it being a polymorphic instance of .factory Generalise  to operate on any  operand.;factoryUses L-precision floating-point arithmetic, to obtain an initial estimate for the  square-root, and its accuracy.<factory"The signed difference between the square of an estimate for the  square-root of a value, and that value.&Positive when the estimate is too low.0CAVEAT: the magnitude is twice the error in the  square-root.=factory'True if the specified estimate for the  square-root , is precise.>factory)For a given value and an estimate of its  square-root6, returns the number of decimals digits to which the  square-root, is accurate; including the integral digits.?CAVEAT: the result returned for an exact match has been bodged.4factoryThe value for which the  square-root is required; y.factoryThe current estimate; x(n).factoryAn improved estimate; x(n+1).5factoryBThe ultimate ratio of successive terms as the iteration converges.7factory(An initial estimate from which to start.factoryThe required precision.factory The value for which to find the  square-root.factory$Returns an improved estimate of the  square-rootb, found using the specified algorithm, accurate to at least the required number of decimal digits.8factoryThe required precision.factory The value for which to find the  square-root.factoryReturns an estimate of the  square-rootb, found using the specified algorithm, accurate to at least the required number of decimal digits. 3456789:;<=> 678345:9><;=,Noneu?factoryDefines the parameters of the  Ramanujan series.??-Nonev@factoryDefines the parameters of the  Chudnovsky series.@@.NonewAfactoryDefines the parameters of the Borwein series.AA/None{Bfactory Define those Borwein$-series which have been implemented.TThough currently there's only one, provision has been made for the addition of more.Cfactory 3https://en.wikipedia.org/wiki/Borwein%27s_algorithm.BCBC0NoneUIfactoryEncapsulates both  arithmetic and  geometric means.JfactoryThe type of the geometric mean;  ,https://en.wikipedia.org/wiki/Geometric_mean.KfactoryThe type of the arithmetic mean;  -https://en.wikipedia.org/wiki/Arithmetic_mean.Lfactory Accessor.Mfactory Accessor.Nfactory0Returns an infinite list which converges on the Arithmetic-geometric mean.Ofactory$Returns the bounds within which the I has been constrained.PfactoryChecks that both means# are positive, as required for the geometric mean to be consistently real.IJKLMNOPKJINOLMP1NoneJQfactoryReturns Pi5, accurate to the specified number of decimal digits.This algorithm is based on the arithmetic-geometric mean of 1 and  (1 / sqrt 2)], but there are many confusingly similar formulations. The algorithm I've used here, where a is the arithmetic mean and g is the geometric mean-, is equivalent to other common formulations:  pi = (a[N-1] + g[N-1])^2 / (1 - sum [2^n * (a[n] - g[n])^2]) where n = [0 .. N-1] => 4*a[N]^2 / (1 - sum [2^n * (a[n]^2 - 2*a[n]*g[n] + g[n]^2)]) => 4*a[N]^2 / (1 - sum [2^n * (a[n]^2 + 2*a[n]*g[n] + g[n]^2 - 4*a[n]*g[n])]) => 4*a[N]^2 / (1 - sum [2^n * ((a[n] + g[n])^2 - 4*a[n]*g[n])]) => 4*a[N]^2 / (1 - sum [2^(n-1) * 4 * (a[n-1]^2 - g[n-1]^2)]) where n = [1 .. N] => 4*a[N]^2 / (1 - sum [2^(n+1) * (a[n-1]^2 - g[n-1]^2)])QQ2None2Rfactory!Defines the available algorithms.RSRS3None YfactoryDetermines the mean of the specified numbers;  "https://en.wikipedia.org/wiki/Mean.,Should the caller define the result-type as ,, then it will be free from rounding-errors.ZfactoryDetermines the root mean square of the specified numbers;  .https://en.wikipedia.org/wiki/Root_mean_square.[factoryDetermines the  weighted mean of the specified numbers;  6https://en.wikipedia.org/wiki/Weighted_arithmetic_mean.NThe specified value is only evaluated if the corresponding weight is non-zero.pCAVEAT: because the operand is more general than a list, no optimisation is performed when supplied a singleton.factory Measures the  dispersion of a  population of results from the mean value;  4https://en.wikipedia.org/wiki/Statistical_dispersion.,Should the caller define the result-type as ,, then it will be free from rounding-errors.\factoryDetermines the exact variance of the specified numbers;  &https://en.wikipedia.org/wiki/Variance.,Should the caller define the result-type as ,, then it will be free from rounding-errors.]factoryDetermines the standard-deviation of the specified numbers;  0https://en.wikipedia.org/wiki/Standard_deviation.^factoryDetermines the average absolute deviation of the specified numbers;  Khttps://en.wikipedia.org/wiki/Absolute_deviation#Average_absolute_deviation.,Should the caller define the result-type as ,, then it will be free from rounding-errors._factoryDetermines the coefficient-of-variance of the specified numbers;  6https://en.wikipedia.org/wiki/Coefficient_of_variation.`factoryThe number of unordered  combinations of r objects taken from n;  )https://en.wikipedia.org/wiki/Combination.afactoryThe number of  permutations of r objects taken from n;  *https://en.wikipedia.org/wiki/Permutations.[factory9Each pair consists of a value & the corresponding weight.`factory/The total number of items from which to select.factory The number of items in a sample.factoryThe number of combinations.afactory/The total number of items from which to select.factory The number of items in a sample.factoryThe number of permutations. YZ[\]^_`a YZ[\]^_`a4NoneÍbfactory)Sums a list of numbers of arbitrary type.Sparks the summation of (list-length / chunk-size) chunks from the list, each of the specified size (thought the last chunk may be smaller), then recursively sums the list of results from each spark.&CAVEAT: unless the numbers are large,  (requiring cross-multiplication), or the list long, m is too light-weight for sparking to be productive, therefore it is more likely to be the parallelised deep  evaluation# of list-elements which saves time.cfactorySums a list of rational type numbers.CAVEAT: though faster than V, this algorithm has poor space-complexity, making it unsuitable for unrestricted use.dfactorySums a list of rational numbers.Sparks the summation of (list-length / chunk-length) chunks from the list, each of the specified size (thought the last chunk may be smaller), then recursively sums the list of results from each spark.1CAVEAT: memory-use is proportional to chunk-size.bcdbcd5None^ factory%Returns an improved estimate for the  square-rootY of the specified value, to the required precision, using the supplied initial estimate..efactoryThe algorithms by which the  square-root has been implemented.ffactory Whttps://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Bakhshali_approximationgfactory \https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Continued_fraction_expansion.hfactory /https://en.wikipedia.org/wiki/Halley%27s_method.ifactory /https://en.wikipedia.org/wiki/Newton%27s_method.jfactory Mhttps://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Taylor_series.kfactory The number of terms in a series.factoryUses continued-fractions#, to iterate towards the principal  square-root% of the specified positive integer;  Rhttps://en.wikipedia.org/wiki/Solving_quadratic_equations_with_continued_fractions,  Vhttps://en.wikipedia.org/wiki/Generalized_continued_fraction#Roots_of_positive_numbers,  \https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Continued_fraction_expansion. lhttps://www.myreckonings.com/Dead_Reckoning/Online/Materials/General%20Method%20for%20Extracting%20Roots.pdfThe convergence  1https://en.wikipedia.org/wiki/Rate_of_convergence of the continued-fraction is merely  1st order (linear).factory!The constant coefficients of the  Taylor-series for a  square-root;  Mhttps://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Taylor_series.@ ((-1)^n * factorial(2*n)) / ((1 - 2*n) * 4^n * factorial(n^2)) .factory Returns the  Taylor-series for the  square-root: of the specified value, to any requested number of terms. Mhttps://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Taylor_series.(The convergence of the series is merely linear, in that each term increases the precision, by a constant number of decimal places, equal to the those in the original estimate.By feeding-back the improved estimate, to form a new series, the order of convergence, on each successive iteration, becomes proportional to the number of terms; S Terms Convergence ===== =========== 2 terms /quadratic/ 3 terms /cubic/factory/Iterates from the estimated value, towards the  square-root@, a sufficient number of times to achieve the required accuracy.factoryThe required precision.factory The value for which to find the  square-root.factory8The number of terms of the infinite series, to evaluate.factoryThe value for which the  square-root is required.factoryAn initial estimate.efghijkkefghij6NoneorfactoryReturns Pi5, accurate to the specified number of decimal digits.rfactoryThis PiC-algorithm is parameterised by the type of other algorithms to use.factory The specific  square-root( algorithm to apply to the above series.factory The specific  factorial(-algorithm to apply to the above series.factory&The number of decimal digits required.rr7Nonesfactory Define those  Ramanujan$-series which have been implemented.tfactoryThe original version.ufactoryA variant found by the Chudnovsky brothers.sutsut8None{factoryReturns Pi5, accurate to the specified number of decimal digits.{factoryThis PiC-algorithm is parameterised by the type of other algorithms to use.factory&The number of decimal digits required.{{9None|factoryDefines those BBP)-type series which have been implemented.}factoryA base-2^16 version of the formula.~factoryA  nega-base 2^10 version of the formula.|}~|}~BCDEFGHIJKLMNOPQRSTUVWXDYZG[\]^_`abcdefAghijklmnopqrsVtuvwxyz{]|Vt}~SYbF   V    ] !!!!!!""""""" " " " # $%%%%%%%%&&&&&&&&''''((((((((((())))))) )!)")#)$)%)&)')()))*)+),)-).)/)0)1)2)3)4)5*6*7*8*9+:+;+<++=+>+?+@+A+B+C+D,-.//E/////00F0G0H0I0J0K0L122M2222233N3O333P3Q3R3S4t4T4U55V5W5X5Y5Z5[5\55555677]7^77777899_9`99999abcdefghbisjkdelmnbopqprstuquvwxyz{b| } I ~mjbbb$%%%%&&&)))***de+bde355555%factory-0.3.2.2-8zP8qzzzF1ShchzTIIfMdFactory.Data.ExponentialFactory.Data.IntervalFactory.Data.MonomialFactory.Data.PrimeWheelFactory.Math.DivideAndConquerFactory.Data.RingFactory.Data.QuotientRingFactory.Data.PolynomialFactory.Data.MonicPolynomialFactory.Data.PrimeFactorsFactory.Math.FactorialFactory.Math.FibonacciFactory.Math.Hyperoperation&Factory.Math.Implementations.Factorial*Factory.Math.Implementations.Pi.BBP.Series+Factory.Math.Implementations.Pi.BBP.Bellard-Factory.Math.Implementations.Pi.BBP.Base655367Factory.Math.Implementations.Primes.SieveOfEratosthenesFactory.Math.PowerFactory.Math.PerfectPower0Factory.Math.Implementations.Primes.TurnersSieve0Factory.Math.Implementations.Primes.SieveOfAtkinFactory.Math.PrecisionFactory.Math.Pi-Factory.Math.Implementations.Pi.Spigot.Series-Factory.Math.Implementations.Pi.Spigot.Spigot6Factory.Math.Implementations.Pi.Spigot.RabinowitzWagon-Factory.Math.Implementations.Pi.Spigot.Gosper0Factory.Math.Implementations.Pi.Spigot.Algorithm0Factory.Math.Implementations.Pi.Ramanujan.Series.Factory.Math.Implementations.Pi.Borwein.Series6Factory.Math.Implementations.Pi.Borwein.ImplementationFactory.Math.PrimalityFactory.Math.PrimeFactorisation Factory.Math.MultiplicativeOrder1Factory.Math.Implementations.Primes.TrialDivision/Factory.Math.Implementations.PrimeFactorisation&Factory.Math.Implementations.PrimalityFactory.Math.Primes-Factory.Math.Implementations.Primes.AlgorithmFactory.Math.ProbabilityFactory.Math.RadixFactory.Math.SquareRoot1Factory.Math.Implementations.Pi.Ramanujan.Classic4Factory.Math.Implementations.Pi.Ramanujan.Chudnovsky3Factory.Math.Implementations.Pi.Borwein.Borwein19931Factory.Math.Implementations.Pi.Borwein.Algorithm$Factory.Math.ArithmeticGeometricMean0Factory.Math.Implementations.Pi.AGM.BrentSalamin-Factory.Math.Implementations.Pi.AGM.AlgorithmFactory.Math.StatisticsFactory.Math.Summation'Factory.Math.Implementations.SquareRoot8Factory.Math.Implementations.Pi.Ramanujan.Implementation3Factory.Math.Implementations.Pi.Ramanujan.Algorithm2Factory.Math.Implementations.Pi.BBP.Implementation-Factory.Math.Implementations.Pi.BBP.Algorithm Data.FunctorfmapFunctor Data.ListheadtailData.PrimeWheel PrimeWheel ExponentialgetBase getExponent rightIdentityevaluate=~<^invertInterval getMinBound getMaxBoundclosedUnitInterval mkBounded preciselyshiftelem' isReversed normalisesplitAt'toListproduct'MonomialgetCoefficient isMonomial<=><*>squaredoubleshiftCoefficient shiftExponentnegateCoefficientmod'realCoefficientToFracDistanceNPrimesPrimeMultiplesgetPrimeComponents getSpokeGapsgetCircumference getSpokeCountestimateOptimalSize mkPrimeWheelrotaterollgenerateMultiples$fShowPrimeWheel MinLengthBisectionRatiodivideAndConquersum'Ring=+==*=additiveInversemultiplicativeIdentityadditiveIdentity=-==^$fMonoidProduct$fSemigroupProduct $fMonoidSum$fSemigroupSum $fReadProduct $fShowProduct $fReadSum $fShowSum QuotientRingquotRem'quot'rem'areCongruentModulo isDivisibleBy PolynomiallifttermsgetLeadingTerm mkConstantmkLinear mkPolynomialzerooneinAscendingOrderinDescendingOrder isNormalisedisMonicisZero isPolynomial getDegree*= raiseModulorealCoefficientsToFrac$fQuotientRingPolynomial$fRingPolynomial$fEqPolynomial$fShowPolynomialMonicPolynomial getPolynomialmkMonicPolynomial$fQuotientRingMonicPolynomial$fRingMonicPolynomial$fEqMonicPolynomial$fShowMonicPolynomialFactorsreduceinsert'>*<>/<>^ Algorithmic factorial fibonacciprimeIndexedFibonacci HyperExponentBase successionadditionmultiplicationexponentiation tetration pentationhexation powerTowerhyperoperationackermannPeterareCoincidental Algorithm BisectionPrimeFactorisation primeFactorsrisingFactorialfallingFactorial!/!$fAlgorithmicAlgorithm$fDefaultAlgorithm $fEqAlgorithm$fReadAlgorithm$fShowAlgorithmSeriesMkSeries numeratorsgetDenominatorsseriesScalingFactorbaseseriessieveOfEratosthenescube squaresFromcubeRootmaybeSquareNumberisPerfectPower turnersSieve sieveOfAtkin$fEqPolynomialType DecimalDigitsConvergenceRateConvergenceOrderlinearConvergencequadraticConvergencecubicConvergencequarticConvergencegetIterationsRequiredgetTermsRequiredroundTopromotesimplifyCategoryAGMBBPBorwein RamanujanSpigotopenRopenIopenS$fAlgorithmicCategory$fDefaultCategory $fEqCategory$fReadCategory$fShowCategory coefficientsbaseNumeratorsbaseDenominatorsnTermsbasesdecimalGosperRabinowitzWagongetSeriesScalingFactorconvergenceRateisPrime areCoprimeisFermatWitnessisCarmichaelNumbercarmichaelNumbersmaxBoundPrimeFactor smoothnesspowerSmoothnessregularNumbersprimePowerTotient eulersTotientomega squareFreemultiplicativeOrder trialDivision FermatsMethod TrialDivisionAKS MillerRabinprimes primorialmersenneNumbers SieveOfAtkinSieveOfEratosthenes TurnersSieve WheelSieve DistributiongeneratePopulationgetMeangetStandardDeviation getVarianceDiscreteDistributionPoissonDistributionShiftedGeometricDistributionContinuousDistributionExponentialDistributionLogNormalDistributionNormalDistributionUniformDistributionmaxPreciseIntegerboxMullerTransform&generateStandardizedNormalDistributiongenerateContinuousPopulationgenerateDiscretePopulation%$fSelfValidatorContinuousDistribution#$fSelfValidatorDiscreteDistribution"$fDistributionDiscreteDistribution$$fDistributionContinuousDistribution$fEqContinuousDistribution$fReadContinuousDistribution$fShowContinuousDistribution$fEqDiscreteDistribution$fReadDiscreteDistribution$fShowDiscreteDistributiontoBasefromBasedigitSum digitalRootIteratorstepconvergenceOrdersquareRootFrom squareRootEstimateResult getEstimategetDiscrepancy isPrecise getAccuracy Borwein1993 GeometricMeanArithmeticMeangetArithmeticMeangetGeometricMean convergeToAGMspreadisValid BrentSalamingetRootMeanSquaregetWeightedMeangetAverageAbsoluteDeviationgetCoefficientOfVariancenCrnPrsumR'sumRBakhshaliApproximationContinuedFraction HalleysMethodNewtonRaphsonIteration TaylorSeriesTerms$fIteratorAlgorithmClassic Chudnovsky Base65536Bellard getLengthGHC.RealIntegralghc-prim GHC.TypesIntGHC.EnumEnum FractionalGHC.BaseMonoidTrue Repository findCoprimesRationalSumData.Semigroup.InternalGHC.NumNumgetSumProduct getProduct MonomialListgetMonomialListpruneCoefficientsinOrder isReducedmod reduceSorted sumExponentsprimeMultiplicity RepositoryIntPrimeMultiplesMapIntPrimeMultiplesMapPrimeMultiplesQueuehead'containers-0.6.0.1Data.Sequence.InternalSeqtail'emptyData.Map.InternalMapsieveOfEratosthenesIntisPerfectPowerIntPolynomialTypeModFourModSix ModTwelveNone atkinsModulusinherentPrimesnInherentPrimesgetPrefactoredPrimespolynomialTypeLookupPeriodpolynomialTypeLookupsquaresfilterOddRepetitions Data.OldListsortfindPolynomialSolutionsgenerateMultiplesOfSquareTosieveOfAtkinInt integer-gmpGHC.Integer.TypeIntegerStringQuotRemquotRemRatioIcarryAndDivideprocessColumnsmkRowdivisIndivisibleBy DixonsMethodfactoriseByDixonsMethodfactoriseByFermatsMethodfactoriseByTrialDivision isPrimeByAKSwitnessesCompositenessisPrimeByMillerRabin%primes-0.2.1.0-5h3YRSGjPOUEJVLnWwzVHRData.Numbers.Primes wheelSieveminPositiveFloat reProfilegeneratePoissonDistributiondigitsencodesdecodesCharrSqrt GHC.FloatsqrtRealDoublegetDispersionFromMean Data.FoldablesumProblemSpecificationsquareRootByContinuedFractiontaylorSeriesCoefficientssquareRootByTaylorSeriessquareRootByIteration