![]() |
![]() |
#34 |
Apr 2020
22·5 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 2020-04-25 at 11:35 |
![]() |
![]() |
![]() |
#35 |
Apr 2020
22·5 Posts |
![]()
thank you very much
|
![]() |
![]() |
![]() |
#36 | |||
"Bob Silverman"
Nov 2003
North of Boston
22·1,889 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 non-prime divisors. Your "brute force/try all possibilities" is simple minded and horribly inefficient. Last fiddled with by R.D. Silverman on 2020-04-25 at 12:50 Reason: cleanup |
|||
![]() |
![]() |
![]() |
#37 | |
"Bob Silverman"
Nov 2003
North of Boston
22×1,889 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 2020-04-25 at 13:40 Reason: add hint. |
|
![]() |
![]() |
![]() |
#38 | |
Romulan Interpreter
"name field"
Jun 2011
Thailand
283016 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 ![]() ---- p.s. is matjax broken again? it seems Last fiddled with by LaurV on 2020-04-25 at 15:45 |
|
![]() |
![]() |
![]() |
#39 | |||
"Bob Silverman"
Nov 2003
North of Boston
22×1,889 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 2020-04-25 at 17:56 |
|||
![]() |
![]() |
![]() |
#40 | ||
Romulan Interpreter
"name field"
Jun 2011
Thailand
24×643 Posts |
![]() Quote:
Quote:
Last fiddled with by LaurV on 2020-04-25 at 18:02 |
||
![]() |
![]() |
![]() |
#41 |
Dec 2008
you know...around...
2×443 Posts |
![]()
There is a program for the computation of Hardy-Littlewood 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 Hardy-Littlewood 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 ^-------------------- |
![]() |
![]() |
![]() |
#42 |
Sep 2002
Database er0rr
7×23×29 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 (x86-64/GMP-6.1.2 kernel) 64-bit version compiled: Sep 27 2019, gcc version 9.1.0 (GCC) threading engine: single (readline v7.0 enabled, extended help enabled) |
![]() |
![]() |
![]() |
#43 |
Dec 2008
you know...around...
2×443 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 top-level: HardyLittlewood2(x^2+x+41) *** ^-------------------------- *** in function HardyLittlewood2: ...,p)/(p-1));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 |
![]() |
![]() |
![]() |
#44 |
Sep 2002
Database er0rr
7·23·29 Posts |
![]()
On my version:
Code:
? HardyLittlewood2(x^2+x+41) 6.6395463549428433306471137152997759330 Does ?getlocalbitprec give you an entry? |
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
LLL in GP/Pari | paul0 | Programming | 2 | 2015-11-17 13:04 |
PARI vs GAP | skan | Miscellaneous Math | 0 | 2012-12-16 00:13 |
pari | devarajkandadai | Programming | 21 | 2012-08-31 18:08 |
64-bit Pari? | CRGreathouse | Software | 2 | 2009-03-13 04:22 |