TITLE: Prime counting function; when is it true that $\pi(n) > \pi(2n) -\pi(n)$?
QUESTION [6 upvotes]: Let $\pi$ be the prime counting function.
Under what conditions is it proven true that $\pi(n) > \pi(2n) -\pi(n)$, if at all?

REPLY [5 votes]: I've written the program Akiva Weinberger suggested above.  This is just a straightforward interpretation of the sieve of Eratosthenes, in R.
n = 30092
top = 2*n
isPrime = rep(TRUE, top)
isPrime[1] = FALSE

nextprime = 2
while (nextprime < sqrt(top)){
  isPrime[seq(2*nextprime, floor(top/nextprime)*nextprime, nextprime)] = FALSE
  nextprime = min(which(isPrime[(nextprime+1):top])) + nextprime
}

#isPrime[n] is now TRUE if n is prime and FALSE otherwise

primePi = cumsum(isPrime) #prime counting function, denoted as pi above

f = primePi[seq(2, 2*n, 2)] - 2*primePi[1:n] 

which(f>0)

The output is the list [1].  That is, $\pi(2k) > 2\pi(k)$ for $k = 1$ and no other $k <= 30092$.  As Barry Cipra showed above, we can prove the desired inequality for larger values from of $k$ from known bounds.
If we want to consider the possibility that $\pi(2k) = 2\pi(k)$, we can replace the last line with which(f>=0).  The output here is [1, 2, 4, 10].  And in fact we have $2 = \pi(4) = 2 \pi(2), 4 = \pi(8) = 2 \pi(4), 8 = \pi(20) = 2\pi(10)$.