ContentsIndex
Maths
Synopsis
powerset :: [a] -> [[a]]
everywhere :: a -> [a] -> [[a]]
permutations :: [a] -> [[a]]
permutations_count :: Integral a => a -> a -> a
combinations :: [a] -> [[a]]
combinations_count :: Integral a => a -> a -> a
binomial :: Integral a => a -> a -> Ratio a -> Ratio a
printBinomial :: Integral a => a -> a -> Ratio a -> IO ()
binomialSimple :: Integral a => a -> a -> Ratio a
printBinomialSimple :: Integral a => a -> a -> IO ()
ratioToFloating :: (Integral a, Floating b) => Ratio a -> b
fareylen :: Integral a => a -> a
fareylenf :: Integral a => a -> a
totient :: Integral a => a -> a
polyx :: Integral a => a -> [a]
integralToBinary :: Integral a => a -> String
factorial :: Integral a => a -> a
factorials :: Array Int Int
tri :: Integral a => a -> a
tris :: Integral a => [a]
pents :: Integral a => [a]
fibs :: Integral a => [a]
primes :: Integral a => [a]
primesn :: Integral a => a -> [a]
divides :: Integral a => a -> a -> Bool
ld :: Integral a => a -> a
ldf :: Integral a => a -> a -> a
isprime :: Integral a => a -> Bool
factors :: Integral a => a -> [a]
ufactors :: Integral a => a -> [a]
divisors :: Integral a => a -> [a]
numdivisors :: Integral a => a -> Int
sumdivisors :: Integral a => a -> a
pnumdivisors :: Integral a => a -> a -> a
coprime :: Integral a => a -> a -> Bool
mean :: Fractional a => [a] -> a
sum_of_n_primes_app :: Integral a => a -> Float
sum_of_n_primes :: Integral a => a -> Float
modexp :: Integer -> Integer -> Integer -> Integer
e_calc :: Int -> Double
e_calc' :: Int -> Double
Documentation
powerset :: [a] -> [[a]]
Answer all subsets of a set.
everywhere :: a -> [a] -> [[a]]
Answer a list of lists with the first arg interspersed at all positions in the list arg. E.g., everywhere 1 [4,5] yields [[1,4,5],[4,1,5],[4,5,1]]. Copied from http://www.haskell.org/hawiki/LicensedPreludeExts.
permutations :: [a] -> [[a]]
Answer all permutations of the given list. Copied from http://www.haskell.org/hawiki/LicensedPreludeExts.
permutations_count :: Integral a => a -> a -> a
Answer the number of k-permutations from a collection of n objects.
combinations :: [a] -> [[a]]
Answer a list of all combinations (of any length) of the given list. Copied from http://www.haskell.org/hawiki/LicensedPreludeExts.
combinations_count :: Integral a => a -> a -> a
Answer the number of ways to choose k unordered objects from a collection of n objects.
binomial :: Integral a => a -> a -> Ratio a -> Ratio a
Answer the probability of an event with probability p occurring r times in n trials.
printBinomial :: Integral a => a -> a -> Ratio a -> IO ()
Calculate the binomial value with binomial and print the result as a double with 2 decimal places.
binomialSimple :: Integral a => a -> a -> Ratio a
Calculate the binomial value assuming that the probability of the event occurring is 1/n.
printBinomialSimple :: Integral a => a -> a -> IO ()
Calculate the binomial value with binomialSimple and print the result as a Double with 2 decimal places.
ratioToFloating :: (Integral a, Floating b) => Ratio a -> b
Answer the given rational as a floating approximation.
fareylen :: Integral a => a -> a
Calculate the length of the farey sequence with denominator n, including the value for 0/n and n/n (so subtract 2 if you want the more standard value excluding these).
fareylenf :: Integral a => a -> a
Calculate the length of the farey sequence with denominator n, including the value for 0/n and n/n (so subtract 2 if you want the more standard value excluding these). This version is optimized for n small enough that totient n fits in an Int.
totient :: Integral a => a -> a
Euler's totient function, which calculates the number of positive integers <=n that are relatively prime to (i.e., do not contain any factor in common with) n, where 1 is counted as being relatively prime to all numbers. In number theory, the totient phi(n) of a positive integer n is defined to be the number of positive integers less than or equal to n and coprime to n. http://en.wikipedia.org/wiki/Totient http://mathworld.wolfram.com/TotientFunction.html
polyx :: Integral a => a -> [a]
Creates an infinite list of n-gon numbers; e.g., for n = 3, returns the triangular numbers (1, 3, 6, 10..), and for n = 5, returns the pentagon numbers (1, 5, 12, 22..).
integralToBinary :: Integral a => a -> String
Convert an integral number to its binary equivalent as a string.
factorial :: Integral a => a -> a
Calculate the factorial of a positive integer.
factorials :: Array Int Int
Array of factorial results of the 10 digits, from 0 to 9.
tri :: Integral a => a -> a
Calculate the nth triangle number (1, 3, 6, 10..).
tris :: Integral a => [a]
A stream of triangle numbers.
pents :: Integral a => [a]
A stream of pentagon numbers.
fibs :: Integral a => [a]
An infinite list of fibonnaci numbers
primes :: Integral a => [a]
An infinite list of prime numbers, using a simple implementation of the sieve of Eratosthenes.
primesn :: Integral a => a -> [a]
A finite list of prime numbers from 2 to n (inclusive), using a simple implementation of the sieve of Eratosthenes.
divides :: Integral a => a -> a -> Bool
Determine if d divides into n evenly.
ld :: Integral a => a -> a
Determine the least natural number greater than 1 that divides n.
ldf :: Integral a => a -> a -> a
Determine the least natural number greater than or equal to k that that divides n.
isprime :: Integral a => a -> Bool
Determine if the given integral argument is a prime number.
factors :: Integral a => a -> [a]
Determine the unique prime factorization of a positive integer.
ufactors :: Integral a => a -> [a]
Determine the unique prime factors of a positive integer.
divisors :: Integral a => a -> [a]
Calculate the proper divisors of n (divides n evenly and less than n).
numdivisors :: Integral a => a -> Int
Calculate the number of divisors of n, including 1 and n itself. This implementation relies on the fact that the number of divisors for a number whose prime factorization is (p1^a) (p2^b) (p3^c)... (px^n) is equal to (a+1) (b+1) (c+1) ... (n+1).
sumdivisors :: Integral a => a -> a
Calculate the sum of the divisors of a number. For example: (72) = 1513 = 195.
pnumdivisors :: Integral a => a -> a -> a
Calculate the number of divisors of the given prime number raised to the given power, using the formula (p^(x+1)-1)/(p-1).
coprime :: Integral a => a -> a -> Bool
Determine if 2 integrals are coprime (have gcd of 1).
mean :: Fractional a => [a] -> a
Determine the arithmetic mean of a list of one or more numbers. If the list is empty, 0 is returned.
sum_of_n_primes_app :: Integral a => a -> Float
Approximate the sum of the first n primes, using the formula (Bach and Shallit, 1996): sigma n ~ 1/2 * n^2 * ln n
sum_of_n_primes :: Integral a => a -> Float
Determine the sum of the first n primes. This is very slow. Consider the function that approximates the sum, sum_of_n_primes_app.
modexp :: Integer -> Integer -> Integer -> Integer
Calculates x^y modulo N. This algorithm has complexity O(n^3) where n is the size in bits of the largest of x, y, and N.
e_calc :: Int -> Double
A formula for computing e, from Courant/Fritz; it converges quite fast, and already is perfectly accurate to limits of Double at e_18. e = 1/0! + 1/1! + 1/2! + ... + 1/n!
e_calc' :: Int -> Double
Another series for computing e from Courant/Fritz, but this one is very slow to converge: at e_1000 it is still only 2.7169.
Produced by Haddock version 2.4.1