PrimeSRcs Documentation



          Documentation for Andrica's Conjecture Program

I have developed a computer program to investigate Andrica's conjecture. My plan 
was to generate the consecutive primes and compute the Andrica function for each 
new prime. In order to see what was happening to the function without too much 
output, the program only saves and output results when the function is larger 
than all following values. Af(k) > Af(m) for all m > k. This is a heuristic 
program and the results are experimental since it has not been proven that the 
function could not have a large value, even greater than 1 for some later prime. 
The program's short name is PrimeSRcs. The SR is for Square Root and the cs is 
for the C# (C sharp) programming language.

When you execute the program PrimeSRcs.exe you get the message:

--------------------------------------------------------------------------------
    PrimeSRcs - Investigates Andrica's Conjecture: Af(n) < 1 for all n > 0.
    It using the sieve of Eratosthenes with double Floating-point.
    C# Version 3.1.2.18527
    Copyright (c) 1981-2007 by author: Harry J. Smith,
    19628 Via Monte Dr., Saratoga CA 95070.  All rights reserved.

  This program computes terms for The On-Line Encyclopedia of Integer
  Sequences maintained by N. J. A. Sloane. See:
    http://www.research.att.com/~njas/sequences/
  The sequences computed are A084974, A084975, A084976, and A084977.

  A084974(n) are the primes p_k such that Af(k) > Af(m) for all
  m > k, where Af(k) is the Andrica function sqrt(p_k+1) - sqrt(p_k),
  and p_k denotes the k-th prime. See:
    http://mathworld.wolfram.com/AndricasConjecture.html

  A084975(n) are the primes p_k+1 such that Af(k) > Af(m) for all m > k.

  A084976(n) are values of k such that Af(k) > Af(m) for all m > k.

  A084977(n) = Ag(k) = floor(1000000*Af(k)) with k such that
  Af(k) > Af(m) for all m > k.

  The latest version of this program and all of its source files can be
  downloaded from http://www.oocities.com/hjsmithh/PrimeSR/ .
--------------------------------------------------------------------------------

Andrica's conjecture states that, for p_n the nth prime number, the inequality 
Af(n) = sqrt(p_n+1) - sqrt(p_n) < 1 for all n > 0. The largest value found for 
Af(n) is at n = 4 where we have Af(4) = sqrt(11) - sqrt(7) = 
0.6708734792908092586... . The search has gown past n = 3.8 * 10^11, so it is 
highly likely the conjecture is true. However, it has never been proven. Past n 
= 3.8 * 10^11, Af(n) appears to be less than 0.0001.

To show how Af(n) decreases with n, four sequences are defined and computed, see 
above.

The program uses a Function NPrime(mC) to generate consecutive prime numbers. It 
is an implementation of Algorithm 357 of the Collected Algorithms from ACM. It 
is an efficient prime number generator using the sieve of Eratosthenes. Here mC 
= Number of new primes desired this call. The current length of the tables in 
array iQ and jQ is returned. This is approximately the number of primes < 
sqrt(current prime). It must not exceed qSize, referred to as "Prime # Table 
Length" on the opening Startup form when you start the program. The user can set 
qSize to any value 1 <= qSize <= 2^31-1. Values less than 200 produce no output. 
Numbers greater than about 10000000 give an out-of-memory alarm. The default 
value is 1000000.

The next parameter on the Startup form is rSize "Size of Result Table". The 
default value is 500. The result table is used to store new values of the four 
sequences as they are computed and the time it took to compute them. If you 
intend to compute many terms, you need a value of rSize at least 100 or so. It 
is not known how large it must be for extremely long calculations. If the 
program stops with "Numbers got too large!" message due to qSize or rSize being 
too small, the program can be restarted with a larger qSize and/or rSize. Just 
do a "Read SnapShot" after the program gets started.

The user can also control mC, the number of new primes generated on each call of 
NPrime. This is called "Primes Gen. Per Cycle" on the Startup form. The default 
value is 105000, but the user can change it to any value 2 <= mC <= 2^31-1. 
Values much larger than the nominal are not recommended. Also, if you plan to 
reread snapshot files, explained later, The value of mC cannot be changed from 
what it was when the file was written.

The next parameter on the Startup form that the operator can change is cyc 
"Cycles Per Status". Its default value is one, but cyc be changed to any value 1 
<= cyc <= 1000. Large values on cyc produce fewer status updates.

The last parameter on the Startup form that the operator can change is Execution 
Priority. It can be set to an integer Pri, -2 <= Pri <= 2. With 2 = Highest, 1 = 
AboveNormal, 0 = Normal, -1 = BelowNormal, -2 = Lowest. Its default value is -1.

These five values are tested as they are edited. Spaces on the left or right are 
removed so you will not see them. These numbers are displayed in bold face font 
iff they are acceptable values. If any of the values are unacceptable, the Run 
button is disabled.

A "Default Settings" button is provided to reset the five parameters to their 
original values.

There are also two command buttons on the Startup form "Run" and "Exit". Choose 
"Exit" to totally terminate the program. Choose "Run" to bring up the second or 
Run form and start calculations.

The Run form will start calculations and start updating status, like:

      The system was booted-up xx:xx:xx ago.

      Priority is BelowNormal
      Current array index: 30 29 36 ...

