TITLE: Fastest Algorithm to Compute the Sum of Primes?
QUESTION [24 upvotes]: Can anyone help me with references to the current fastest algorithms for counting the exact sum of primes less than some number n?  I'm specifically curious about the best case running times, of course.  I'm pretty familiar with the various fast algorithms for prime counting, but I'm having a harder time tracking down sum of prime algorithms...

REPLY [10 votes]: I'll put in a plug for my original paper with Lagarias and Odlyzko, as well as a recent paper by Bach, Klyve and Sorenson: http://www.ams.org/journals/mcom/2009-78-268/S0025-5718-09-02249-2/home.html Computing prime harmonic sums Math. Comp. 78 (2009), 2283-2305.  Although the algorithms of Lagarias and Odlyzko (with the extra algorithm of Odlyzko-Schonhage for computing good approximations to a bunch of values of $\zeta(s)$) are asymptotically the best, having complexity $O(x^{1/2 + \epsilon})$ the combinatorial algorithms will probably work best for any reasonable ranges.  Though one should look at J. Buethe, J. Franke, A. Jost, and T. Kleinjung, "Conditional Calculation of pi(10^24)", Posting to the Number Theory Mailing List, Jul 29 2010.  A little more detail (that's all I have right now) is contained in the talk of David Platt: www.maths.bris.ac.uk/~madjp/junior%20talk.pdf .   The idea in the combinatorial method is the following:
Suppose that $f(n)$ is a completely multiplicative function of the positive integers.  In the case of calculating $\pi(x)$, we take $f(n) = 1$.  In the case of calculating the sum of the primes $\le x$ we take $f(n) = n$.  In the case of Calculating $\pi(x,a,q)$ we take $f(n)$ to be a Dirichlet character mod $q$.
Define $\phi(x,a)$ as the sum of $f(n)$ for all integers $n \le x$ which are not divisible by the first $a$ primes.  Clearly $\phi(x,0) = \sum_{n \le x} f(n)$.  We have the recursion:
$\phi(x,a+1) = \phi(x,a) - f(p_{a+1})\phi(x/p_{a+1},a).$
Imagine that you have a labeled tree, where the labels are $\pm f(k) \phi(x/k,b)$ for some $k$ and $b$.  You can expand any node in the tree you want by applying the above formula.  This has the property that it leaves the sum of the values at the leaves the same.  So the idea is to start with a tree consisting of one node labeled $\phi(x,\pi(\sqrt x))$ and keep expanding until either $b=0$ or $x/k < $ some cutoff.  If you accumulate all such nodes you can evaluate all of them by sieving (and a special data structure -- see the Lagarias-Miller-Odlyzko paper for details), and the optimal value for the cutoff is $x^{2/3}$ perhaps multiplied by some logarithmic factors.
Here's the reference to my paper with Lagarias and Odlyzko: Computing $\pi(x)$: The Meissel-Lehmer Method
Author(s): J. C. Lagarias, V. S. Miller, A. M. Odlyzko
Source: Mathematics of Computation, Vol. 44, No. 170 (Apr., 1985), pp. 537-560