Your product formula is a good idea. It's faster than my summation formula.
On Dec 21, 3:40 am, John Cremona <john.crem...@gmail.com> wrote: > On Dec 21, 1:38 am, rje <ronevan...@gmail.com> wrote: > > > Thanks for the helpful response. The appropriate code for computing > > Gamma(n).ncusps() is > > > n=self.level() > > if n<=2: > > return[None,1,3][n] > > return ZZ(sum([moebius(d)*(n/d)^2/ZZ(2) for d in n.divisors()])) > > > But can I impose on someone who knows the ticketing procedure > > to get this implemented? Thanks. > > OK, -- but if you want to use this as a nice first contribution to > Sage, you can go for it! > > Incidentally, as far as I can see Gamma(n).ncusps() is half of > Gamma1(n).index(). At least for n>2 (for n=1,2 there is no factor > 1/2). So we could copy that code, which is > > return prod([p**(2*e) - p**(2*e-2) for (p,e) in > self.level().factor()]) > > or just return Gamma1(n).index()//2. > > I just found your ticket at #10506. I'll make a patch and you can > review it! > > John Cremona > > > > > *************************************************************************** > > ************************ > > > On Dec 20, 9:21 am, John Cremona <john.crem...@gmail.com> wrote: > > > > You are right, and you can see the reason like this: > > > > sage: G = Gamma(5) > > > sage: G.ncusps?? > > > > shows that the code is a one-liner > > > > return ZZ(len(self.cusps())) > > > > i.e. a complete set of cusps is computed (to see how, do G.cusps??), > > > while for the other groups a formula is used, e.g. > > > > sage: G = Gamma0(5) > > > sage: G.ncusps?? > > > > shows the code > > > > n = self.level() > > > return sum([arith.euler_phi(arith.gcd(d,n//d)) for d in > > > n.divisors()]) > > > > and > > > > sage: G = Gamma1(5) > > > sage: G.ncusps?? > > > > shows the code > > > > n = self.level() > > > if n <= 4: > > > return [None, 1, 2, 2, 3][n] > > > return ZZ(sum([phi(d)*phi(n/d)/ZZ(2) for d in n.divisors()])) > > > > Why don't you open a ticket to improve this by implementing a suitabel > > > formula for the principal congruence subgroups? > > > > John Cremona > > > > On Dec 19, 10:51 pm, rje <ronevan...@gmail.com> wrote: > > > > > Sage is slow in computing the number of > > > > cusps for Gamma(n). > > > > > Look, for example, at the disparity in times below. > > > > > sage: time Gamma(5).ncusps() > > > > CPU times: user 52.02 s, sys: 0.24 s, total: 52.26 s > > > > Wall time: 52.29 s > > > > 12 > > > > > sage: time Gamma0(5).ncusps() > > > > CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s > > > > Wall time: 0.00 s > > > > 2 > > > > > sage: time Gamma1(5).ncusps() > > > > CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s > > > > Wall time: 0.00 s > > > > 4- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org