mersenneforum.org  

Go Back   mersenneforum.org > Factoring Projects > Aliquot Sequences

Reply
 
Thread Tools
Old 2021-03-26, 23:47   #1
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

24·257 Posts
Default A Tool for Studying Aliquot Sequence Data

I've written a program to use Jean-Luc Garambois' "regina_file" to display various compilations of data, such as terminating primes, cycles and open-ended merges. The program is an amateur version of C++ that should compile with g++ under any linux OS. Feel free to modify in any manner and to provide critique.

Edit: Forgot to add the link to the page with the regina_file (Thanks Henry): http://www.aliquotes.com/aliquote_base.htm#alibasefonda

Edit2: I had to fix a bug that mishandled out of bounds entries. (New source provided at: 2021-03-27 at 08:38)

An example of a run with the program named seqinfo (entries are highlighted):
Code:
$ ./seqinfo 
Data available for sequences 2 through 14000000 
Enter sequence (q to quit): 13456987 
13456987 terminates with prime 13456987. 
List all sequences that terminate with 13456987? (y/n/f): y 
13456987   
1 sequence found. 
Enter sequence (q to quit): 13930332 
13930332 is open ended. It merges with 4788. 
Enter sequence (q to quit): 284 
284 ends in a cycle. Display cycle? (starts at entry point) (y/n/f): y 
284 
220 
Display all sequences that end in this cycle? (y/n/f): y 
220       284       562       80089     236883    438311    516551    543309
710637    850967    880847    1361207   1502809   1571111   1634599   1932199
2584945   2961887   3075271   3079297   3196247   3293689   3434375   3583153 
4045895   4229785   4388329   5201945   5361407   5681929   7119911   8078687
8172965   8210735   8450785   8717711   8867495   9238099   9246265   9544409
9588729   9660965   9822335   9849451   10080601  10322491  10519607  10628569
10749529  10770475  11071655  11288185  11910911  12137673  12710149  13280375
13347719  13366297  13647655   
59 sequences found. 
Enter sequence (q to quit): q 
$
The source code:
Code:
////////////////////////////////////////////////////////////////////////////////// 
// This program is designed to display cumulative data for Aliquot sequences.   // 
// The program relies on a file named "regina_file" which must be retrieved and // 
// unpacked from this file: regina_file.tar.lzma.  The file can be retrieved    // 
// from this site: http://www.aliquotes.com/aliquote_base.htm#alibasefonda      // 
// The accuracy of this program is dependent on the currency of regina_file.    // 
//                                                                              // 
// To retrieve cycle information, the program has to access factordb.com, so a  // 
// network connection is also necessary.  If no network is available, cycle     // 
// data will show as blank.  wget must also be installed, which is commonly     // 
// available on most linux platforms.                                           // 
//                                                                              // 
// A "results.txt" file can be used to capture the output of various data sets. // 
// This file is never deleted or overwritten by the program.  It only appends   // 
// new data to its end.  Therefore, it is necessary to manually remove the file // 
// if old data is no longer wanted.                                             // 
//                                                                              // 
// Most functions are self-explanatory.  When a (y/n/f) prompt is offered, the  // 
// "f" means to send data to the results.txt file as well as the screen.  The   // 
// formatting is slightly different between them.  The file output is displayed // 
// with one element per line, while the screen output is displayed in columns.  // 
// The screen display is based on a screen width of 0 (mod 10).  Any variation  // 
// of columns not equal to 0 (mod 10) will not be aligned properly.             // 
//                                                                              // 
// Compile with "g++ <filename> -o <program name>"                              // 
////////////////////////////////////////////////////////////////////////////////// 
#include <iostream> 
#include <fstream> 
 
using namespace std; 
 
