### Partition Function Example Source: https://github.com/bodigrim/arithmoi/blob/master/changelog.md Shows the first 10 values generated by the partition function. ```haskell take 10 partition -- [1,1,2,3,5,7,11,15,22,30] ``` -------------------------------- ### Inverse Totient Function Example Source: https://github.com/bodigrim/arithmoi/blob/master/changelog.md Illustrates the generation of preimages for the totient function using `inverseTotient`. ```haskell > inverseTotient 120 :: [Integer] [155,310,183,366,225,450,175,350,231,462,143,286,244,372,396,308,248] ``` -------------------------------- ### Bernoulli Numbers Example Source: https://github.com/bodigrim/arithmoi/blob/master/changelog.md Demonstrates how to retrieve the first 10 Bernoulli numbers using the `bernoulli` function from `Math.NumberTheory.Recurrencies.Bilinear`. ```haskell take 10 $ Math.NumberTheory.Recurrencies.Bilinear.bernoulli [1 % 1,(-1) % 2,1 % 6,0 % 1,(-1) % 30,0 % 1,1 % 42,0 % 1,(-1) % 30,0 % 1] ``` -------------------------------- ### Riemann Zeta Function Example Source: https://github.com/bodigrim/arithmoi/blob/master/changelog.md Shows how to compute the first 5 values of the Riemann zeta function for non-negative integer arguments using `zetas` from `Math.NumberTheory.Zeta`. ```haskell take 5 $ Math.NumberTheory.Zeta.zetas 1e-15 [-0.5,Infinity,1.6449340668482262,1.2020569031595945,1.0823232337111381] ``` -------------------------------- ### Ramanujan Tau Function Example Source: https://github.com/bodigrim/arithmoi/blob/master/changelog.md Demonstrates the usage of the Ramanujan tau function for the first 10 integers. ```haskell map ramanujan [1..10] -- [1,-24,252,-1472,4830,-6048,-16744,84480,-113643,-115920] ``` -------------------------------- ### Mertens Function Example Source: https://github.com/bodigrim/arithmoi/blob/master/changelog.md Demonstrates the Mertens function applied to powers of 10, from 10^0 to 10^9. ```haskell map (mertens . (10 ^)) [0..9] -- [1,-1,1,2,-23,-48,212,1037,1928,-222] ``` -------------------------------- ### Arithmetic Functions Example Source: https://github.com/bodigrim/arithmoi/blob/master/changelog.md Illustrates the usage of newly added arithmetic functions like `divisors`, `tau`, `sigma`, and `totient` from `Math.NumberTheory.ArithmeticFunctions`. ```haskell divisors tau sigma totient jordan moebius liouville smallOmega bigOmega carmichael expMangoldt ``` -------------------------------- ### Bulk Evaluation of Arithmetic Functions Source: https://github.com/bodigrim/arithmoi/blob/master/changelog.md Example of using `runFunctionOverBlock` to evaluate the Carmichael function over a range of integers. ```haskell runFunctionOverBlock carmichaelA 1 10 -- [1,1,2,2,4,2,6,2,6,4] ``` -------------------------------- ### Smooth Numbers Generation Example Source: https://github.com/bodigrim/arithmoi/blob/master/changelog.md Generates smooth numbers within a specified range using a given set of prime factors. ```haskell smoothOverInRange (fromJust (fromList [3,5,7])) 1000 2000 -- [1029,1125,1215,1225,1323,1575,1701,1715,1875] ``` -------------------------------- ### Prime Newtype Usage Source: https://github.com/bodigrim/arithmoi/blob/master/changelog.md Examples of functions that now extensively use the new `Prime` newtype for prime number representation. ```haskell primes :: Integral a => [Prime a] primeList :: Integral a => PrimeSieve -> [Prime a] sieveFrom :: Integer -> [Prime Integer] nthPrime :: Integer -> Prime Integer ``` -------------------------------- ### Dirichlet Beta Function Example Source: https://github.com/bodigrim/arithmoi/blob/master/changelog.md Illustrates the computation of the Dirichlet beta function for non-negative integer arguments, showing the first 5 values with a specified precision. ```haskell take 5 $ Math.NumberTheory.Zeta.Dirichlet.betas 1e-15 -- [0.5,0.7853981633974483,0.9159655941772191,0.9689461462593693,0.9889445517411055] ``` -------------------------------- ### Enum Instance for Primes Source: https://github.com/bodigrim/arithmoi/blob/master/changelog.md Demonstrates the usage of `nextPrime` and `precPrime` functions, showcasing the new `Enum` instance for primes. ```haskell > [nextPrime 101 .. precPrime 130] [Prime 101,Prime 103,Prime 107,Prime 109,Prime 113,Prime 127] ``` -------------------------------- ### Relationship between Phi and Pi Functions Source: https://github.com/bodigrim/arithmoi/blob/master/Math/NumberTheory/Primes/Counting/HowPrimeCountingWorks.md Shows the relationship between the Phi function and the prime-counting function Pi, useful for conversions and understanding their connection. ```mathematics Phi(x, Pi(sqrt(x))) = Pi(x) - Pi(sqrt(x)) + 1 ``` -------------------------------- ### Polymorphic Fibonacci and Lucas Functions Source: https://github.com/bodigrim/arithmoi/blob/master/changelog.md Demonstrates the polymorphic nature of `fibonacci` and `lucas` functions, which now support types beyond `Integer`, such as `Mod 7`. ```haskell map fibonacci [1..10] :: [Mod 7] ``` -------------------------------- ### Modular Arithmetic Functions Source: https://github.com/bodigrim/arithmoi/blob/master/changelog.md Lists the new interface for modular computations provided by `Math.NumberTheory.Moduli.Class`, which replaces `invertMod`, `powerMod`, and `powerModInteger`. ```haskell Math.NumberTheory.Moduli.Class ``` -------------------------------- ### Legendre's Prime Counting Formula Source: https://github.com/bodigrim/arithmoi/blob/master/Math/NumberTheory/Primes/Counting/HowPrimeCountingWorks.md The prime counting function Pi(limit) expressed using the Phi function and primes up to the square root of the limit. ```mathematics Pi(limit) = Phi(limit, Pi(sqrt(limit))) + Pi(sqrt(limit)) - 1 ``` -------------------------------- ### Recursive Phi Function for Prime Counting Source: https://github.com/bodigrim/arithmoi/blob/master/Math/NumberTheory/Primes/Counting/HowPrimeCountingWorks.md A recursive function to calculate prime counts. It's noted that this recursive approach is less efficient than iterative methods due to a lack of asymptotic improvements from partial sieving. ```haskell phip2 x = (x + 1) / 2 phi pmult pilmt = let looppi pi acc = if pi >= pilmt then acc else p = unsafeAt baseprms pi npmult = pmult * p -- special termination condition for when p >= limit / npmult... if p * npmult >= limit then acc + pilmit - pi else looppi (pi + 1) (acc + phip2(limit / npmult) - phi npmult pi) -- recursion ``` -------------------------------- ### Terminating Condition for Phi Function Source: https://github.com/bodigrim/arithmoi/blob/master/Math/NumberTheory/Primes/Counting/HowPrimeCountingWorks.md A crucial terminating condition for the recursive Phi function: when the limit 'm' is less than or equal to the nth prime 'pn', the value is 1. ```mathematics Phi(m, n) when m is less than or equal to pn must be exactly one ``` -------------------------------- ### Recursive Phi Function Definition Source: https://github.com/bodigrim/arithmoi/blob/master/Math/NumberTheory/Primes/Counting/HowPrimeCountingWorks.md Defines the recursive Phi function used in Legendre's prime counting formula. It requires base cases for Phi(0, n) and Phi(m, 0). ```mathematics Phi(m, n) = Phi(m, n - 1) - Phi(floor(m / pn), n - 1) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.