The priority is set to BelowNormal so you can continue using your computer to do 
other tasks. The status is the output of ai the "Current array index" which is 
the last index from 1 to rSize where the last terms of the computed sequences 
were stored. Every time Af(n) is computed, the new terms are stored over any 
earlier terms that had an Af value less than this current Af(n). The value of ai 
tends to rise and fall with an overall general trend to get larger.

Other status items are, for example "Prime no. table length = 400 of 1000000", 
"Current result array index = 38 of 500" and "Max prime tested = 9,442,211". The 
prime no. table is the array of all primes less than the square root of the last 
prime generated by the function NPrime. The Current results array index is the 
same as described in the last paragraph but here we also get the max length of 
the array, rSize. The max prime tested is just that. All primes less than this 
p_n have been generated, counted, and tested by computing Af(n) = sqrt(p_n+1) - 
sqrt(p_n).

The equation for defining Af(n) is good for a definition, but it as an unstable 
equation for calculation. For large values of n, sqrt(p_n+1) and sqrt(p_n) have 
several leading digits the same, so there is a large relative error when they 
are subtracted. To get a stable equation, multiply and divide by sqrt(p_n+1) + 
sqrt(p_n) and you get Af = (p_n+1 - p_n) / (sqrt(p_n+1) + sqrt(p_n)). This is a 
very stable equation for computing Af(n).

There are six command buttons for controlling the actions of the program. They 
are "Read SnapShot", "Write Snapshot", "Write Results", "Test 'Too Large'", 
"Pause", and "Quit".

Write SnapShot: Selecting this will write a snapshot file containing all the 
data that is necessary to initialize and restart the programs calculations 
exactly where it was when the snapshot was taken. It contains all of the data in 
the results table and all of the data in the prime number table maintained by 
the function NPrime. When a snapshot file is written, the previous snapshot 
file, if any, is renamed PrimeSRcsSnapS.Bak and a new file is named 
PrimeSRcsSnapS.txt. An automatic Write SnapShot is forced every hour and when 
"Numbers got too large!".

Read Snapshot: This will read the latest snapshot file PrimeSRcsSnapS.txt and 
restart the calculations from there.

Write Results: This will write a file containing the results table in a human 
readable form. When a results file is written, the previous results file, if 
any, is renamed PrimeSRcsRFile.Bak and a new file is named PrimeSRcsRFile.txt.

Test 'Too Large': This causes the program to try to store a zero in one cell 
pact the end of the prime number table. This simulates the numbers getting too 
large for the program to handle in its current configuration. The program will 
then write a results file to PrimeSRcsRFile.Too and "Quit".

Pause: This causes the program to stop using processor resources and wait to be 
resumed. When resumed by selecting OK on the message box provided, the amount of 
time delayed is accounted for to maintain an accurate value of the time required 
to calculate the terms of the sequences.

Quit: This does cause the calculations to stop and the user is returned to the 
original Startup form for possible restart "Run" or termination "Exit".

The functions of the six command buttons are also available in the "File" menu. 
Minimize and Close buttons are also available. The Close button does the same as 
the "Quit" and the "Exit" in the "File" menu. The "File" menu also has a "Write 
All" function which does a "Write Results" followed by a "Write SnapShot".

Next to the "File" menu is the "Priority" menu which contains a selection of the 
five execution priorities. One of these five are always marked with a radio 
button to show the current priority.

Next to the "Priority" menu is the "Help F1" menu which contains "Help Form" and 
"About". The "About is obvious. Pressing F1 or selecting "Help Form" brings up a 
third or Help form containing this help text that can be scrolled up and down to 
review.

This Help form has a "File" menu that has the options "Print Setup", "Print", 
"Print Preview" and "Exit". These are straightforward. The Exit merely exits 
this Help form. The calculations have continued during the Help session.

To install, copy the files PrimeSRcs.exe and PrimeSRcsHelp.txt to any folder and 
execute the .exe file from there. For development, the following 17 files are 
required:

   AboutForm.cs
   AboutForm.resx
   AssemblyInfo.cs
   cs.ico
   Global.cs
   harry.jpg
   HelpForm.cs
   HelpForm.resx
   NPrimes.cs
   PrimeSRcs.csproj
   PrimeSRcs.sln
   PrimeSRcs.suo
   PrimeSRcs.csproj.user
   RunForm.cs
   RunForm.resx
   StartupForm.cs
   StartupForm.resx

The program can generate the following 5 files:

   PrimeSRcsRfile.Bak  Copy of previous PrimeSRcsRFile.txt file
   PrimeSRcsRFile.Too  Results in a data table when "Numbers got too large!"
   PrimeSRcsRFile.txt  Results in an accumulated data table
   PrimeSRcsSnapS.Bak  Copy of previous PrimeSRcsSnapS.txt file
   PrimeSRcsSnapS.txt  Snap Shot of all data for restart, forced every hour

The latest version of the program as well as the latest results and restart 
files can be downloaded from my website:

      http://www.oocities.com/hjsmithh/download.html#PrimeSR 


The end -

Report any errors by sending me a letter, an e-mail or call me at my home phone.




-Harry

Harry J. Smith
19628 Via Monte Dr.
Saratoga, CA 95070-4522, USA

Home Phone:  1 408 741-0406
E-mail:  hjsmithh@sbcglobal.net
Website:  http://www.oocities.com/hjsmithh/

Return to Calculator Programs
Return to Harry's Home Page


This page accessed times since November 4, 2007.
Page created by: hjsmithh@sbcglobal.net
Changes last made on Wednesday, 12-Dec-07 09:44:43 PST

1