mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   PARI/GP (https://www.mersenneforum.org/forumdisplay.php?f=155)
-   -   PARI's commands (https://www.mersenneforum.org/showthread.php?t=13636)

CRGreathouse 2010-08-09 20:40

I left that one off because you chose (inscrutably) to start at 8 rather than 1, so I supposed you had a reason to do so.

science_man_88 2010-08-09 20:44

[QUOTE=CRGreathouse;224644]I left that one off because you chose (inscrutably) to start at 8 rather than 1, so I supposed you had a reason to do so.[/QUOTE]
how do I jump to the start of the specific loop without messing things up ? labels ?

CRGreathouse 2010-08-09 20:50

[QUOTE=science_man_88;224645]how do I jump to the start of the specific loop without messing things up ? labels ?[/QUOTE]

You probably don't want to do that. Tell me what your goal is and I'll give you a way.

science_man_88 2010-08-09 20:51

[QUOTE=CRGreathouse;224646]You probably don't want to do that. Tell me what your goal is and I'll give you a way.[/QUOTE]

[CODE] if(v[i]=0,\\skip over making it 0 again)[/CODE]

could we not use a while actually while(v[i]!=0,v[i]=0) I think my logic is sinking in more than normal as I haven't programmed in another language in a while i have no idea why lol.

CRGreathouse 2010-08-09 20:52

next() rather than break(). Actually, neither requires the parentheses.

science_man_88 2010-08-09 20:58

[QUOTE=CRGreathouse;224649]next() rather than break(). Actually, neither requires the parentheses.[/QUOTE]

thanks my while did work but I tested for speed if statements are faster lol.

reason i started at 8 was because that was my next 0 I could explain with the current pattern

now that's up to 31 not including 0

CRGreathouse 2010-08-09 21:07

[QUOTE=science_man_88;224650]thanks my while did work but I tested for speed if statements are faster lol.[/QUOTE]

Just make sure that the version you check is actually correct. I can get an incorrect result very quickly. :smile:

science_man_88 2010-08-09 21:11

[QUOTE=CRGreathouse;224653]Just make sure that the version you check is actually correct. I can get an incorrect result very quickly. :smile:[/QUOTE]

[CODE]for(i=4,100,if(i%5==4 || i%7==1 || (i>=20 && i%8==4),print1(i", ")))[/CODE]

what I've been using to test patterns last little while.

[CODE](18:14) gp > for(i=1,1000,if(foo(i)!=vector(i,n,isprime(6*n+1)),print(i);break()))
20[/CODE]

shows my first 2 equations I suggest give accurate results until 20 which isn't covered by the first 2 equations and i haven't implemented the third yet.

CRGreathouse 2010-08-09 21:23

[QUOTE=science_man_88;224654][CODE]for(i=4,100,if(i%5==4 || i%7==1 || (i>=20 && i%8==4),print1(i", ")))[/CODE]

what I've been using to test patterns last little while.[/QUOTE]

That prints numbers that are 4 mod 5, or 1 mod 7, or 4 mod 8, with the exception of 12. In particular, it displays 112 out of the 280 residue classes mod 280 (again, with the exception of 12).

I don't see what this has to do with your earlier code.

[QUOTE=science_man_88;224654][CODE](18:14) gp > for(i=1,1000,if(foo(i)!=vector(i,n,isprime(6*n+1)),print(i);break()))
20[/CODE]

shows my first 2 equations I suggest give accurate results until 20 which isn't covered by the first 2 equations and i haven't implemented the third yet.[/QUOTE]

So your plan is to have v[i] be 0 if 6*i+1 is composite and 1 otherwise?

science_man_88 2010-08-09 21:36

[QUOTE=CRGreathouse;224658]That prints numbers that are 4 mod 5, or 1 mod 7, or 4 mod 8, with the exception of 12. In particular, it displays 112 out of the 280 residue classes mod 280 (again, with the exception of 12).

I don't see what this has to do with your earlier code.



So your plan is to have v[i] be 0 if 6*i+1 is composite and 1 otherwise?[/QUOTE]

the first code shown here prints out all indexes that according to my patterns should give composites and then i can compare it to [url]http://www.research.att.com/~njas/sequences/A046954[/url]

the second code checks to see if foo(n) is accurate against isprime(6*n+1) if not it's found the next place a 0 is needed hence the b in the form ax+b for my patterns.

CRGreathouse 2010-08-09 23:07

[QUOTE=science_man_88;224660]the first code shown here prints out all indexes that according to my patterns should give composites and then i can compare it to [url]http://www.research.att.com/~njas/sequences/A046954[/url][/QUOTE]

OK, simple enough. So for a given prime p you need to find the first time that the prime p divides 6n + 1, then from that index mark off every p-th member of the array.

I think this would be
[code]v=vector(10^6,unused,1);
forprime(p=5,sqrt(10^6*6+1),
forstep(i=lift(Mod(-1,p)/6),10^6,p,v[i]=0)
);[/code]
but I haven't checked it. I think the first time that p divides 6n+1 is when n = lift(Mod(-1,p)/6)...?

Actually you should probably make this its own function

[code]first(p)={
lift(Mod(-1,p)/6)
};

v=vector(10^6,unused,1);
forprime(p=5,sqrt(10^6*6+1),
forstep(i=first(p),10^6,p,v[i]=0)
);[/code]
so that you can modify it. In this case you want to exclude the case that 6n+1 is p itself, something like

[code]first(p)={
if(p%6==1,
2*p
,
lift(Mod(-1,p)/6)
)
};

v=vector(10^6,unused,1);
forprime(p=5,sqrt(10^6*6+1),
forstep(i=first(p),10^6,p,v[i]=0)
);[/code]

You can try these. Like I said, I haven't. :smile:

science_man_88 2010-08-09 23:25

couldn't this be simplified to:

px=6n+1
px-1 = 6n
(p/6)x-1/6 = n ?

so what else is there ?

is it too late to tell you this same thing but more complicated is what i wanted for my 24m+7 with 6n+p/-p and then applying the pattern equations to weed out members of either A002450 or A121290.

CRGreathouse 2010-08-09 23:30

[QUOTE=science_man_88;224675]couldn't this be simplified to:

px=6n+1
px-1 = 6n
(p/6)x-1/6 = n ?

so what else is there ?[/QUOTE]

I don;'t see how that would work, but you're welcome to code it up. If it works then I'll be able to see what the code does; if not, you'll know.

science_man_88 2010-08-09 23:36

[QUOTE=CRGreathouse;224676]I don;'t see how that would work, but you're welcome to code it up. If it works then I'll be able to see what the code does; if not, you'll know.[/QUOTE]

no code here it's basic math

px=6n+1
px-1 = 6n+1-1 = 6n

(px-1)/6 = n
(p/6)x-1/6 = n

technically it could be applied as:

[CODE]p=5;for(x=1,p,if(((p/6)*x-(1/6))%1==0,print((p/6)*x-(1/6))))[/CODE]

CRGreathouse 2010-08-09 23:50

[QUOTE=science_man_88;224678]no code here it's basic math[/QUOTE]

It's not clear what you're doing because you don't define x and you don't say how to handle division (round down, round up, leave as a rational, divide mod p).

[QUOTE=science_man_88;224678][CODE]p=5;for(x=1,p,if(((p/6)*x-(1/6))%1==0,print((p/6)*x-(1/6))))[/CODE][/QUOTE]

Ah. So you mean that you can find the least instance by trying all instances. Yes, I was just trying to avoid doing that.

science_man_88 2010-08-09 23:56

[QUOTE=CRGreathouse;224679]It's not clear what you're doing because you don't define x and you don't say how to handle division (round down, round up, leave as a rational, divide mod p).



Ah. So you mean that you can find the least instance by trying all instances. Yes, I was just trying to avoid doing that.[/QUOTE]

yeah It just seems simpler lol. so figure out what I wanted with the 6np+/-p and 24m+7 idea with those sequences ?

CRGreathouse 2010-08-10 00:05

[QUOTE=science_man_88;224680]yeah It just seems simpler lol.[/QUOTE]

And that's fine. If you have a way to solve a problem, but you know it's inefficient, just put it in its own function. If it turns out to be a bottleneck, you can re-write it later to make it fast; if not, you can leave it.

[QUOTE=science_man_88;224680]so figure out what I wanted with the 6np+/-p and 24m+7 idea with those sequences ?[/QUOTE]

Nope, never did.

science_man_88 2010-08-10 00:26

[QUOTE=science_man_88;224675]
is it too late to tell you this same thing but more complicated is what i wanted for my 24m+7 with 6n+p/-p and then applying the pattern equations to weed out members of either A002450 or A121290.[/QUOTE]

got it yet ?

CRGreathouse 2010-08-10 00:38

Nope. Find someone to translate sm88-ese into CRGreathouse-ese, or figure out how to code it in Pari. (Clearly, I read Pari better than English.)

science_man_88 2010-08-10 00:45

[CODE]6np+/-p 24m+7
└────┬────┘
Equations(m's) A002450 or A121290
[INDENT] └────┬────┘[/INDENT][INDENT] Mersenne Primes
[/INDENT][/CODE]

best I can do is a picture translation.

according to what you say:

[CODE]p 6n+1
└────┬────┘
n that work to primes[/CODE]

CRGreathouse 2010-08-10 01:16

That means nothing to me. Find someone who understands it and have her explain it to me.

3.14159 2010-08-10 12:46

[QUOTE=CRGreathouse]That means nothing to me. Find someone who understands it and have her explain it to me.
[/QUOTE]

He's a dude.

Also: I'm looking for a 2n-1 Cunningham chain of length 6.

CRGreathouse 2010-08-10 13:11

[QUOTE=3.14159;224721]He's a dude. [/QUOTE]

The person who will explain sm88's ideas to me is a dude? How could you know that? I can't even prove that such a person exists, let alone guess at their sex.

[QUOTE=3.14159;224721]Also: I'm looking for a 2n-1 Cunningham chain of length 6.[/QUOTE]

[url=http://oeis.org/classic/A057329]A057329[/url]. :rolleyes:

3.14159 2010-08-10 13:26

[QUOTE=CRGreathouse]The person who will explain sm88's ideas to me is a dude? How could you know that? I can't even prove that such a person exists, let alone guess at their sex.
[/QUOTE]

I was assuming you meant sm88 himself.

[QUOTE=CRGreathouse]A057329. :rolleyes:[/QUOTE]

You see, before you make any more smug/arrogant posts, please be aware I was looking in the 10[sup]55[/sup] range.

Man, your ego is really overinflated. Claim "superiority" elsewhere.

CRGreathouse 2010-08-10 13:35

[QUOTE=3.14159;224725]You see, before you make any more smug/arrogant posts, please be aware I was looking in the 10[sup]55[/sup] range.

Man, your ego is really overinflated. Claim "superiority" elsewhere.[/QUOTE]

That's humor, not arrogance. Just like giving the smallest possible examples when you asked for 10,000+ digit primes. :smile:

3.14159 2010-08-10 15:33

[QUOTE=3.14159]That's humor, not arrogance. Just like giving the smallest possible examples when you asked for 10,000+ digit primes.
[/QUOTE]

Are you sure of that? You rubbed off as quite smug.

Also: I'm going to stick to an easy p and 2p-1 prime set.

A quick snippet of the printout:
[code]5336101 * 10672201 = 56947942428301
48024901 * 96049801 = 4612782184094701
58697101 * 117394201 = 6890699272911301
128066401 * 256132801 = 32802006002119201
213444001 * 426888001 = 91116682912332001
405543601 * 811087201 = 328931224218550801
442896301 * 885792601 = 392314266436068901
661676401 * 1323352801 = 875631318618949201
763062301 * 1526124601 = 1164528149651766901
779070601 * 1558141201 = 1213902001905931801
864448201 * 1728896401 = 1494541383559824601
949825801 * 1899651601 = 1804338103540757401
1013859001 * 2027718001 = 2055820146803577001
1077892201 * 2155784401 = 2323703192875356601
1115244901 * 2230489801 = 2487542377297754701
1184614201 * 2369228401 = 2806621609237122601
1195286401 * 2390572801 = 2857419159635779201
1366041601 * 2732083201 = 3732139309959244801
1392722101 * 2785444201 = 3879349699834986301
1520788501 * 3041577001 = 4625595328026865501
1739568601 * 3479137201 = 6052197833430625801
1872971101 * 3745942201 = 7016041488489333301
1899651601 * 3799303201 = 7217352408464074801
1958348701 * 3916697401 = 7670259267458426101
1990365301 * 3980730601 = 7923108060859275901
1995701401 * 3991402801 = 7965648161911024201
2011709701 * 4023419401 = 8093951840183309101
2027718001 * 4055436001 = 8223280581131154001
2134440001 * 4268880001 = 9111668233603320001
2155784401 * 4311568801 = 9294812765034073201
2177128801 * 4354257601 = 9479779630110266401
2235825901 * 4471651801 = 9997834916929097701
2411917201 * 4823834401 = 11634689166547431601
2604016801 * 5208033601 = 13561806997176530401
2609352901 * 5218705801 = 13617445121304878701
2662713901 * 5325427801 = 14180090634494561701
2748091501 * 5496183001 = 15104013792988774501
2817460801 * 5634921601 = 15876170727525662401
3030904801 * 6061809601 = 18372767822418794401
3041577001 * 6083154001 = 18502381302982731001
3068257501 * 6136515001 = 18828408181817272501
3100274101 * 6200548201 = 19223398999562442301
3532498201 * 7064996401 = 24957087076603974601
3553842601 * 7107685201 = 25259594461811047801
3745942201 * 7491884401 = 28064165942719506601
3863336401 * 7726672801 = 29850736290719929201
3868672501 * 7737345001 = 29933253836118517501
4567701601 * 9135403201 = 41727795826988224801
4578373801 * 9156747601 = 41923013318788001401
4733120701 * 9466241401 = 44804863135736342101
4791817801 * 9583635601 = 45923035671169133401
4823834401 * 9647668801 = 46538756651718223201
4914548101 * 9829096201 = 48305566069170864301
5026606201 * 10053212401 = 50533539794836698601
5304083401 * 10608166801 = 56266601444223370201
5346772201 * 10693544401 = 57175945933425996601
5474838601 * 10949677201 = 59947715408524435801
5730971401 * 11461942801 = 65688066392428834201
5741643601 * 11483287201 = 65932942476066850801
5746979701 * 11493959401 = 66055551361665119101
5762988001 * 11525976001 = 66424061393576964001
5949751501 * 11899503001 = 70799085841353754501
6035129101 * 12070258201 = 72845566525439007301
6061809601 * 12123619201 = 73491071271489748801
6136515001 * 12273030001 = 75313632708859545001
6526050301 * 13052100601 = 85178665055838330901
6579411301 * 13158822601 = 86577306128873613901
6590083501 * 13180167001 = 86858401093714750501
6664788901 * 13329577801 = 88838822183120786701
6696805501 * 13393611001 = 89694407829750916501
6702141601 * 13404283201 = 89837404073007544801
6787519201 * 13575038401 = 92140833801099837601
6792855301 * 13585710601 = 92285766273854745901
6963610501 * 13927221001 = 96983742412311331501
7064996401 * 14129992801 = 99828348285220909201
7107685201 * 14215370401 = 101038377825921135601
7465203901 * 14930407801 = 111458538559546031701
7475876101 * 14951752201 = 111777446947530048301
7619950801 * 15239901601 = 116127300411701132401
7683984001 * 15367968001 = 118087220247563952001
7737345001 * 15474690001 = 119733015321262035001
7801378201 * 15602756401 = 121723003662274614601
8009486101 * 16018972201 = 128303735196214878301
8105535901 * 16211071801 = 131399424476694227701
8142888601 * 16285777201 = 132613269528448585801
8169569101 * 16339138201 = 133483718583858327301
8217594001 * 16435188001 = 135057702322324782001
8361668701 * 16723337401 = 139835006922204386101
8495071201 * 16990142401 = 144332469411624093601
8500407301 * 17000814601 = 144513848557287801901
8527087801 * 17054175601 = 145422452723398943401
8687170801 * 17374341601 = 150933873042806792401
9114058801 * 18228117601 = 166132135647057056401
9199436401 * 18398872801 = 169259260182888229201
9210108601 * 18420217201 = 169652200875218245801
9428888701 * 18857777401 = 177807884262262046101
9823760101 * 19647520201 = 193012525034175300301
10053212401 * 20106424801 = 202134159149187157201
10133253901 * 20266507801 = 205365669234130181701
10330689601 * 20661379201 = 213446295254088388801
10373378401 * 20746756801 = 215213958890293255201
10549469701 * 21098939401 = 222582621934084589101
10821610801 * 21643221601 = 234214520645818112401
10949677201 * 21899354401 = 239790861601248711601
10955013301 * 21910026601 = 240024632839218819901
11008374301 * 22016748601 = 242368609490826102901
11045727001 * 22091454001 = 244016169950195181001
11083079701 * 22166159401 = 245669311306353419101
11200473901 * 22400947801 = 250901231202763841701
11307195901 * 22614391801 = 255705358275875207701
11563328701 * 23126657401 = 267421141283177366101
11696731201 * 23393462401 = 273627041565197073601
11750092201 * 23500184401 = 276129333452251956601
11760764401 * 23521528801 = 276631158579897013201
12144963601 * 24289927201 = 295000281727084810801
12459793501 * 24919587001 = 310492908162663880501
12763951201 * 25527902401 = 325836900510254733601
12833320501 * 25666641001 = 329388230149940461501
12886681501 * 25773363001 = 332133120203544544501
13004075701 * 26008151401 = 338211969661673207101
13249536301 * 26499072601 = 351100424369783988901
13585710601 * 27171421201 = 369143065054661851801
13927221001 * 27854442001 = 387934969607463663001
14129992801 * 28259985601 = 399313393098493658401
14327428501 * 28654857001 = 410550414888206785501
14556880801 * 29113761601 = 423805557294487922401
14764988701 * 29529977401 = 436009782666550346101
14850366301 * 29700732601 = 441066758532902478901
15090490801 * 30180981601 = 455445825215040752401
15287926501 * 30575853001 = 467441393384668279501
15298598701 * 30597197401 = 468094244413179176101
15506706601 * 31013413201 = 480915899203487239801
15933594601 * 31867189201 = 507758873802099103801
15970947301 * 31941894601 = 510142315366667421901
16050988801 * 32101977601 = 515268482963603846401
16371154801 * 32742309601 = 536029419020239544401
16408507501 * 32817015001 = 538478236804338022501
16504557301 * 33009114601 = 544800823387480251901
16536573901 * 33073147801 = 546916552749932141701
16723337401 * 33446674801 = 559340027638647532201
16958125801 * 33916251601 = 575156061348125657401
17118208801 * 34236417601 = 586066145092149506401
17134217101 * 34268434201 = 587162791311267471301
17374341601 * 34748683201 = 603735492119104144801
17443710901 * 34887421801 = 608566099977888752701
17667827101 * 35335654201 = 624304228923992301301
17811901801 * 35623803601 = 634527691519122185401
18030681901 * 36061363801 = 650210979612067265701
18137403901 * 36274807801 = 657930840517882631701
18206773201 * 36413546401 = 662973180767096799601
18249462001 * 36498924001 = 666085726633636386001
18318831301 * 36637662601 = 671159160450675873901
18398872801 * 36797745601 = 677037040676356298401
18457569901 * 36915139801 = 681363773282144729701
18580300201 * 37160600401 = 690455111099980980601
18772399801 * 37544799601 = 704805988558397279401
18815088601 * 37630177201 = 708015118108145185801
18943155001 * 37886310001 = 717686242764879465001
19108574101 * 38217148201 = 730275208327707342301
19172607301 * 38345214601 = 735177741417544401901
19647520201 * 39295040401 = 772050100077758640601
19668864601 * 39337729201 = 773728469365272913801
19764914401 * 39529828801 = 781303682537949463201
19807603201 * 39615206401 = 784682289116723289601
19973022301 * 39946044601 = 797843239652513646901
19983694501 * 39967389001 = 798696091798611583501
20021047201 * 40042094401 = 801684662029318821601
20047727701 * 40095455401 = 803822771926837763101
20143777501 * 40287555001 = 811543543999443832501
20351885401 * 40703770801 = 828398478730521976201
20597346001 * 41194692001 = 848501324549224038001
20608018201 * 41216036401 = 849380828324886534601
20714740201 * 41429480401 = 858200923169136300601
20746756801 * 41493513601 = 860855835498932750401
20810790001 * 41621580001 = 866177960910632370001
20853478801 * 41706957601 = 869735156186659316401
20912175901 * 41824351801 = 874638201807818147701
20949528601 * 41899057201 = 877765497187284505801
21072258901 * 42144517801 = 888080190360475196701
21371080501 * 42742161001 = 913446163539073741501
21467130301 * 42934260601 = 921675366698757570901
21477802501 * 42955605001 = 922592000522445907501
21499146901 * 42998293801 = 924426634920056660701
21627213301 * 43254426601 = 935472710312275419901
21787296301 * 43574592601 = 949372560193349268901
21910026601 * 43820053201 = 960098531291145199801
22016748601 * 44033497201 = 969474437897254165801
22032756901 * 44065513801 = 970884753295093490701
22166159401 * 44332318801 = 982677245158915198201
22299561901 * 44599123801 = 994540921930761905701[/code]

I wonder how many are pseudoprime to at least one base.

Also: Tell axn that I found a number that is pseudoprime to 12 bases, fulfilling his earlier challenge:
328931224218550801 is pseudoprime to bases: 251169786077579315, 40862152820310575, 183644156479177715, 225767247325947877, 25444470474523400, 208889906942174523, 269487719751560989, 104170679060552196, 320924599187430222, 62180953435717957, 156917890795425459, and 303417456068163282.

CRGreathouse 2010-08-10 15:46

[QUOTE=3.14159;224730]Are you sure of that? You rubbed off as quite smug. [/QUOTE]

Quite sure. (You're the one who's discovering big primes, not me!)

3.14159 2010-08-10 15:50

I'm sure I would've found 100 failures if I looked long enough.

But, a quick pondering: What are the odds that one person would have stumbled upon that pseudoprime number? That passed for those 12 bases? I would guess 1 in about 10[sup]10[/sup] to 1 in 10[sup]50[/sup]

But, eliminating the guesswork, the actual odds would be in between 1 in 10[sup]198[/sup] and 1 in 10[sup]210[/sup]

So, the odds that someone would have concluded this number to be prime? Virtually zero, to answer my own question.

In fact, I can go further and say: This will [B]never happen[/B], and have good odds of being right. (It has not occurred, because they did not occur consecutively, in the order I posted. I had to repeatedly jab PARI to get the bases.)

CRGreathouse 2010-08-10 16:03

[QUOTE=3.14159;224730]Also: Tell axn that I found a number that is pseudoprime to 12 bases, fulfilling his earlier challenge:
328931224218550801 is pseudoprime to bases: 251169786077579315, 40862152820310575, 183644156479177715, 225767247325947877, 25444470474523400, 208889906942174523, 269487719751560989, 104170679060552196, 320924599187430222, 62180953435717957, 156917890795425459, and 303417456068163282.[/QUOTE]

By my count that's a strong pseudoprime to 55250166363603749 bases:
20, 22, 24, 29, 30, 45, 54, 74, 103, ...

[QUOTE=3.14159;224730]I wonder how many are pseudoprime to at least one base.[/QUOTE]

All numbers on your list are strong pseudoprimes to between 10677736203749 and 186476422849474353749 bases.

CRGreathouse 2010-08-10 16:05

[QUOTE=3.14159;224735]I'm sure I would've found 100 failures if I looked long enough.

But, a quick pondering: What are the odds that one person would have stumbled upon that pseudoprime number? That passed for those 12 bases? I would guess 1 in about 10[sup]10[/sup] to 1 in 10[sup]50[/sup][/QUOTE]

If you'll tell me about the process that caused you to stumble across it I may be able to speak to the probability.

3.14159 2010-08-10 16:06

Also: @CRG: I fiddled with the previous post a lot. Please, refresh before you reply.

3.14159 2010-08-10 16:09

[QUOTE=CRGreathouse]If you'll tell me about the process that caused you to stumble across it I may be able to speak to the probability.
[/QUOTE]

Okay: Suppose the guy stumbles upon the number, with no prior knowledge on whether or not it is prime or composite. Suppose he does 12 iterations of the Miller-Rabin test, and sees that it passes all 12 tests. In the order that I posted them in. He declares it a prime number. The odds of that occurring, I estimate, are about 1 in 10[sup]198[/sup] to 1 in 10[sup]210[/sup]. So it will never occur. That is, if my way of estimating isn't completely wrong, which I have a gut feeling that it is..

CRGreathouse 2010-08-10 16:09

[QUOTE=3.14159;224739]Also: @CRG: I fiddled with the previous post a lot. Please, refresh before you reply.[/QUOTE]

My posts can take considerable time to compose, since they often involve calculation (as post #126). Please don't make substantial edits! When you have new things to say, just make new posts to which I can reply separately.

3.14159 2010-08-10 16:12

[QUOTE=CRGreathouse]My posts can take considerable time to compose, since they often involve calculation (as post #126). Please don't make substantial edits! When you have new things to say, just make new posts to which I can reply separately.
[/QUOTE]

Yes, sorry, I fiddle around with the post frequently whenever I see what I perceive to be an error in phrasing, or see that a certain portion could have been phrased better, etc..

Also: Does that provide a "yes" to my question: Are pseudoprimes more often to be of the form p * (2p-1), where both are primes?

CRGreathouse 2010-08-10 16:15

[QUOTE=3.14159;224741]Okay: Suppose the guy stumbles upon the number, with no prior knowledge on whether or not it is prime or composite. Suppose he does 12 iterations of the Miller-Rabin test, and sees that it passes all 12 tests. In the order that I posted them in. He declares it a prime number. The odds of that occurring, I estimate, are about 1 in 10[sup]198[/sup] to 1 in 10[sup]210[/sup]. So it will never occur.[/QUOTE]

If the number is a bad case for Miller-Rabin, it might be nearly as likely as 1/16777216. In a probabilistic sense, the guy should reject the occurrence (at 95% confidence) if he had tested <= 860558 such numbers. Otherwise, if he had tested <= X such numbers (where X is a number based on the size of the numbers he encountered), he should reject (again, at 95%) the idea that the number was random rather than generated by some process that can favor 'bad' numbers.

CRGreathouse 2010-08-10 16:17

[QUOTE=3.14159;224743]Yes, sorry, I fiddle around with the post frequently whenever I see what I perceive to be an error in phrasing, or see that a certain portion could have been phrased better, etc.[/QUOTE]

Small edits are fine. Major edits are disruptive.

Fortunately it doesn't matter too much since we quote posts -- even if you change your post the version I quoted should make things clear.

[QUOTE=3.14159;224743]Also: Does that provide a "yes" to my question: Are pseudoprimes more often to be of the form p * (2p-1), where both are primes?[/QUOTE]

Statistically speaking, I have some numbers on that in my latest post. I haven't considered the number-theoretic aspect yet.

3.14159 2010-08-10 16:19

[QUOTE=CRGreathouse]If the number is a bad case for Miller-Rabin, it might be nearly as likely as 1/16777216. In a probabilistic sense, the guy should reject the occurrence (at 95% confidence) if he had tested <= 860558 such numbers.[/QUOTE]

Hmm.. How did you come up with the number of bases it is pseudoprime to?

Also: Why reject it? It came up as pseudoprime to 12 bases! It's at least a 99.999% chance of primality!

[QUOTE=CRGreathouse]Statistically speaking, I have some numbers on that in my latest post. I haven't considered the number-theoretic aspect yet.
[/QUOTE]

I was curious, because I saved a list of the base 2 pseudoprimes up to 10[sup]9[/sup], and noticed that a good fraction of them were of the form p * (2p-1), where both numbers are prime.

A recommendation of mine is to compare how many times 700 random p * (2p-1) numbers comes up as pseudoprime, as compared to 700 with no special form - general composites with prime factors of similar size.

3.14159 2010-08-10 16:24

Then, from that, try a larger base of semiprimes, say, 10k or 100k semiprimes, ones of the form p * (2p-1) and general semiprimes with prime factors of similar size, and test how pseudoprime they are, and see if you can come up with some sort of correlation.

science_man_88 2010-08-10 16:31

[QUOTE=3.14159;224748]Hmm.. How did you come up with the number of bases it is pseudoprime to?

Also: Why reject it? It came up as pseudoprime to 12 bases! It's at least a 99.999% chance of primality!



I was curious, because I saved a list of the base 2 pseudoprimes up to 10[sup]9[/sup], and noticed that a good fraction of them were of the form p * (2p-1), where both numbers are prime.

A recommendation of mine is to compare how many times 700 random p * (2p-1) numbers comes up as pseudoprime, as compared to 700 with no special form - general composites with prime factors of similar size.[/QUOTE]

I made a vector(100,p,2*p^2-p) and guess what all the perfect numbers are included and the p that came with them on further test seems to be the super perfect number that you multiply the Mersenne prime by to get it.

3.14159 2010-08-10 16:42

[QUOTE=science_man_88]I made a vector(100,p,2*p^2-p) and guess what all the perfect numbers are included and the p that came with them on further test seems to be the super perfect number that you multiply the Mersenne prime by to get it.
[/QUOTE]

I meant, the products of p and 2p-1, where p is prime, and where 2p-1 is prime. It seems to make up a good portion of the pseudoprime numbers.

CRGreathouse 2010-08-10 16:43

[QUOTE=3.14159;224748]Hmm.. How did you come up with the number of bases it is pseudoprime to?[/QUOTE]

Unfortunately I don't have a reference handy for the formula; my apologies. (I wish I had written this down!)

You can get my Pari code for it here, though:
[url]http://oeis.org/classic/A141768[/url]

Note that this is a formula for *strong* pseudoprimes. There is a similar formula for pseudoprimes, but I have neither the reference nor the formula itself at the moment.

[QUOTE=3.14159;224748]Also: Why reject it? It came up as pseudoprime to 12 bases! It's at least a 99.999% chance of primality![/QUOTE]

Terminology difference. You should statistically reject that as having occurred: "I can't believe that just happened!"

But then again you should reject rolling a 20 on a 20-sided die on a single attempt, too. :redface:

[QUOTE=3.14159;224748]I was curious, because I saved a list of the base 2 pseudoprimes up to 10[sup]9[/sup], and noticed that a good fraction of them were of the form p * (2p-1), where both numbers are prime.

A recommendation of mine is to compare how many times 700 random p * (2p-1) numbers comes up as pseudoprime, as compared to 700 with no special form - general composites with prime factors of similar size.[/QUOTE]

I expect that in a Korselt's criterion-like fashion, having fewer prime factors is advantageous. So there are two essential parts here: test if semiprimes are better than other numbers, and test if these 'Sophie Germain semiprimes' are better than other semiprimes.

I wrote a script to do the latter comparison first. It goes through a block of sequential primes and picks out the Sophie Germain primes, forming the semiprimes as p * (2p + 1). As a comparison, it takes either the next semiprime or the previous semiprime (alternating between the two so as to remove even the small effect of the size difference).

I ran this test on the primes from 10^9 to 10^9 + 10^5 and found just the opposite effect: the other semiprimes were much more productive. There are issues with the sample size, though, since numbers usually have few bases to which they are pseudoprime but some numbers have many. I'll re-run the test to larger bounds now.

CRGreathouse 2010-08-10 16:44

[QUOTE=3.14159;224749]Then, from that, try a larger base of semiprimes, say, 10k or 100k semiprimes, ones of the form p * (2p-1) and general semiprimes with prime factors of similar size, and test how pseudoprime they are, and see if you can come up with some sort of correlation.[/QUOTE]

Interesting, we had the same idea. (I didn't see this before I posted.) The size of the numbers I examined was around a (US) billion, but I only looked at a range of width 100,000, which presumably had only around ~500 SG primes (2 * 1e5 / log(1e9)^2).

3.14159 2010-08-10 16:54

[QUOTE=CRGreathouse]I wrote a script to do the latter comparison first. It goes through a block of sequential primes and picks out the Sophie Germain primes, forming the semiprimes as p * (2p + 1). As a comparison, it takes either the next semiprime or the previous semiprime (alternating between the two so as to remove even the small effect of the size difference).
[/QUOTE]

Ah, but you made an elementary mistake: The pseudoprimes are not Sophie Germain-based: They are 2nd kind Cunningham-based. Although, the results are interesting. Post the data, if you still have it.

[QUOTE=CRGreathouse]I ran this test on the primes from 10^9 to 10^9 + 10^5 and found just the opposite effect: the other semiprimes were much more productive. There are issues with the sample size, though, since numbers usually have few bases to which they are pseudoprime but some numbers have many. I'll re-run the test to larger bounds now.
[/QUOTE]

Try it on 2nd kind Cunningham pseudoprimes. (I'm sure you'll only have to change a snippet of code for it.)

Also: Congrats on having a palindrome number of posts (1331), also a power of 11, also the concatenation of the fourth row on Pascal's triangle, and when the power of 11 and 11 are concatenated, forms an emirp (113 --> 311.)

CRGreathouse 2010-08-10 17:02

Ah, simple enough to flip. I'm going to have to find a new method for comparison, though, since the total or average is clearly inappropriate here.

3.14159 2010-08-10 17:04

[QUOTE=CRGreathouse]Ah, simple enough to flip. I'm going to have to find a new method for comparison, though, since the total or average is clearly inappropriate here.[/QUOTE]

Did you get random outcomes when you tried it?

CRGreathouse 2010-08-10 17:07

[QUOTE=3.14159;224759]Did you get random outcomes when you tried it?[/QUOTE]

It takes time to run and I need to change the way it records its data. I'm not sure that I can do that today -- I have a big project to work on. (It would only take 15 minutes... but I don't have 15 minutes.) Why don't you write it and we can compare numbers tomorrow.

3.14159 2010-08-10 17:12

[QUOTE=CRGreathouse]It takes time to run and I need to change the way it records its data. I'm not sure that I can do that today -- I have a big project to work on. (It would only take 15 minutes... but I don't have 15 minutes.) Why don't you write it and we can compare numbers tomorrow.
[/QUOTE]

Oki. I'll get working on it. Cheers.

CRGreathouse 2010-08-10 17:16

Sorry about cutting out early. Preliminary results looked good, but I don't trust data averaged that way. Still not sure what's best... median, geomean, percentage at or above some threshold...?

3.14159 2010-08-10 17:20

[QUOTE=CRGreathouse]Sorry about cutting out early. Preliminary results looked good, but I don't trust data averaged that way. Still not sure what's best... median, geomean, percentage at or above some threshold...?
[/QUOTE]

Mean, and repeat it over and over, to ensure that it is not random outcomes, or alternatively, to show that it was merely random outcomes.

I was able to get a list of the bases a number is pseudoprime to going...

3.14159 2010-08-10 18:01

Though a decent check reveals that the 2nd-kind Cunninghams by far outperform their general counterparts in how many bases they are pseudoprime to. The general composites usually had no false witnesses when checked, besides 1.

CRGreathouse 2010-08-10 18:02

[QUOTE=3.14159;224764]Mean, and repeat it over and over, to ensure that it is not random outcomes, or alternatively, to show that it was merely random outcomes.[/QUOTE]

You'll need to repeat it a huge number of times to make that work -- at least a billion, by my estimates.

3.14159 2010-08-10 18:04

[QUOTE=CRGreathouse]You'll need to repeat it a huge number of times to make that work -- at least a billion, by my estimates.
[/QUOTE]

Are you sure of that?

CRGreathouse 2010-08-10 18:26

[QUOTE=3.14159;224774]Are you sure of that?[/QUOTE]

No, just an estimate. But I'm pretty sure you can't get reliable data, statistically speaking, by taking the mean for this problem with less than a million numbers. My heuristic for the size and variablility suggested a few hundred million as the right size.

science_man_88 2010-08-10 18:46

[QUOTE=science_man_88;224688][CODE]6np+/-p 24m+7
└────┬────┘
Equations(m's) A002450 or A121290
[INDENT] └────┬────┘[/INDENT][INDENT] Mersenne Primes
[/INDENT][/CODE]

best I can do is a picture translation.

according to what you say:

[CODE]p 6n+1
└────┬────┘
n that work to primes[/CODE][/QUOTE]

you said for the p and 6n+1 case we were sieving p against 6n+1 and it leaves n for primes.

so that's what the:

[CODE]p 6n+1
└────┬────┘
n that work to primes[/CODE]

is

now if we use this logic what:

[CODE]6np+/-p 24m+7
└────┬────┘
Equations(m's) A002450 or A121290
[INDENT] └────┬────┘[/INDENT][INDENT] Mersenne Primes
[/INDENT][/CODE]

means is 6np+/-p sieve 24m+7 leaves Equations(m's)

Equations(m's) sieve A002450 or A121290 leaves Mersenne primes(indexes that give) . have i made sense yet ?

3.14159 2010-08-10 19:05

Anyone have any idea how to save your programs, so I don't have to continuously keep defining them every time I open PARI/GP?

science_man_88 2010-08-10 19:06

[QUOTE=3.14159;224784]Anyone have any idea how to save your programs, so I don't have to continuously keep defining them every time I open PARI/GP?[/QUOTE]

maybe like CRG suggest we should all make scripts to write it to file and then read from the file the next time we open it I haven't done it yet but it should help lol.

3.14159 2010-08-10 19:25

To axn: Here's another wonderful pseudoprime number for you: 9479779630110266401 is pseudoprime to bases: 10, 17, 24, 36, 40, 54, 59, 60, 61, 68, 77, 90, 96, 98, 100, 102, 109, 127, 135, 139, 147, 150, 151, 153, 160, 179, 199, 203, 216, 218, 236, 242, 244, 247, 250, 254, 255, 263, 272, 278, 281, 287, 289, 299, 308, 319, 327, 341, 347, 349, 358, 360, 371, 375, 381, 384, 392, 397, 398, 406, 417, 425, 431, 433, 434, 436, 443, 451, 462, 479, 486, 497, 508, 523, 526, 531, 537, 545, 549, 553, 554, 556, 562, 563, 571, 574, 576, and 583.

Meh, there's no point in that, as I can collect an infinite amount of these.

Here are just a few pseudoprime numbers to catch:

[code]42619430701 * 85238861401 = 3632831746512063272101
42688800001 * 85377600001 = 3644667291008066400001
42902244001 * 85804488001 = 3681205080599778732001
43056990901 * 86113981801 = 3707808930854536592701
43094343601 * 86188687201 = 3714244900759004950801
43217073901 * 86434147801 = 3735430953085773641701
43547912101 * 87095824201 = 3792841296669296556301
43627953601 * 87255907201 = 3806796670778389780801
43857405901 * 87714811801 = 3846944104686281837701
43894758601 * 87789517201 = 3853499665236232195801
44033497201 * 88066994401 = 3877897751456916171601
44102866501 * 88205733001 = 3890125667165953099501
44332318801 * 88664637601 = 3930708980502663836401
44396352001 * 88792704001 = 3942072141948997056001
44524418401 * 89048836801 = 3964847667850090375201
44945970301 * 89891940601 = 4040280492551802090901
45164750401 * 90329500801 = 4079709357524094571201
45223447501 * 90446895001 = 4090320407706182842501
45410211001 * 90820422001 = 4124174526265272633001
45452899801 * 90905799601 = 4131932200594038779401
45490252501 * 90980505001 = 4138726145163983257501
45570294001 * 91140588001 = 4153303390629582882001
45687688201 * 91375376401 = 4174729706257901544601
45783738001 * 91567476001 = 4192301330642639214001
46039870801 * 92079741601 = 4239339406699504892401
46098567901 * 92197135801 = 4250155925000116523701
46215962101 * 92431924201 = 4271830305795920706301
46237306501 * 92474613001 = 4275777024888596419501
46424070001 * 92848140001 = 4310388550869072210001
46482767101 * 92965534201 = 4321295274685133121301
46573480801 * 93146961601 = 4338178227795657722401
46605497401 * 93210994801 = 4344144775942630012201
46722891601 * 93445783201 = 4366057199070869794801
46893646801 * 93787293601 = 4398028220546981420401
47048393701 * 94096787401 = 4427102699641544561101
47213812801 * 94427625601 = 4458288238368529118401
47240493301 * 94480986601 = 4463328414596411259901
47325870901 * 94651741801 = 4479476113028911232701
47379231901 * 94758463801 = 4489583231010092915701
47448601201 * 94897202401 = 4502739511815628683601
47507298301 * 95014596601 = 4513886783672887674901
47742086701 * 95484173401 = 4558613685083860040101
47811456001 * 95622912001 = 4571870649823306368001
47891497501 * 95782995001 = 4587191065728686992501
47939522401 * 95879044801 = 4596395616024022087201
48355738201 * 96711476401 = 4676554833878945694601
48665232001 * 97330464001 = 4736609611373643696001
48745273501 * 97490547001 = 4752203377325840320501
48964053601 * 97928107201 = 4794957090034238080801
49988584801 * 99977169601 = 4997717220763547834401
50143331701 * 100286663401 = 5028707428102879775101
50436817201 * 100873634401 = 5087745058683742131601
50516858701 * 101033717401 = 5103906025983081956101
50527530901 * 101055061801 = 5106062757852492212701
51311937601 * 102623875201 = 5265829880686523332801
51616095301 * 103232190601 = 5328442588192212465901
51642775801 * 103285551601 = 5333952584813059607401
51685464601 * 103370929201 = 5342774501990762713801
51781514401 * 103563028801 = 5362650467270159263201
51824203201 * 103648406401 = 5371496074785253089601
52224410701 * 104448821401 = 5454778146081222212101
52341804901 * 104683609801 = 5479329080536353434701
52576593301 * 105153186601 = 5528596326224939559901
52629954301 * 105259908601 = 5539824179398066842901
52656634801 * 105313269601 = 5545442377079111984401
52795373401 * 105590746801 = 5574702905049241240201
52886087101 * 105772174201 = 5593876417656231081301
52992809101 * 105985618201 = 5616475632777064047301
53136883801 * 106273767601 = 5647056840108815531401
53264950201 * 106529900401 = 5674309839776754930601
53377008301 * 106754016601 = 5698210030276668804901
53873265601 * 107746531201 = 5804657492977906516801
54390867301 * 108781734601 = 5916732891455591181901
54470908801 * 108941817601 = 5934159811159247606401
54807083101 * 109614166201 = 6007632716025032469301
54977838301 * 109955676601 = 6045125408446827294901
55004518801 * 110009037601 = 6050994177004120436401
55965016801 * 111930033601 = 6264166211016459530401
56274510601 * 112549021201 = 6333641086707848251801
56584004401 * 113168008801 = 6403499108048190733201
56674718101 * 113349436201 = 6424047343598959374301
56680054201 * 113360108401 = 6425257088399915442601
56770767901 * 113541535801 = 6445840176081653123701
57106942201 * 114213884401 = 6522405695039602506601
57288369601 * 114576739201 = 6563914583024273428801
57512485801 * 115024971601 = 6615372045962940737401
57581855101 * 115163710201 = 6631340073687537585301
57640552201 * 115281104401 = 6644866516014771336601
57688577101 * 115377154201 = 6655943855818354551301
57747274201 * 115494548401 = 6669495355233213102601
58424958901 * 116849917801 = 6826951645108653296701
58515672601 * 117031345201 = 6848167879836328537801
58675755601 * 117351511201 = 6885688590637889986801
58819830301 * 117639660601 = 6919544873218055670901
59070627001 * 118141254001 = 6978677948523469881001
59177349001 * 118354698001 = 7003917269513134047001
59236046101 * 118472092201 = 7017818315300358558301
59300079301 * 118600158601 = 7032998810150477217901
59369448601 * 118738897201 = 7049462854314192265801
59406801301 * 118813602601 = 7058336081573583783901
59422809601 * 118845619201 = 7062140601693972748801
59566884301 * 119133768601 = 7096427410597873632901
59833689301 * 119667378601 = 7160140750677370047901[/code]

CRGreathouse 2010-08-10 19:44

[QUOTE=3.14159;224784]Anyone have any idea how to save your programs, so I don't have to continuously keep defining them every time I open PARI/GP?[/QUOTE]

Listen to wise science_man_88:

[QUOTE=science_man_88;224785]maybe like CRG suggest we should all make scripts to write it to file and then read from the file the next time we open it I haven't done it yet but it should help lol.[/QUOTE]

In fact, if you edit your .gprc file (in the "C:\Program Files\PARI" folder or similar) to include the line
[code]read "foo.gp"[/code]
then every time you open Pari it will read that file for you.

I *strongly* recommend this.

CRGreathouse 2010-08-10 19:55

[QUOTE=3.14159;224787]To axn: Here's another wonderful pseudoprime number for you: 9479779630110266401 is pseudoprime to bases: 10, 17, 24, 36, 40, 54, 59, 60, 61, 68, 77, 90, 96, 98, 100, 102, 109, 127, 135, 139, 147, 150, 151, 153, 160, 179, 199, 203, 216, 218, 236, 242, 244, 247, 250, 254, 255, 263, 272, 278, 281, 287, 289, 299, 308, 319, 327, 341, 347, 349, 358, 360, 371, 375, 381, 384, 392, 397, 398, 406, 417, 425, 431, 433, 434, 436, 443, 451, 462, 479, 486, 497, 508, 523, 526, 531, 537, 545, 549, 553, 554, 556, 562, 563, 571, 574, 576, and 583.

Meh, there's no point in that, as I can collect an infinite amount of these.[/QUOTE]

Well, any odd composite is a strong pseudoprime to some base, right?

3.14159 2010-08-10 20:00

[QUOTE=CRGreathouse]Well, any odd composite is a strong pseudoprime to some base, right?
[/QUOTE]

Meh. There's rarely any other false witnesses besides 1. Or, can you try a search for a general composite that turns up 20 false witnesses?

axn 2010-08-10 20:14

[QUOTE=CRGreathouse;224790]Well, any odd composite is a strong pseudoprime to some base, right?[/QUOTE]

Sure about that (after accounting for trivial bases)?

CRGreathouse 2010-08-10 20:19

[QUOTE=3.14159;224791]Meh. There's rarely any other false witnesses besides 1.[/QUOTE]

I wasn't counting 1.

[QUOTE=3.14159;224791]Or, can you try a search for a general composite that turns up 20 false witnesses?[/QUOTE]

I generated random 200-bit odd numbers until I found one that had at least 20 bases to which it was a strong pseudoprime. I found
2459914847011133427927355231834335535322382601220307217655951
which has 49 such bases.

Depending on what you allow as "general composites" there may be faster techniques.

CRGreathouse 2010-08-10 20:22

[QUOTE=axn;224792]Sure about that (after accounting for trivial bases)?[/QUOTE]

My proof was showing that 'the other' trivial base always works, so I'm sure in what I said but certainly wouldn't agree that removing both will always leave some bases. (I suspect that it *usually* would leave none, but I can't prove that suspicion at this time and wouldn't bet anything on it one way or the other.)

CRGreathouse 2010-08-10 20:36

[QUOTE=science_man_88;224781]have i made sense yet ?[/QUOTE]

Not to me. Maybe start a new thread and ask if anyone can follow it?

3.14159 2010-08-10 20:41

[QUOTE=CRGreathouse]I generated random 200-bit odd numbers until I found one that had at least 20 bases to which it was a strong pseudoprime. I found
2459914847011133427927355231834335535322382601220307217655951
which has 49 such bases.[/QUOTE]

:orly owl: Please, tell me which 49 bases it is pseudoprime to.

Also: The number factors as 281 * 1013 * 2218207 * 25849700567 * 481506753362074034556725949990356011.

CRGreathouse 2010-08-10 20:46

[QUOTE=3.14159;224798]Please, tell me which 49 bases it is pseudoprime to.[/QUOTE]

No thanks, that would be too much work. But feel free to work them out yourself if you like.

To duplicate my count note that I include those bases strictly between 1 and n. If you include 1 that makes 50 bases.

science_man_88 2010-08-10 20:52

[CODE]scriptwriter(name,input()) = print(name"() ={");addhelp(name,input());[/CODE]

as you can see I'm trying to make a description interpreting script writer to give CRGreathouse a break lol any advice ?

CRGreathouse 2010-08-10 20:59

[QUOTE=science_man_88;224800][CODE]scriptwriter(name,input()) = print(name"() ={");addhelp(name,input());[/CODE]

as you can see I'm trying to make a description interpreting script writer to give CRGreathouse a break lol any advice ?[/QUOTE]

I used to edit text on Windows with Crimson Editor, where I had a nice macro. I would type the name of the function and its arguments, like

[code]foo(a,b)[/code]
and press the shortcut key to transform this to
[code]foo(a,b)={

};
addhelp(foo, "foo(a, b): ");[/code]
by appropriate use of 'duplicate line', 'next word', etc. functions.

:smile:

Now I'm using gedit on Linux and Notepad++ on Windows; I like them better, overall, but I have no such feature. Pity.

science_man_88 2010-08-10 21:03

[QUOTE=CRGreathouse;224801]I used to edit text on Windows with Crimson Editor, where I had a nice macro. I would type the name of the function and its arguments, like

[code]foo(a,b)[/code]
and press the shortcut key to transform this to
[code]foo(a,b)={

};
addhelp(foo, "foo(a, b): ");[/code]
by appropriate use of 'duplicate line', 'next word', etc. functions.

:smile:

Now I'm using gedit on Linux and Notepad++ on Windows; I like them better, overall, but I have no such feature. Pity.[/QUOTE]

I wanted to make something read the inputs and create the code even more.

CRGreathouse 2010-08-10 21:06

[QUOTE=science_man_88;224803]I wanted to make something read the inputs and create the code even more.[/QUOTE]

Sounds [url=http://en.wikipedia.org/wiki/AI-complete]AI-Complete[/url].

science_man_88 2010-08-10 21:09

[QUOTE=CRGreathouse;224804]Sounds [url=http://en.wikipedia.org/wiki/AI-complete]AI-Complete[/url].[/QUOTE]

search the input for descriptive words or sentences like "all primes until n" if n is greater than primelimit warn the user or use for(1,n,if(isprime()) things like that.

CRGreathouse 2010-08-10 21:15

I agree, that would be very cool. But it's a hard task.

I was doing a problem that is somewhat similar: take natural language and see if it has a certain mathematical meaning. My source data was the OEIS; the goal was to determine which sequences represented quadratic equations ([url=http://math.crg4.com/oeis-quadratics.html]results here[/url]). But even at that very restricted task I found many problems: different ways to write polynomials and generating functions, differences in base variables, mentions of equations other than those defining the sequence, etc.

For a more general-purpose task like this one, I can only imagine how much harder it would be.

science_man_88 2010-08-10 21:20

[QUOTE=CRGreathouse;224807]I agree, that would be very cool. But it's a hard task.

I was doing a problem that is somewhat similar: take natural language and see if it has a certain mathematical meaning. My source data was the OEIS; the goal was to determine which sequences represented quadratic equations ([url=http://math.crg4.com/oeis-quadratics.html]results here[/url]). But even at that very restricted task I found many problems: different ways to write polynomials and generating functions, differences in base variables, mentions of equations other than those defining the sequence, etc.

For a more general-purpose task like this one, I can only imagine how much harder it would be.[/QUOTE]

apparently embedded braces in parser is not supported by PARI go figure

[CODE]scriptwriter(name,input()) = { print(name"() = {");addhelp(name,name"()"input());if(input()=="all primes until";if(n>primelimit,print(n"is greater than primelimit"));addhelp(name,name"():"input());[/CODE]

3.14159 2010-08-10 21:40

[QUOTE=CRGreathouse]No thanks, that would be too much work. But feel free to work them out yourself if you like.
[/QUOTE]

What the - It's not up to me to validate what you post! You do that!

Prime-numbered post. Woo.

science_man_88 2010-08-10 21:50

[CODE]script(name) = print(name"()=");if(input()==,print("is n greater than primelimit?"))[/CODE]

can't figure out how to check strings the way I want can I fill in a vector with them ? if so can't I check strings like that ?

CRGreathouse 2010-08-10 21:52

[QUOTE=3.14159;224810]What the - It's not up to me to validate what you post! You do that![/QUOTE]

You asked me to find a general composite that was a pseudoprime to at least 20 bases, and I did that. You didn't ask for a list of the bases! If you want those you can generate them yourself. I imagine you can work mod each of the primes and CRT the results together.

CRGreathouse 2010-08-10 21:54

[QUOTE=science_man_88;224812][CODE]script(name) = print(name"()=");if(input()==,print("is n greater than primelimit?"))[/CODE]

can't figure out how to check strings the way I want can I fill in a vector with them ? if so can't I check strings like that ?[/QUOTE]

You can certainly have strings in vectors:
[code]["one", "two", "three"][/code]
and even convert strings into vectors of characters
[code]Vec("hi there")[/code]

Is that what you wanted?

3.14159 2010-08-10 21:57

[QUOTE=CRGreathouse]You asked me to find a general composite that was a pseudoprime to at least 20 bases, and I did that. You didn't ask for a list of the bases! If you want those you can generate them yourself. I imagine you can work mod each of the primes and CRT the results together.[/QUOTE]

I didn't ask for a list of bases? What is it that I ask for here, then:

[QUOTE=3.14159]Please, tell me which 49 bases it is pseudoprime to.[/QUOTE]

[B]I couldn't make it any more explicit than that.[/B]

science_man_88 2010-08-10 21:58

might work CRG also i got this working as wanted:

[CODE]script(name) = print(name"()=");if(input()==all primes upto,print("is n greater than primelimit?"))[/CODE]

if I implement yours the hard part is telling how long the number(or it's representation) would be after this.

nvm if I can check for spaces I just add a extra character onto my string I check for and then check for the next space and read the number encoded check if it's above the prime limit if so I warn them ask them if it should be changed if not I go with [CODE]for(x=1,#,if(isprime(x)))[/CODE] deal.

CRGreathouse 2010-08-10 22:23

[QUOTE=3.14159;224817]I didn't ask for a list of bases?[/QUOTE]

You didn't ask in #147, the post I responded to when I posted that number.

I'm sorry if it bothers you that I'm not willing to put in the time to calculate what you want. Perhaps you can code a solution, or even hire someone to code it for you.

CRGreathouse 2010-08-10 22:25

[QUOTE=science_man_88;224818]might work CRG also i got this working as wanted:

[CODE]script(name) = print(name"()=");if(input()==all primes upto,print("is n greater than primelimit?"))[/CODE][/QUOTE]

OK. You should probably put "all primes upto" in quotes or something. Right now it works as you appear to intend it, but only insofar as it interprets the expression as the polynomial allprimesupto * 1 + 0, which is printed allprimesupto.

[QUOTE=science_man_88;224818]if I implement yours the hard part is telling how long the number(or it's representation) would be after this.[/QUOTE]

I don't fully understand but this seems like an easy part.

science_man_88 2010-08-10 22:27

[QUOTE=CRGreathouse;224823]OK. You should probably put "all primes upto" in quotes or something. Right now it works as you appear to intend it, but only insofar as it interprets the expression as the polynomial allprimesupto * 1 + 0, which is printed allprimesupto.



I don't fully understand but this seems like an easy part.[/QUOTE]

sorry edited too much.

science_man_88 2010-08-10 22:35

[CODE](19:32) gp > script(name) = print(name"()=");Vec(input());
(19:32) gp > script(foo)
foo()=
for me
%8 = [1, 0]
(19:33) gp > script(foo)
foo()=
fool you are a fool
*** input: Warning: unused characters: foolyouareafool.[/CODE]

3.14159 2010-08-10 22:40

[QUOTE=CRGreathouse]I'm sorry if it bothers you that I'm not willing to put in the time to calculate what you want. Perhaps you can code a solution, or even hire someone to code it for you.
[/QUOTE]

What I am merely asking for is some form of validation for the claim. Nothing more.

(Just post data, and I'll take your word for it afterwards.)

CRGreathouse 2010-08-10 22:41

You really want to take the second argument as a string argument rather than as input(); that would take care of your immediate issue. That issue, of course, is that it reads foolyouareafool and foo as polynomials not as strings.

science_man_88 2010-08-10 22:44

[QUOTE=CRGreathouse;224828]You really want to take the second argument as a string argument rather than as input(); that would take care of your immediate issue. That issue, of course, is that it reads foolyouareafool and foo as polynomials not as strings.[/QUOTE]

I want what makes this work so that you don't have to as hard.

how do I have them read as strings ?

CRGreathouse 2010-08-10 22:50

[QUOTE=science_man_88;224829]I want what makes this work so that you don't have to as hard.[/QUOTE]

If you made the program as I imagine it, you'd be up for a Knuth Prize at the least. :smile:


[QUOTE=science_man_88;224829]how do I check for a specific string in input() ? that's what I'm up against right now.[/QUOTE]

I would suggest something like
[code]script(name, text)={
print(name"()={");
if(text == "prime", print("isprime(47)"));
print("};");
print("addhelp("name", \""name": "text"\");")
};[/code]

which does
[code]> script("foobar", "prime")
foobar()={
isprime(47)
};
addhelp(foobar, "foobar: prime");

> script("foobar", "Lists the foobars up to N.")
foobar()={
};
addhelp(foobar, "foobar: Lists the foobars up to N.");[/code]

Of course you would replace "prime" with whatever it is you're looking for.

CRGreathouse 2010-08-10 22:52

[QUOTE=3.14159;224827]What I am merely asking for is some form of validation for the claim. Nothing more.

(Just post data, and I'll take your word for it afterwards.)[/QUOTE]

I linked to a program I wrote that gives the count of the bases to which a number is a strong pseudoprime, I used that program.

(I also wrote a modified version of it that I used for a modified version of the problem in which I generate random semiprimes rather than random odd numbers, but that's not what I used here because I wasn't sure if that would be what you consider a "general composite".)

science_man_88 2010-08-10 22:53

see I wanted it so people could write random functions without having to worry about what they input so I was thinking along Vec(input()) thanks to you then searching the vector for the specific phrase needed however this seems overly complicating.


so something like [CODE]Vec(input());forstep(i=1,length(input()),length(string to search for),if(v[i]=="a" && v[i+1]=="l"[/CODE] .etc then checking for the next space after that to find the end of the format of the number then pretty much you know the rest lol.

3.14159 2010-08-10 23:10

[QUOTE=CRGreathouse](I also wrote a modified version of it that I used for a modified version of the problem in which I generate random semiprimes rather than random odd numbers, but that's not what I used here because I wasn't sure if that would be what you consider a "general composite".)
[/QUOTE]

What I consider a general composite is any composite number, such as 35615990503459801, or 7948413665865367, or even 1208925819614629174706176.

[QUOTE=CRGreathouse]I linked to a program I wrote that gives the count of the bases to which a number is a strong pseudoprime, I used that program.
[/QUOTE]

So you waited until it generated 49 numbers?

CRGreathouse 2010-08-10 23:39

[QUOTE=3.14159;224834]What I consider a general composite is any composite number, such as 35615990503459801, or 7948413665865367, or even 1208925819614629174706176.[/QUOTE]

I don't think that's what you mean! I think you would cry foul if I chose 2^101 - 1.

[QUOTE=3.14159;224834]So you waited until it generated 49 numbers?[/QUOTE]

I had a script generate random odds and test them until one had >= 20 bases to which it was a pseudoprime. The first I generated at that size happened to have 49 (or 50, or 48, depending on how you count it) bases.

CRGreathouse 2010-08-10 23:40

[QUOTE=science_man_88;224832]see I wanted it so people could write random functions without having to worry about what they input so I was thinking along Vec(input()) thanks to you then searching the vector for the specific phrase needed however this seems overly complicating.


so something like [CODE]Vec(input());forstep(i=1,length(input()),length(string to search for),if(v[i]=="a" && v[i+1]=="l"[/CODE] .etc then checking for the next space after that to find the end of the format of the number then pretty much you know the rest lol.[/QUOTE]

Yes, I understand. If you're using input() then the user needs to surround the text with quote marks for that to work right. Well, I suppose you could convert it to a string -- this works on the assumption that the string has no special characters or spaces and that the resultant polynomial is undefined.

science_man_88 2010-08-10 23:53

[QUOTE=science_man_88;224832]see I wanted it so people could write random functions without having to worry about what they input so I was thinking along Vec(input()) thanks to you then searching the vector for the specific phrase needed however this seems overly complicating.


so something like [CODE]Vec(input());forstep(i=1,length(input()),length(string to search for),if(v[i]=="a" && v[i+1]=="l"[/CODE] .etc then checking for the next space after that to find the end of the format of the number then pretty much you know the rest lol.[/QUOTE]


think i know a way to simplify this lol Vec(string1,string2,etc.) at least to the most common things you get annoyed with people asking then vector each string separately and walk through it does Vec(input())[i] with the individually vectored strings from the vector above. This might take a lot of variables though. that might shorten the code some(might increase time though) the hard part is putting the placement of these into variables etc. and then making sense of it all to write the code needed.

science_man_88 2010-08-10 23:57

I could also see doing something like [CODE]for(n=2,100,if(Vec(input())==stringN + n,print(function to do it))[/CODE]

3.14159 2010-08-11 00:09

[QUOTE=CRGreathouse]I don't think that's what you mean! I think you would cry foul if I chose 2^101 - 1.
[/QUOTE]

Why? Because all of its bases are powers of two? And it would generate the first 100 powers of two?

CRGreathouse 2010-08-11 00:11

[QUOTE=science_man_88;224840]I could also see doing something like [CODE]for(n=2,100,if(Vec(input())==stringN + n,print(function to do it))[/CODE][/QUOTE]

That would wait for user input 99 times. Surely that's not what you want?

Ideally, the program wouldn't directly ask for user input at all. That way I could write a program that checks mersenneforum.org for updates, read those updates into a string, and send the string to the program, which would either output a program or give some sort of an error.

So if it read a post that said
[quote]What are the primes from 1 to 100?[/quote]
it might generate something like
[code]userscript_mersenneforum_post83529()={
forprime(p=1,100,print(p))
};
addhelp(userscript_mersenneforum_post83529, "userscript_mersenneforum_post83529(): Lists the primes p with 1 <= p <= 100. Assumes that 100 <= default(primelimit).")[/code]
and if it reads something like
[quote]What's the best CPU for double-checking?[/quote]
it just gives
[code]*** user error: cannot determine program from description[/code]

CRGreathouse 2010-08-11 00:15

[QUOTE=3.14159;224841]Why?[/QUOTE]

I'm trying to figure out what you mean by "general composite". In post #187 you define it to mean the same as "composite", but in that case why did you say "general composite" in post #157 rather than just "composite"?

I had the feeling that you had some special meaning like "generated uniformly at random" or "algorithmically irreducible". At the least, I supposed that you would exclude SNFS-type numbers.

In the end, I suppose only you can tell me what you meant in #157.


All times are UTC. The time now is 23:20.

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