-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Summatory functions #60
Comments
Very interesting. I'll dig into that paper later. Until then I can offer one piece of Haskell code related to the sublinear computation of certain summatory functions over the primes. Its name is It takes three parameters: A size parameter So, for example, Here is the code for primeLucy. It isn't pretty, but it is fast and it could be made a great deal faster by restricting to functions with Int, rather than Integer, values and sums.
|
Awesome, I was not aware of this algorithm. I've found the original post of Lucy_Hedgehog (https://projecteuler.net/thread=10;page=5#111677). He mentions that "It is also possible to improve the complexity of the algorithm to O(n^2/3), but the code would be more complex". Do you know how? |
I am told the algorithm referred to there is described in the paper Tomás Oliveira e Silva, Computing pi(x): the combinatorial method, Revista do DETUA, but this paper is still on my reading list. |
I've just realised that there is |
Hope you can use the code I posted above! It is more general that |
What @Lucy_Hedgehog wrote was generalised Legendre 1798 : Legendre => 1870 : Meissel => 1959 : Lehmer => 1985 : Lagarias, Miller and Odlyzko => 1996 : M. Deleglise, J. Rivat => 2001 : Xavier Gourdon => 2015 : Douglas Staple => Each of them can be generalised to find sum of primes or even sum of squares of primes. @kimwalisch have generalised most of them in repo primesum |
Common difficulty of number theory is that arithmetic functions misbehave: their plots oscillate up and down in chaotic fashion. For instance, here is a plot of divisor function from wiki:
The pivot idea of analytic number theory is that instead of studying this jumble, we can study the summatory function, which is simply a sum (or an integral) of original function:
Summatory functions behave well and a wide range of fruitful methods can be applied. E. g., divisor summatory function.
The interesting thing is that in many cases summatory function can be computed in sublinear time, faster than O(n). For example, let
tau
denote the divisor function. Thensummatory tau n
is equal towhere
sqrtx = integerSquareRoot x
. This computation can be completed in O(x^{1/2}) time. There is a systematic way to derive such formulas, which I have explored in my old paper with a long title.The proposal is to implement some of these algorithms, to provide users with a DSL to describe functions (in terms of Dirichlet convolution?) and to derive effective summatory formulas from DSL automatically.
Upd.: I think it is worse to create a separate type for multiplicative functions, accompanied by conversion
multiplicative :: MultiplicativeFunction -> ArithmeticFunction
, because there is so much more to do with multiplicative functions, which is undefined for general arithmetic ones. It would be nice to implement inverses of multiplicative functions as well, following the approach in Computing the inverses....Implementation plan
Math.NumberTheory.MoebiusInversion.totientSum
.The text was updated successfully, but these errors were encountered: