![]() |
|
|
#1 |
|
Mar 2016
3·5·23 Posts |
A peaceful evening for all,
if i have to quadratic function f(n) and g(n) with f(n) =an^2+bn+c and g(n)=en^2+fn+g and i want to find a t>1 with t=gcd (f(n), g(n)) for n=1 to n_max Is there a better way than for n=1 to n=n_max if ((gcd (f(n), g(n))>1) print (n) end_for; If someone knows a better way, it would be nice to leave a short message. Greetings from the primes ![]() Bernhard |
|
|
|
|
|
#2 | |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
Quote:
|
|
|
|
|
|
|
#3 |
|
Aug 2006
3·1,993 Posts |
I think the gcd of f(n) and g(n) must divide the resultant of f and g. Does that help?
|
|
|
|
|
|
#4 | ||
|
Mar 2016
3×5×23 Posts |
Quote:
![]() i think i will follow the subject of prime distribution concerning quadratic irreducible polynomials Quote:
![]() ![]() ![]() Greetings from Germany Bernhard |
||
|
|
|
|
|
#5 | |
|
Aug 2006
10111010110112 Posts |
Quote:
But I'm not sure how much time you want to spend optimizing this process since probably you'll just have to try a few values to get a common factor, and that should be pretty fast with quadratics unless the coefficients are gigantic. |
|
|
|
|
|
|
#6 | |
|
Mar 2016
3×5×23 Posts |
Quote:
m=137 is the exponent for the mersenne number = 32032215596496435569.5439042183600204290159 Greetings from the primes Bernhard |
|
|
|
|
|
|
#7 | |
|
"Forget I exist"
Jul 2009
Dumbassville
100000110000002 Posts |
Quote:
Last fiddled with by science_man_88 on 2017-11-28 at 22:47 |
|
|
|
|
|
|
#8 |
|
Aug 2006
3·1,993 Posts |
Ah, you're looking for *all* values giving a nontrivial gcd up to some limit? Yes, there are big speedups available. Here's the basic idea; there are lots of optimizations available but I have no time to show them.
Code:
commonFactorSmall(f, g, start, end)=
{
my(v=List(),x=variable(f),y=variable(g));
for(n=ceil(start),end, if(gcd(subst(f,x,n),subst(g,y,n))>1, listput(v,n)));
Vec(v);
}
commonFactor(f, g, start, end)=
{
my(r=polresultant(f,g),u,v,d);
if(end-start < r, return(commonFactorSmall(f, g, start, end)));
u=commonFactorSmall(f, g, start, start+r-1);
v=List(u);
u=concat(u, u[1]+r);
d=vector(#v,i,u[i+1]-u[i]);
forstep(n=u[#u],end,d, listput(v,n));
Vec(v);
}
\\ Example
P=32*x^2-17*x+4;Q=17*x^2+8*x+6;
v=commonFactor(P,Q,1,10^7);#v
|
|
|
|
|
|
#9 | |
|
Aug 2006
135338 Posts |
Quote:
|
|
|
|
|
|
|
#10 |
|
"Forget I exist"
Jul 2009
Dumbassville
100000110000002 Posts |
a small example 3n^2+5n+4 is always even ; 5n^2+6n+13 is odd if x is even, and even if x is odd. so for t=2 we have that n is odd. With the subtraction we get 2n^2+n+9 which is odd when n is even and even if n is odd.edit: of course we then can continue this and get n^2+4n-5 and then we can get n^2-3n+14 then ( for certain n values at least) 7n-19. etc.
Last fiddled with by science_man_88 on 2017-11-28 at 23:27 |
|
|
|
|
|
#11 | |
|
Aug 2006
3×1,993 Posts |
Quote:
But try to code whatever you do!
|
|
|
|
|