int main() 
{ 
    ifstream in, cyc; 
    ofstream out; 
    static string stype[15000000], extra1[15000000], cycles[100]; 
    string buff, numt, temp, seqq, yn; 
    size_t found, foundc1, foundc2, foundc3, foundc4, founde, foundp; 
    int c, i=2, j, k, rcount, seqn; 
 
    in.open("regina_file"); 
    if(in.is_open()){ 
        cout << " Reading regina_file . . .\r"; 
        fflush(stdout); 
        while(!in.eof()){ 
            getline(in,buff); 
            found=buff.find("["); 
            if(found!=string::npos){ 
                numt=to_string(i); 
                j=numt.length()+3; 
                temp.assign(buff.substr(j,1)); 
                if(temp=="1") 
                    stype[i].assign("p"); 
                else if(temp=="0") 
                    stype[i].assign("o"); 
                else 
                    stype[i].assign("c"); 
 
                foundc1=buff.find(","); 
                if(foundc1!=string::npos){ 
                    temp.assign(buff.substr(foundc1+2)); 
                    foundc2=temp.find(","); 
                    if(foundc2!=string::npos){ 
                        temp.assign(temp.substr(foundc2+2)); 
                        foundc3=temp.find(","); 
                        if(foundc3!=string::npos){ 
                            temp.assign(temp.substr(foundc3+2)); 
                            foundc4=temp.find(","); 
                            extra1[i].assign(temp.substr(0,foundc4)); 
                        } 
                    } 
                } 
            } 
            i++; 
        } 
        in.close(); 
        i--; 
    } 
    else{ 
        cout << "An error occurred with regina_file. Is it present?" << endl; 
        return 0; 
    } 
    cout << "Data available for sequences 2 through " << i-1 << endl; 
 
    do{ 
        cout << "Enter sequence (q to quit): "; 
        getline(cin, seqq); 
        if(seqq=="q") 
            return 0; 
        seqn=atoi(seqq.c_str()); 
        if(seqn>1 && seqn<i){ 
            if(stype[seqn]=="p"){ 
                cout << seqn << " terminates with prime " << extra1[seqn] << "." << endl; 
                cout << "List all sequences that terminate with " << extra1[seqn] << "? (y/n/f): "; 
                getline(cin, yn); 
                if(yn.substr(0,1)=="y" || yn.substr(0,1)=="f"){ 
                    if(yn.substr(0,1)=="f"){ 
                        out.open("results.txt", std::ios_base::app); 
                        out << "All sequences that terminate with " << extra1[seqn] << ":" << endl; 
                    } 
                    rcount=0; 
                    for(j=2;j<i;j++){ 
                        if(extra1[j]==extra1[seqn]){ 
                            if(out.is_open()) 
                                out << j << endl; 
                            temp.assign(to_string(j)); 
                            temp.append("          "); 
                            temp=temp.substr(0,10); 
                            cout << temp; 
                            rcount++; 
                        } 
                    } 
                    if(out.is_open()) 
                        out.close(); 
                    if(rcount>1) 
                        cout << "\n" << rcount << " sequences found." << endl; 
                    else 
                        cout << "\n" << rcount << " sequence found." << endl; 
                } 
            } 
            else if(stype[seqn]=="o"){ 
                cout << seqn << " is open ended. "; 
                if(to_string(seqn)==extra1[seqn]){ 
                    cout << "List any sequences that merge with " << seqn << "? (y/n/f): "; 
                    getline(cin, yn); 
                    if(yn.substr(0,1)=="y" || yn.substr(0,1)=="f"){ 
                        if(yn.substr(0,1)=="f"){ 
                            out.open("results.txt", std::ios_base::app); 
                            out << "All sequences that merge with " << extra1[seqn] << ":" << endl; 
                        } 
                        rcount=0; 
                        for(j=seqn+1;j<i;j++){ 
                            if(extra1[j]==extra1[seqn]){ 
                                if(out.is_open()) 
                                    out << j << endl; 
                                temp.assign(to_string(j)); 
                                temp.append("          "); 
                                temp=temp.substr(0,10); 
                                cout << temp; 
                                rcount++; 
                            } 
                        } 
                        if(out.is_open()) 
                            out.close(); 
                        if(rcount>1) 
                            cout << "\n" << rcount << " sequences found." << endl; 
                        else if(rcount==1) 
                            cout << "\n" << rcount << " sequence found." << endl; 
                        else 
                            cout << "No merges found." << endl; 
                    } 
                } 
                else 
                    cout << "It merges with " << extra1[seqn] << "." << endl; 
            } 
            else if(stype[seqn]=="c"){ 
                c=0; 
                cout << seqn << " ends in a cycle. Display cycle? (starts at entry point) (y/n/f): "; 
                getline(cin, yn); 
                if(yn.substr(0,1)=="y" || yn.substr(0,1)=="f"){ 
                    if(yn.substr(0,1)=="f"){ 
                        out.open("results.txt", std::ios_base::app); 
                        out << seqn << " ends with the following cycle:" << endl; 
                    } 
                    temp.assign("wget \"http://www.factordb.com/elf.php?seq="); 
                    temp.append(extra1[seqn]); 
                    temp.append("&type=1\" -q -O cycle.tmp"); 
                    system(temp.c_str()); 
                    cyc.open("cycle.tmp"); 
                    if(cyc.is_open()){ 
                        while(!cyc.eof()){ 
                            getline(cyc, buff); 
                            foundp=buff.find("."); 
                            founde=buff.find("="); 
                            if(founde!=string::npos && foundp!=string::npos){ 
                                cycles[c].assign(buff.substr(foundp+4,founde-foundp-5)); 
                                c++; 
                            } 
                        } 
                        cyc.close(); 
                        c-=2; 
                        for(j=0;j<c;j++){ 
                            if(out.is_open()) 
                                out << cycles[j] << endl; 
                            cout << cycles[j] << endl; 
                        } 
                        if(out.is_open()) 
                            out.close(); 
                    } 
                    else 
                        cout << "An error was encountered trying to read cycle.tmp!" << endl; 
                } 
                cout << "Display all sequences that end in this cycle? (y/n/f): "; 
                getline(cin, yn); 
                if(yn.substr(0,1)=="y" || yn.substr(0,1)=="f"){ 
                    if(yn.substr(0,1)=="f"){ 
                        out.open("results.txt", std::ios_base::app); 
                        out << "All sequences that end in the same cycle as " << extra1[seqn] << ":" << endl; 
                    } 
                    rcount=0; 
                    if(c==0){ 
                        temp.assign("wget \"http://www.factordb.com/elf.php?seq="); 
                        temp.append(extra1[seqn]); 
                        temp.append("&type=1\" -q -O cycle.tmp"); 
                        system(temp.c_str()); 
                        cyc.open("cycle.tmp"); 
                        if(cyc.is_open()){ 
                            while(!cyc.eof()){ 
                                getline(cyc, buff); 
                                foundp=buff.find("."); 
                                founde=buff.find("="); 
                                if(founde!=string::npos && foundp!=string::npos){ 
                                    cycles[c].assign(buff.substr(foundp+4,founde-foundp-5)); 
                                    c++; 
                                } 
                            } 
                            cyc.close(); 
                            c-=2; 
                        } 
                        else 
                            cout << "An error was encountered trying to read cycle.tmp!" << endl; 
                    } 
                    for(j=2;j<i;j++) 
                        for(k=0;k<c;k++) 
                            if(cycles[k]==extra1[j]){ 
                                if(out.is_open()) 
                                    out << j << endl; 
                                temp.assign(to_string(j)); 
                                temp.append("          "); 
                                temp=temp.substr(0,10); 
                                cout << temp; 
                                rcount++; 
                            } 
                    if(out.is_open()) 
                        out.close(); 
                    if(rcount>1 || rcount<1) 
                        cout << "\n" << rcount << " sequences found." << endl; 
                    else 
                        cout << "\n" << rcount << " sequence found." << endl; 
                } 
            } 
            else 
                cout << "Sequence appears to be incomplete!" << endl; 
        } 
        else 
            cout << "Sequence is outside current bounds of 2 through " << i-1 << endl;; 
    }while(seqq.substr(0,1)!="q"); 
 
    return 0; 
}

