mersenneforum.org  

Go Back   mersenneforum.org > Math Stuff > Computer Science & Computational Number Theory > PARI/GP

Reply
 
Thread Tools
Old 2011-10-28, 13:33   #2322
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

28·3·5 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
GP doesn't have much in the way of I/O. I suggest
Code:
extern("rm oldStatus; mv pariStatus oldStatus");
write("pariStatus", ...);
extern("rm oldStatus");
Thanks. That would keep me from possibly losing the value. Is the first "rm oldStatus" just to "be sure" before the mv?
EdH is offline   Reply With Quote
Old 2011-10-28, 14:16   #2323
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

28×3×5 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
yeah probably but you should still find it with mine:

Code:
(10:29)>for(x=1000010274063430,1000010274063430,b=x;for(y=1,10000000,if((sigma(b)-b) != 0,b=sigma(b)-b);if(b==x,print(x","y);break())))
1000010274063430,2
In computer terms, yours seems to be taking an eternity to search from 1000010274060000 to 1000010274080000:
Code:
? for(x=1000010274060000,1000010274080000,b=x;for(y=1,10000000,if((sigma(b)-b) != 0,b=sigma(b)-b);if(b==x,print(x","y);break())))
^C  *** sigma: user interrupt after 7mn, 32,978 ms.
whereas, mine (without the extra prints) is done in a few seconds:
Code:
? for(b=100001027406,100001027408,c=b*10000;for(d=c,c+10000,i=d;f=d*20;for(e=1,5,i=sigma(i)-i;if(i<d,break());if(i>f,break());if(i==d,print(d);break()))))
1000010274063430
time = 8,999 ms.
EdH is offline   Reply With Quote
Old 2011-11-08, 15:47   #2324
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Code:
lucas2(t,z,p,q,x)= v=[t,z];for(y=3,x,v=concat(v,p*v[y-1]-q*v[y-2]));v=vector(x,i,v[i])
though I tried using it like:
Code:
for(z=-1000,1000,for(a=-1000,1000,if(lucas2(2,3,z,a,13)==[2,3,5,7,13,17,19,31,61,89,107,127,521],print(z","a))))
and got told "bug in" I'm guessing something like the segmentation fault: please report errors.

Last fiddled with by science_man_88 on 2011-11-08 at 15:48
science_man_88 is offline   Reply With Quote
Old 2011-11-27, 00:35   #2325
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default error testing

how can it be done in PARI because if possible it may allow me to test something , I'm currently working on related to Mersenne prime exponents. because laurv talked of code like:
Code:
 sqrt(Mod(2,2^61-1))
well so far in testing manually I see a pattern ( gulp) to the result and I might be able to tell just by the first calculation and this kinda had to do with trying the lucas-lehmer test backwards. I think that if p is a mersenne prime exponent the result isn't and error on the second level down by adding 2 ( I am positive it's likely known though).

Last fiddled with by science_man_88 on 2011-11-27 at 00:38
science_man_88 is offline   Reply With Quote
Old 2011-11-27, 00:51   #2326
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
how can it be done in PARI because if possible it may allow me to test something , I'm currently working on related to Mersenne prime exponents. because laurv talked of code like:
Code:
 sqrt(Mod(2,2^61-1))
well so far in testing manually I see a pattern ( gulp) to the result and I might be able to tell just by the first calculation and this kinda had to do with trying the lucas-lehmer test backwards. I think that if p is a mersenne prime exponent the result isn't and error on the second level down by adding 2 ( I am positive it's likely known though).
doh I found it I think lol

trap() still not sure how to use it.

Last fiddled with by science_man_88 on 2011-11-27 at 00:53
science_man_88 is offline   Reply With Quote
Old 2011-11-27, 21:26   #2327
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

The general format is
trap(, code, what to do if the code fails)
as in
Code:
trap(,1/0,"don't divide by 0")
Technically you can put the error type before the first comma to catch only certain types of errors, but usually you don't want to do this.
CRGreathouse is offline   Reply With Quote
Old 2011-11-27, 21:35   #2328
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

