Ok, so I figured out what is going on here, at least.

When S = CuspForms(N, k), a call to S.hecke_polynomial() passes through a
bunch of abstract layers and then eventually arrives at
S._compute_hecke_matrix_prime(self, p, prec=None),
in sage/modular/modform/space.py. To compute the hecke matrix, this
function computes a basis of cusp forms, explicitly computes the action of
the Hecke operator on this basis, and then does linear algebra to find the
matrix of this operator on this basis. Which is all rather roundabout,
since it ends up using modular symbols to compute hecke matrices to compute
a basis. I understand why this might take 5 hours.

Maybe there is some sense to this very generic functionality, if, e.g., I
can use it to more efficiently compute the same thing for a small
dimensional subspace.

On Sat, Sep 17, 2016 at 3:48 PM, Jonathan Bober <jwbo...@gmail.com> wrote:

> What is going on with the timings in the following examples?
> sage: S = CuspForms(1728, 2)
> sage: %time f = S.hecke_polynomial(2)
> CPU times: user 17276.68 s, sys: 13.46 s, total: 17290.14 s
> Wall time: 17293.59 s
> sage: f
> x^253 + x^251 - 2*x^249
> (Meanwhile, in a separate Sage session...)
> sage: %time M = ModularSymbols(1728, 2, 1)
> CPU times: user 0.47 s, sys: 0.03 s, total: 0.50 s
> Wall time: 0.54 s
> sage: %time S = M.cuspidal_subspace()
> CPU times: user 1.57 s, sys: 0.00 s, total: 1.57 s
> Wall time: 1.54 s
> sage: %time f = S.hecke_polynomial(2)
> CPU times: user 19.09 s, sys: 0.00 s, total: 19.09 s
> Wall time: 19.07 s
> sage: f
> x^253 + x^251 - 2*x^249
> That's almost 5 hours using CuspForms() and just over 20 seconds using
> ModularSymbols() directly. To compute the same thing. Is this expected
> behavior? Am I being stupid somehow?
> (Note: I did this on a "very old" (2 years) version of Sage. But as other
> checks, I also tried the first method on a relatively up to date version on
> my laptop and stopped after about 7 minutes when it was using 15% of my
> ram. I also tried Magma, where the standard ModularForms(),
> CuspidalSubspace(), HeckePolynomial() commands complete quickly, and I
> tried cloud.sagemath.com, where I again killed the computation after a
> few minutes. Maybe if I find an old enough version of Sage the computations
> will be the same speed...)
> For a long time, and until recently, I would have just tried the first
> method, not knowing what I was doing, and would have said to myself
> something like "I guess Sage is probably pretty good at computations with
> trivial character, so this is probably just something that takes a long
> time." Now instead I would guess that for at least some functionality the
> ModularForms()/CuspForms() classes are so slow that they are effectively
> broken (or, at least, not much more than a toy) and have been for a long
> time. This is a shame, because I shouldn't even need to know that modular
> symbols are a thing that exist if I just want to do some simple
> computations like this.
> I would expect ModularForms/CuspForms to mostly be a light wrapper around
> ModularSymbols, but something else must be going on here. One explanation
> would be that for some reason the first computation triggers some large
> computation that would make all subsequent computations faster, but the
> computation of hecke_polynomial(3) didn't seem like it was going to be
> fast. (I didn't wait for it to finish.)

You received this message because you are subscribed to the Google Groups 
"sage-nt" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-nt+unsubscr...@googlegroups.com.
To post to this group, send an email to sage-nt@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-nt.
For more options, visit https://groups.google.com/d/optout.

Reply via email to