Last fiddled with by EdH on 2021-03-27 at 13:39
EdH is offline   Reply With Quote
Old 2021-03-27, 10:08   #2
henryzz
Just call me Henry
 
henryzz's Avatar
 
"David"
Sep 2007
Cambridge (GMT/BST)

2·2,969 Posts
Default

The regina_file mentioned above is at http://www.aliquotes.com/aliquote_base.htm
henryzz is offline   Reply With Quote
Old 2021-03-27, 12:20   #3
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

24·257 Posts
Default

Quote:
Originally Posted by henryzz View Post
The regina_file mentioned above is at http://www.aliquotes.com/aliquote_base.htm
Thanks! I forgot to add the link to the page. The link I added to the first post will go to that section of the page.
EdH is offline   Reply With Quote
Old 2021-03-27, 17:58   #4
garambois
 
garambois's Avatar
 
"Garambois Jean-Luc"
Oct 2011
France

2AC16 Posts
Default

Thank you very much Edwin !
Superb work !
It is for this purpose that I created the "regina_file" file a few years ago.
I wanted to be able to do that kind of research and statistics.

I allow myself to provide some details here on this "regina_file" file.

The calculations are still going on and in a few months I will release the "regina_file" version up to 15,000,000.
I want to clarify that this file contains a lot more information about the aliquot sequences, but I dare not try here to do the English translation of the page which explains the meaning of all the variables contained in the file for each aliquot sequence.
For example, we can know for each sequence the number of parity changes, the number of peaks in the graph and other things that are useful to me.
To learn more, check out the link given above.
And if your automatic translator tells you nonsense, ask me here for further explanation, I will try to explain things to you differently to make it easier to understand.
When using this file, always keep in mind that the computation of each sequence was interrupted as soon as the size of the terms first reached 10^50.
Some sequences considered as Open End in this file are therefore finished or merged in FactorDB.
Note that we can find further additional information in the three additional files which you will find the links below on this page :
"regina_cycles"
"regina_prems"
"regina_opens"
Finally, on this other page, but sorry also written in French, I show what type of research we can do thanks to these 4 files (regina_file, regina_prems, regina_opens, regina_cycles).
Some records presented are quite funny.
Other example, we can look for sequences whose graph is in the shape of a "bell", these are sequences with a single maximum.
And other funny things ...
garambois is offline   Reply With Quote
Old 2021-03-27, 21:20   #5
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

