Kevin Buzzard on Wed, 05 Apr 2017 15:30:42 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

writing a "module" in pari-gp


I occasionally use pari-gp to write what one might call a "module".
I've been doing this for years and now have got into some
exceptionally bad habits. There must be a better way to do what I am
doing.

Basically a summary of what I do is that I want to do some
experimental calculations based on some parameters which don't change
between sessions, so I edit my source file and put the parameters in
and then read the file into an interactive gp session and do my
experiments there.

Here's an example I'm currently thinking about. I have some code which
computes certain characteristic polynomials of Hecke operators on
Drinfeld modular forms. Drinfeld modular forms are defined over a base
function field and let's assume that this base field is F_q(T) for q a
fixed prime power and F_q the field with q elements. q is something
that needs to be chosen by the user and in a given session will
probably never change. I will also do various calculations of power
series in a variable t (this is the q-expansion variable but we used q
already) representing these modular forms, and all of these power
series will work to a fixed precision O(t^B) where B is a fixed
positive integer chosen at the start.

So here's what I do in practice. I want to work over F_q(T) and with
power series in t, so I really want T and t to be not defined by the
user. So the first thing I do is I start a fresh pari-gp session.

The second thing I do is to read in my module code, called
drinfeldslopes.g, which implements all the functions I want. The code
looks like this

q=9
B=100
\\
\\ that's the global variables set
\\
del()=[some pari function which will return a power series in t to
precision O(t^B)]
etc etc

so the first thing I do is to edit drinfeldslopes.g and change the
inbuilt values of q and B so they're the values I want.

I then \r the file drinfeldslopes.g in the fresh session and then I
have all my functions producing Drinfeld forms etc etc and I can do
calculations. For example I can run del() and it prints out the
Drinfeld modular form version of the Delta function for F_q[T] to
precision t^B; I didn't need q or B as an input because they're
globally fixed for the session.

This worked fine in the 1990s but I do wonder whether nowadays I could
be doing something more sophisticated. In python or sage I could
imagine importing a module and then running some initial code to set
some parameters.

Another thing I'd really like is that certain functions can take a
long time to run (e.g. computing del() when B is large) so I would
ideally like to remember the values of computations if they have been
done already. This is an independent question but is this sort of
thing possible or easy nowadays? This should just be a quick look-up
-- do I have to write this myself?

I should add that all I really need from the computer algebra system
is the ability to do arithmetic in the ring F_q(T)[[t]] mod t^B and
the field F_q(T); I chose pari-gp because my impression is that it's
quick at this sort of thing.

Kevin