![]() |
[QUOTE=3.14159;238632]I did a comparison, and it seems that trial division by far outspeeds the Fermat script. [/QUOTE]
That's actually usual for Fermat's method, so this doesn't indicate that your version is bad. |
[QUOTE=CRGreathouse;238648]That's actually usual for Fermat's method, so this doesn't indicate that your version is bad.[/QUOTE]
It might be a more difficult task to code a factoring method which is faster than trial division. |
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? |
[QUOTE=3.14159;238679]It might be a more difficult task to code a factoring method which is faster than trial division.[/QUOTE]
I recommend Pollard's rho, it's pretty easy. |
[QUOTE=3.14159;238685]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?[/QUOTE] 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. |
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) ^---- [/CODE] How do I eval? I understand that I create a POL object. But how do I marry it to the argument? [FONT=Courier New]subst(polcyclo(15),x,10)[/FONT] ? Looks ugly. |
[QUOTE=Batalov;238709]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) ^---- [/CODE] How do I eval? I understand that I create a POL object. But how do I marry it to the argument? [FONT=Courier New]subst(polcyclo(15),x,10)[/FONT] ? Looks ugly.[/QUOTE] Doesn't work? I get a return of 90090991. |
[QUOTE=CRGreathouse;238691]I recommend Pollard's rho, it's pretty easy.[/QUOTE]
Well, I'll have to learn how Pollard's Rho works first. |
[QUOTE=Batalov;238709]
How do I eval?[/QUOTE] eval() lol |
[QUOTE=Batalov;238709]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) ^---- [/CODE] How do I eval? I understand that I create a POL object. But how do I marry it to the argument? [FONT=Courier New]subst(polcyclo(15),x,10)[/FONT] ? Looks ugly.[/QUOTE] 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)[/code] |
[QUOTE=CRGreathouse;238752]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)[/code][/QUOTE] Thanks! That's what I was looking for. [SIZE=1](and yes, subst() works, too, but I was looking for a hint to best practices)[/SIZE] |
| All times are UTC. The time now is 23:12. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.