24·257 Posts
Default

I'm glad you approve, Jean-Luc! I have already been studying the text you provide for elements of regina_file and am also already adding more features to the program. I'll be adding posts here with newer features as I add them. As can be seen in the source, I'm already set to accept a new file up to (almost) 15M. I will adjust that greater as the file is enlarged, as well.

I'm also looking over other portions of your pages. I forgot how much you had documented things within my interests. One of the things this program will soon be able to do is to provide a count of many of the things you are tracking.

I too find interesting things within this research, such as 28 being untouchable from any number but itself, while the other perfect numbers within the current set have many sequences that reach them:
Code:
Enter sequence (q to quit): 6 
6 ends in a cycle. Display cycle? (starts at entry point) (y/n/f): y 
6 
Display all sequences that end in this cycle? (y/n/f): y 
. . . 
63275 sequences found. 
Enter sequence (q to quit): 28 
28 ends in a cycle. Display cycle? (starts at entry point) (y/n/f): y 
28 
Display all sequences that end in this cycle? (y/n/f): y 
28         
1 sequence found. 
Enter sequence (q to quit): 496 
496 ends in a cycle. Display cycle? (starts at entry point) (y/n/f): y 
496 
Display all sequences that end in this cycle? (y/n/f): y 
496       608       650       652       790       1294      1574      1778
2162      2582      3142      5158      368449    1492799   1535075   1767455
1842215   2256401   2974751   3157729   3837505   3873551   4018945   4170127
4605213   4669921   5076873   5251285   5616985   6977649   7349365   7463965
7505901   7589845   7601365   7675345   8109041   8697385   8837245   8924241
11035163  12856335  13157075  13384167  13631207   
45 sequences found. 
Enter sequence (q to quit): 8128 
8128 ends in a cycle. Display cycle? (starts at entry point) (y/n/f): y 
8128 
Display all sequences that end in this cycle? (y/n/f): y 
. . . 
15492 sequences found.
EdH is offline   Reply With Quote
Old 2021-03-27, 21:33   #6
henryzz
Just call me Henry
 
