20200425, 11:29  #34 
Apr 2020
10100_{2} Posts 
Next step would be to make a function of it, so you can call it with starting and stopping values you need. Then, you can move to better "algorithms"
but I donâ€™t understand it at all Last fiddled with by User133 on 20200425 at 11:35 
20200425, 12:01  #35 
Apr 2020
2^{2}×5 Posts 
thank you very much

20200425, 12:48  #36  
Nov 2003
2^{5}·233 Posts 
Quote:
learn some number theory. Quote:
Quote:
divisors function. It does require using the computer in your head along with some math. It also requires knowing how one computes the sum of divisors from the prime factorization *without* knowing/computing the nonprime divisors. Your "brute force/try all possibilities" is simple minded and horribly inefficient. Last fiddled with by R.D. Silverman on 20200425 at 12:50 Reason: cleanup 

20200425, 13:25  #37  
Nov 2003
16440_{8} Posts 
Quote:
Follow on. Give an estimate for the largest prime factor of the answer without doing any computations at all. You may express your answer as a function of the input parameters. Justify your answer. Hint: psi(x) ~ x. Explain why this question is relevant to the original question. Last fiddled with by R.D. Silverman on 20200425 at 13:40 Reason: add hint. 

20200425, 15:35  #38  
Romulan Interpreter
Jun 2011
Thailand
3×2,861 Posts 
Quote:
We however agree about the last sentence. This way of computing is "horribly inefficient", regardless of the fact that you use the divisors, like I did, or the prime factors, like you suggested . Because the factorization is the hard part, not combining them in products, or sums...  p.s. is matjax broken again? it seems tag works, but matjax not, or at least, not in previews... Last fiddled with by LaurV on 20200425 at 15:45 

20200425, 17:51  #39  
Nov 2003
1110100100000_{2} Posts 
Quote:
how to write code or in learning Pari syntax. That could be done by RTFM. It has to be an exercise in how to derive and code the best method. Code syntax is too trivial. If it is a weird exercise in Pari syntax then the correct answer is indeed RTFM. Quote:
Quote:
to do it. It is in the "Computer Science and CNT" group and not the "programming" group. It is also learning that this problem requires finding a solution that has many (necessarily small) prime factors. Also, the OP said he needed help with a task using GP and not help learning Pari/GP. Note that there is a subgroup devoted to Pari itself if the point of the exercise were to learn it. Last fiddled with by R.D. Silverman on 20200425 at 17:56 

20200425, 18:02  #40  
Romulan Interpreter
Jun 2011
Thailand
3×2,861 Posts 
Quote:
Quote:
Last fiddled with by LaurV on 20200425 at 18:02 

20200614, 16:25  #41 
Dec 2008
you know...around...
3^{2}·61 Posts 
There is a program for the computation of HardyLittlewood constants for quadratic polynomials in A221712, but it doesn't seem to work:
Code:
/* Auxiliary functions. */ ZetaDN(P, s) = zeta(s) * prod(j = 1, #P, 1  P[j]^(s)); LchiN(L, Ebad, s) = { my([P, E] = Ebad); lfun(L, s) * prod(j = 1, #P, subst(E[j], 'x, P[j]^(s))); } LchiNinit(D, P) = { my(Ebad = [], Pbad = []); for (j = 1, #P, my(p = P[j], s = kronecker(D, p)); if (s, Ebad = concat(Ebad, 1  s*'x); Pbad = concat(Pbad, p))); return ([Pbad, Ebad]); } Oddpart(n) = n >> valuation(n,2); /* The real work; D is fundamental. */ HLW2(D, N) = { my(B = getlocalbitprec(), lim, S1, S2, L, P, v, Ebad); localbitprec(32); lim = ceil(B*log(2)/log(N/2)); localbitprec(B + lim + exponent(lim)); L = lfuninit(D, [1/2, lim, 0]); v = vector(lim); forfactored(X = 1, lim, my([n] = X, S = 0); \\ FIXME: loop over odd divisors? fordivfactored(X, Y, my([d] = Y); if (d % 2, S += moebius(Y) << (n/d))); v[n] = S / (2*n); ); P = setunion(factor(abs(D))[,1]~, primes([2, N])); Ebad = LchiNinit(D, P); S1 = sum(n = 1, lim, v[n] * log(LchiN(L, Ebad, n))); S2 = sum(n = 2, lim, (v[n]  if (n%2 == 0, v[n/2])) * log(ZetaDN(P, n))); return (S1 + S2); } /* Compute the HardyLittlewood constant of aX^2+bX+c. */ HardyLittlewood2(A, N = 50) = { my(D = poldisc(A), S, P); if (poldegree(A) != 2, error("polynomial of degree != 2")); my([a, b, c] = Vec(A)); if (issquare(D)  gcd([2 * a, a + b, c]) > 1, return (0)); N = max(N, 3); /* Take care of the prime p = 2. */ S = if ((a + b) % 2, 1., 2.); /* Take care of odd primes dividing a. */ P = factor(Oddpart(a))[,1]; for (j = 1, #P, my(p = P[j]); S *= if (b % p, (p  1) / (p  2), p / (p  1)) ); /* Take care of odd primes dividing the index f. */ my([D0, f] = coredisc(D, 1)); P = factor(Oddpart(f))[,1]; S /= prod(j = 1, #P, my(p = P[j]); 1  kronecker(D0, p) / (p  1); ); /* Take care of the primes p <= N. */ S *= prodeuler(p = 3, N, 1  kronecker(D0, p) / (p  1)); /* Do the real work */ return (S * exp(HLW2(D0, N))); } Code:
*** unexpected character: LchiN(L,Ebad,s)=my([P,E]=Ebad);lfun(L,s)*pro ^ 
20200614, 17:20  #42 
Sep 2002
Database er0rr
3281_{10} Posts 
The code translates here. Is you error at runtime? Maybe your should consider upgrading Pari/GP to a later version.
Code:
GP/PARI CALCULATOR Version 2.12.0 (alpha) amd64 running linux (x8664/GMP6.1.2 kernel) 64bit version compiled: Sep 27 2019, gcc version 9.1.0 (GCC) threading engine: single (readline v7.0 enabled, extended help enabled) 
20200614, 22:15  #43 
Dec 2008
you know...around...
3^{2}×61 Posts 
Okay, I got the newest version and the program can now be read in.
But it is still not working as desired, I'm afraid: Code:
(23:53) gp > HardyLittlewood2(x^2+x+41) *** at toplevel: HardyLittlewood2(x^2+x+41) *** ^ *** in function HardyLittlewood2: ...,p)/(p1));return(S*exp(HLW2(D0,N))) *** ^ *** in function HLW2: my(B=getlocalbitprec(),lim,S1,S2,L,P,v,EBad);1 *** ^ *** not a function in function call 
20200615, 00:56  #44 
Sep 2002
Database er0rr
17·193 Posts 
On my version:
Code:
? HardyLittlewood2(x^2+x+41) 6.6395463549428433306471137152997759330 Does ?getlocalbitprec give you an entry? 
Thread Tools  
Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
LLL in GP/Pari  paul0  Programming  2  20151117 13:04 
PARI vs GAP  skan  Miscellaneous Math  0  20121216 00:13 
pari  devarajkandadai  Programming  21  20120831 18:08 
64bit Pari?  CRGreathouse  Software  2  20090313 04:22 