Quickly computing cusp form space dimensions

29 views
Skip to first unread message

David Loeffler

unread,
Sep 20, 2022, 4:07:14 AM9/20/22
to sage-nt
How should one go about *quickly* computing the dimension of a space of cuspidal modular forms (of weight >= 2) in Sage, without actually computing a basis of the space?

The standalone method "dimension_cusp_forms" used to be really good for this, and was a command I personally used very very frequently. However, ticket #32647 slapped a deprecation warning on it. If this indeed gets removed, then the simplest way of getting at this functionality is by typing "CuspForms(...).dimension()". 

Unfortunately, this approach is vastly slower than the old standalone function was, since it seems to be doing some kind of unnecessary O(dimension) loop over the basis elements at initialisation time:

sage: time dimension_cusp_forms(Gamma0(99), 100) # deprecated

[ deprecation warning text ]

CPU times: user 8 ms, sys: 0 ns, total: 8 ms

Wall time: 8.94 ms

1184


sage: time CuspForms(Gamma0(99), 100).dimension()

CPU times: user 1.06 s, sys: 124 ms, total: 1.18 s

Wall time: 1.18 s

1184


Note the huge difference in timings: 9 milliseconds vs 1.2 seconds! So the non-deprecated method is 130 times slower than the deprecated one, which seems a bit problematic to me.

IMHO, Sage has shot itself in the foot here, axing a fast and effective command in one of its "core competences" (modular forms) because some developer's notion of code aesthetics has been prioritised over ease-of-use and functionality. I'd like to call for this change made in #32647 to be reversed, and not reintroduced unless CuspForms.__init__() has been re-engineered to make the new code path as quick as the old one was.

(This problem only affects cusp form spaces, not the full modular form space; "ModularForms(...).dimension()" takes about the same time as "dimension_modular_forms()", as it should. If you're crafty, you can work around this by importing "dimension_cusp_forms" from sage.modular.dims, or using the dimension_cusp_forms() method of the Gamma0 group class; but these won't be easy to find for non-expert Sage users.)

Regards, David

John Cremona

unread,
Sep 20, 2022, 5:21:26 AM9/20/22
to sag...@googlegroups.com
In 9.6 and 9.7.rc1, I follow the suggestions at ticket #32647 and all
seems well:

sage: from sage.modular.dims import dimension_cusp_forms
sage: time dimension_cusp_forms(Gamma0(99), 100)
CPU times: user 4 ms, sys: 0 ns, total: 4 ms
Wall time: 5.19 ms
1184

-- in particular it is fast and I see no deprecation warning. David,
you didn't say which Sage version you were running.

John
> --
> 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+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-nt/CANDN%3DhzJRoKzD09Rn8pfwhMXOnU5tgTeD1j1yhCcPAKeCxYziw%40mail.gmail.com.

David Loeffler

unread,
Sep 20, 2022, 6:20:32 AM9/20/22
to sage-nt
Hi John,

My point is that once the deprecated top-level function is removed, non-expert users wanting to compute these dimensions are unlikely to spot that they can import extra stuff from "sage.modular.dims"; they're much more likely to end up using CuspForms(...).dimension(), which is hugely slower (and the docstring for that method does not say anything about the existence of a faster alternative).

(My email was prompted by a discussion on MathOverflow with a Sage newbie who wanted to compute some modular form space dimensions.)  

David

John Cremona

unread,
Sep 20, 2022, 6:23:52 AM9/20/22
to sag...@googlegroups.com
OK, fair enough. I first thought that some functionality was no
longer available, but your point is that it is hidden. I think that
there has been a move to have fewer things in the global namespace.

We can open a ticket just to add to the documentation, perhaps.

John
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-nt/CANDN%3DhyqUbg6w4ZZvtCq46KqbohaFnF2KDoMZYQpyvFFGEzP1A%40mail.gmail.com.

William Stein

unread,
Sep 20, 2022, 12:35:41 PM9/20/22
to sag...@googlegroups.com
On Tue, Sep 20, 2022 at 1:07 AM David Loeffler <d.loef...@cantab.net> wrote:
> I'd like to call for this change made in #32647 to be reversed, and not reintroduced unless CuspForms.__init__() has been re-engineered to make the new code path as quick as the old one was.

A middle ground would be to not actually remove the deprecated
functionality until after "CuspForms(Gamma0(99), 100).dimension()" is
made fast (instead of the usual 1 year period). Similar remarks for
spaces of cusp forms with character.

-- William

--
William (http://wstein.org)
Reply all
Reply to author
Forward
0 new messages