100000110000002 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
The general format is
trap(, code, what to do if the code fails)
as in
Code:
trap(,1/0,"don't divide by 0")
Technically you can put the error type before the first comma to catch only certain types of errors, but usually you don't want to do this.
thanks I already proved myself wrong without it but I still want to see if it even semi fits:


Code:
(17:34)>b=2;forprime(p=2281,2281,for(y=1,p-1,b=sqrt(Mod(b,1<<p-1));trap(,break(),);if(y==p-1,print(p)));b=2)
  *** sqrt: user interrupt after 13,750 ms.
  *** break: bug in PARI/GP (Segmentation Fault), please report
  ***   Break loop (type 'break' or Control-d to go back to GP)
science_man_88 is offline   Reply With Quote
Old 2011-11-27, 21:37   #2329
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
thanks I already proved myself wrong without it but I still want to see if it even semi fits:


Code:
(17:34)>b=2;forprime(p=2281,2281,for(y=1,p-1,b=sqrt(Mod(b,1<<p-1));trap(,break(),);if(y==p-1,print(p)));b=2)
  *** sqrt: user interrupt after 13,750 ms.
  *** break: bug in PARI/GP (Segmentation Fault), please report
  ***   Break loop (type 'break' or Control-d to go back to GP)
Code:
(17:37)>b=2;forprime(p=29,29,for(y=1,p-1,b=sqrt(Mod(b,1<<p-1));if(y==p-1,print(p)));b=2)
  *** sqrt: non quadratic residue in gsqrt
  *** break: bug in PARI/GP (Segmentation Fault), please report
  ***   Break loop (type 'break' or Control-d to go back to GP)
science_man_88 is offline   Reply With Quote
Old 2011-11-27, 21:40   #2330
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

20C016 Posts
Default

hopefully I don't have to reinstall ( though likely) I've had segmentation faults too much ( stupidly ignored a little) and even my timer seems wacky at times.
science_man_88 is offline   Reply With Quote
Old 2011-11-27, 22:28   #2331
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

You're using trap wrong. You're writing

code; trap(, stuff, )

when I told you to write

trap(, code, stuff)

What you did will still cause the error.

Quote:
Originally Posted by science_man_88 View Post
hopefully I don't have to reinstall
No, you don't need to do that.
CRGreathouse is offline   Reply With Quote
Old 2011-11-28, 03:10   #2332
LaurV
Romulan Interpreter
 
LaurV's Avatar
 
Jun 2011
Thailand

3·3,221 Posts
Default

I don't know what are you trying to do (semantically), but (syntactically) you should write this:

Code:
(10:06:27) gp > b=2;forprime(p=2,2281,for(y=1,p-1,trap(,print("break here, p="p", y="y);break,b=sqrt(Mod(b,1<<p-1)));if(y==p-1,print(p)));b=2)
break here, p=2, y=1
break here, p=3, y=2
break here, p=5, y=3
7
break here, p=11, y=6
break here, p=13, y=7
break here, p=17, y=5
break here, p=19, y=10
23
break here, p=29, y=15
31
break here, p=37, y=19
break here, p=41, y=11
break here, p=43, y=8
47
break here, p=53, y=27

Last fiddled with by LaurV on 2011-11-28 at 03:10
LaurV is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why do I sometimes see all the <> formatting commands when I quote or edit? cheesehead Forum Feedback 3 2013-05-25 12:56
Passing commands to PARI on Windows James Heinrich Software 2 2012-05-13 19:19
Ubiquity commands Mini-Geek Aliquot Sequences 1 2009-09-22 19:33
64-bit Pari? CRGreathouse Software 2 2009-03-13 04:22
Are these commands correct? jasong Linux 2 2007-10-18 23:40

All times are UTC. The time now is 15:31.


Fri Aug 6 15:31:41 UTC 2021 up 14 days, 10 hrs, 1 user, load averages: 2.36, 2.72, 2.83

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.