If you scroll down a bit, it defines the function for you ...

= The number of primes less than or equal to

So for example, because there are 4 primes less than or equal to 10 (2, 3, 5, and 7).

Results 1 to 12 of 12

- February 27th 2009, 11:28 PM #1

- Joined
- Feb 2009
- Posts
- 5

## What is pi(x)?

I was looking into prime numbers and i keep coming upon pi(x). Specifically How many primes are there?. It is obvious that they arent multiplying pi*x. So what are they doing? Im only in trig so please explain it in basic terms.

Thanks!

- February 27th 2009, 11:54 PM #2

- February 28th 2009, 12:01 AM #3

- Joined
- Feb 2009
- Posts
- 5

- February 28th 2009, 12:45 AM #4

- Joined
- Nov 2005
- From
- someplace
- Posts
- 14,972
- Thanks
- 5

- February 28th 2009, 08:47 PM #5
Li(x) is the best approximation and it has been proven that it asymptotically approaches pi(x), however Littlewood proved (in 1914?) that while for small n (n < 10^300) Li(x)-pi(x)>0, Li(x)-pi(x) changes signs infinitely many times as n --> infinity.

Maple has the Li function built in.

- February 28th 2009, 10:57 PM #6

- Joined
- Feb 2009
- Posts
- 5

Yes i have looked at that article and I know that it contains what I am looking for, however I havent taken calculus and I dont understand how they are displaying the formulas. Could you explain it in a way that someone in trig could understand it?

You say that " ", but what steps did you go through to get that? I know that it isnt pi*46000.

- February 28th 2009, 11:24 PM #7
isn't something you can calculate exactly with a formula. You can only approximate it using the log integral, Li(n) ( , which is only a 0.7% error), and the larger the number, the more accurate (percentage-wise) the approximation will be. For example, and , for a 17% error. and , for a 5% error. and , for a 0.2% error. All of those calculations were done using Maple 12. The command for finding in Maple is "nops(select(isprime, [`$`(1..n)]))". Li(n) in Maple is just "Li(n)".

If you don't understand calculus, you won't understand the meaning behind the log integral, Li(n). Just know it as the best approximation for . There is no particular reason for using the notation either. There are only a limited number of letters, and they have to be recycled eventually.

- February 28th 2009, 11:49 PM #8

- Joined
- Feb 2009
- Posts
- 5

- March 1st 2009, 12:00 AM #9
The following is

code. It was the only way I could get the forum to preserve the indentations needed for Python, which is the language this is written in.**NOT HTML**

[html]primes = [2]

p=1

i=3

n=input("Up to what number? ")

while i<=n:

for j in primes:

if i%j==0:

break

else:

if j==primes[len(primes)-1]:

primes.append(i)

p=p+1

i=i+1

print ""

print "Number of Primes: " + `p`[/html]

This code is not very efficient (it takes almost 1 minute for n=100000, compared to about 3 seconds on Maple), but it should at least point you in the right direction.

- March 1st 2009, 12:10 AM #10

- Joined
- Feb 2009
- Posts
- 5

- March 1st 2009, 12:15 AM #11
I'm not too great at programming, but I would suggest that you check out the Sieve of Eratosthenes. It's supposedly efficient for n<10,000,000.

- March 1st 2009, 01:04 AM #12

- Joined
- Nov 2005
- From
- someplace
- Posts
- 14,972
- Thanks
- 5

As I said before it is the number of primes less than or equal to 46000, and as I suggested I counted them.

My Euler code to find the primes less than or equal to some limit is:

Code:function primes(n) ## ## function returns a row vector containing the primes ## less than or equal n ## ## (c) Xxx Xxxxxx 1997 rewritten 2004 using MATLAB seive alg ## if size(n)!=[1,1] "n must be a scalar" rv=[]; return rv; endif p=[1:2:n]; q=length(p); p(1)=2; for k=3 to sqrt(n) step 2 if p((k+1)/2) p(((k*k+1)/2):k:q)=0; endif end; rv=p(nonzeros(p>0)); return rv; endfunction

Code:pp=primes(n); np=length(pp)