mersenneforum.org  

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

Reply
 
Thread Tools
Old 2010-11-25, 21:03   #1695
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
I did a comparison, and it seems that trial division by far outspeeds the Fermat script.
That's actually usual for Fermat's method, so this doesn't indicate that your version is bad.
CRGreathouse is offline   Reply With Quote
Old 2010-11-26, 02:13   #1696
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24×3×5×7 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
That's actually usual for Fermat's method, so this doesn't indicate that your version is bad.
It might be a more difficult task to code a factoring method which is faster than trial division.
3.14159 is offline   Reply With Quote
Old 2010-11-26, 03:25   #1697
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

69016 Posts
Default

I did some reading on some of the highly composite numbers; Is there any way in which one could compute a specific one, without checking every integer smaller than it?

Ex: I wanted to compute the 100th term in the sequence. Any way to do that without checking every integer before it?

Last fiddled with by 3.14159 on 2010-11-26 at 03:30
3.14159 is offline   Reply With Quote
Old 2010-11-26, 06:17   #1698
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
It might be a more difficult task to code a factoring method which is faster than trial division.
I recommend Pollard's rho, it's pretty easy.
CRGreathouse is offline   Reply With Quote
Old 2010-11-26, 06:19   #1699
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

135338 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
I did some reading on some of the highly composite numbers; Is there any way in which one could compute a specific one, without checking every integer smaller than it?

Ex: I wanted to compute the 100th term in the sequence. Any way to do that without checking every integer before it?
The fastest way would be to compute the first 100 members of the sequence, which does not require checking all numbers up to that point (or even checking the products of primorials up to that point). There's extensive discussion at a link from the Sloane sequence; it's from the person who calculated lots of terms there.
CRGreathouse is offline   Reply With Quote
Old 2010-11-26, 10:48   #1700
Batalov
 
Batalov's Avatar
 
"Serge"
Mar 2008
Phi(4,2^7658614+1)/2

9,497 Posts
Default

I am stumped. Must be something really trivial:
Code:
gp > polcyclo(15,10)
  ***   variable name expected: polcyclo(15,10)
                                            ^---
gp > p=polcyclo(15)
%1 = x^8 - x^7 + x^5 - x^4 + x^3 - x + 1
gp > p(10)
  ***   unused characters: p(10)
                            ^----
How do I eval? I understand that I create a POL object. But how do I marry it to the argument? subst(polcyclo(15),x,10) ? Looks ugly.
Batalov is offline   Reply With Quote
Old 2010-11-26, 13:49   #1701
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24·3·5·7 Posts
Default

Quote:
Originally Posted by Batalov View Post
I am stumped. Must be something really trivial:
Code:
gp > polcyclo(15,10)
  ***   variable name expected: polcyclo(15,10)
                                            ^---
gp > p=polcyclo(15)
%1 = x^8 - x^7 + x^5 - x^4 + x^3 - x + 1
gp > p(10)
  ***   unused characters: p(10)
                            ^----
How do I eval? I understand that I create a POL object. But how do I marry it to the argument? subst(polcyclo(15),x,10) ? Looks ugly.
Doesn't work?

I get a return of 90090991.
3.14159 is offline   Reply With Quote
Old 2010-11-26, 13:50   #1702
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

110100100002 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
I recommend Pollard's rho, it's pretty easy.
Well, I'll have to learn how Pollard's Rho works first.
3.14159 is offline   Reply With Quote
Old 2010-11-26, 14:13   #1703
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

Quote:
Originally Posted by Batalov View Post
How do I eval?
eval() lol
science_man_88 is offline   Reply With Quote
Old 2010-11-26, 17:30   #1704
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

135338 Posts
Default

Quote:
Originally Posted by Batalov View Post
I am stumped. Must be something really trivial:
Code:
gp > polcyclo(15,10)
  ***   variable name expected: polcyclo(15,10)
                                            ^---
gp > p=polcyclo(15)
%1 = x^8 - x^7 + x^5 - x^4 + x^3 - x + 1
gp > p(10)
  ***   unused characters: p(10)
                            ^----
How do I eval? I understand that I create a POL object. But how do I marry it to the argument? subst(polcyclo(15),x,10) ? Looks ugly.
substpol (or subst) are usual. If all you want is to evaluate the polynomial (not to take derivatives or extract coefficients, etc.) then it's best to create it as a closure instead:
Code:
p=n->polcyclo(15,n);
p(15)
CRGreathouse is offline   Reply With Quote
Old 2010-11-27, 00:32   #1705
Batalov
 
Batalov's Avatar
 
"Serge"
Mar 2008
Phi(4,2^7658614+1)/2

9,497 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
substpol (or subst) are usual. If all you want is to evaluate the polynomial (not to take derivatives or extract coefficients, etc.) then it's best to create it as a closure instead:
Code:
p=n->polcyclo(15,n);
p(15)
Thanks! That's what I was looking for.
(and yes, subst() works, too, but I was looking for a hint to best practices)
Batalov 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 23:06.


Fri Aug 6 23:06:56 UTC 2021 up 14 days, 17:35, 1 user, load averages: 4.21, 3.93, 3.92

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.