henryzz's Avatar
 
"David"
Sep 2007
Cambridge (GMT/BST)

10111001100102 Posts
Default

If you haven't already I would suggest reading https://arxiv.org/abs/1610.07471
henryzz is offline   Reply With Quote
Old 2021-03-28, 08:34   #7
garambois
 
garambois's Avatar
 
"Garambois Jean-Luc"
Oct 2011
France

12548 Posts
Default

Quote:
Originally Posted by henryzz View Post
If you haven't already I would suggest reading https://arxiv.org/abs/1610.07471

Yes, Andrew R. Booker has explored the issue of "finite connected components of the aliquot graph".
His work is wonderful, the concept is very beautiful !

The study of the infinite graph of aliquot sequences has given rise to many questions and conjectures, in particular on the presence of all possible graphs in this graph.
You can get an idea of it by looking here and especially here (We understand better when we see diagrams).
But once again, sorry, it's in French !

Everything becomes even more complicated if we decide to take into account the length of the branches of the graph.
It is this new research which made me, for example, ask you this annoying question on this forum, which still remains unanswered today.
But my computer is doing calculations right now ...
garambois is offline   Reply With Quote
Old 2021-03-28, 08:59   #8
garambois
 
garambois's Avatar
 
"Garambois Jean-Luc"
Oct 2011
France

22×32×19 Posts
Default

Quote:
Originally Posted by EdH View Post
I'm glad you approve, Jean-Luc! I have already been studying the text you provide for elements of regina_file and am also already adding more features to the program. I'll be adding posts here with newer features as I add them. As can be seen in the source, I'm already set to accept a new file up to (almost) 15M. I will adjust that greater as the file is enlarged, as well.

I'm also looking over other portions of your pages. I forgot how much you had documented things within my interests. One of the things this program will soon be able to do is to provide a count of many of the things you are tracking.

I too find interesting things within this research, such as 28 being untouchable from any number but itself, while the other perfect numbers within the current set have many sequences that reach them:

Thank you very much Edwin, it's great that you have decided to add in your program the possibility of exploiting more data from the regina_file file.
Personally, I will use your program quite often, that's for sure ...

Ideally, my program should run not by calculating the sequences on the machine, but by scanning the sequences on FactorDB.
Thus, the regina_file file and the three other complementary files would be much more complete.
I have already thought about this question.
But I think that we should only scan the sequences up to 10 M.
Because I am not sure that beyond that, someone has already done systematic calculations for all the sequences.
Indeed, if I enter 15,000,018 in FactorDB, the maximum term size is 50 digits.
garambois is offline   Reply With Quote
Old 2021-03-28, 09:21   #9
garambois
 
garambois's Avatar
 
"Garambois Jean-Luc"
Oct 2011
France

22×32×19 Posts
Default

I also want to take the opportunity here to ask a substantive question about the regina_file.
Each line in this file looks like this :

[n, a, b, c, d, e, f, g, h, i, j, k, l, m]

n is the starting number of the aliquot sequence.
k is the "arithmetic mean" (*) over all the terms of the quotients su+1(n) / su(n) (next term divided by the previous one).
However, it would seem that for mathematicians, it would be much easier to work with the "geometric mean" (*) of these quotients.
Now, the "geometric mean" of the quotients of the successive terms does not appear in the regina_file file.

Would it be interesting to add a variable "o" which is the "geometric mean" of the quotients ?

If anyone has an opinion on this matter, it interests me the most !
In a few days or weeks of calculation, I could maybe add this geometric mean, but I'm not so sure, I still have to check.
And I will only do this job if I am told here that it would be useful.


(*) I hope the machine translation correctly translated "arithmetic mean" and "geometric mean"!
garambois is offline   Reply With Quote
Old 2021-03-28, 11:40   #10
Happy5214
 
Happy5214's Avatar
 
"Alexander"
Nov 2008
The Alamo City

23·97 Posts
Default

Quote:
Originally Posted by garambois View Post
k is the "arithmetic mean" (*) over all the terms of the quotients su+1(n) / su(n) (next term divided by the previous one).
However, it would seem that for mathematicians, it would be much easier to work with the "geometric mean" (*) of these quotients.
Now, the "geometric mean" of the quotients of the successive terms does not appear in the regina_file file.

Would it be interesting to add a variable "o" which is the "geometric mean" of the quotients ?

If anyone has an opinion on this matter, it interests me the most !
In a few days or weeks of calculation, I could maybe add this geometric mean, but I'm not so sure, I still have to check.
And I will only do this job if I am told here that it would be useful.


(*) I hope the machine translation correctly translated "arithmetic mean" and "geometric mean"!
First of all, the translation came through correctly. Geometric means work better than arithmetic means for growth rates, which seem to be what the quotients are really serving as, so I think they're worth adding.
Happy5214 is offline   Reply With Quote
Old 2021-04-01, 17:12   #11
garambois
 
garambois's Avatar
 
"Garambois Jean-Luc"
Oct 2011
France

12548 Posts
Default

Quote:
Originally Posted by Happy5214 View Post
First of all, the translation came through correctly. Geometric means work better than arithmetic means for growth rates, which seem to be what the quotients are really serving as, so I think they're worth adding.

OK, I'll try to add that over the next few weeks.
I just realized that the geometric mean of the quotients of the successive terms can be written in a fairly simple way.
Indeed, if n is the starting number of the sequence, and if the calculation of the sequence was interrupted at index i, with the term si(n), then the geometric mean x of the quotients of the successive terms is calculates as follows :
x = [s1(n)/n * s2(n)/s1(n) * s3(n)/s2(n) * ........ * si-1(n)/si-2(n) * si(n)/si-1(n)](1/i) = [si(n)/n](1/i)
Only the starting number of the aliquot sequence, the last term and the number of terms are therefore involved in the calculation of this mean.

- For Open End sequences, no problem.

- For sequences that end with 1, it seems more interesting to me to consider the prime number as the last term of the sequence, rather than 1.

- For the sequences which end with a cycle, or which start with a number which belongs to a cycle, I don't know how to do it.
It seems reasonable to me to have a geometric mean of 1 for perfect numbers.
For amicable numbers, it's much more complicated.
If n = 220, the sequence is: 220 -> 284 -> 220 -> 284 ...
So I can take x = 284/220.
But I can also take x = (220/220) ^ (1/2) = 1.
For cycles longer than 2, it seems reasonable to go around the entire cycle before calculating the mean.
But if we proceed like this, if we take a number n which belongs to the cycle, the average will always be equal to 1.

I have to think about this cycle question, unless somebody here has a suggestion for me ?
garambois is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Aliquot sequence reservations schickel Aliquot Sequences 3622 2021-12-03 18:21
Useful aliquot-sequence links 10metreh Aliquot Sequences 4 2021-10-28 22:17
Extending an aliquot sequence backwards arbooker Aliquot Sequences 11 2021-09-10 05:28
A new tool to identify aliquot sequence margins and acquisitions garambois Aliquot Sequences 24 2021-02-25 23:31
Another Aliquot Sequence site schickel Aliquot Sequences 67 2012-01-20 17:53

All times are UTC. The time now is 04:16.


Sun Dec 5 04:16:33 UTC 2021 up 134 days, 22:45, 0 users, load averages: 1.14, 1.05, 1.01

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.