Ask Your Question

How to write Pari GP script in Sage

asked 2023-07-23 07:55:50 +0100

adityaghosh2001 gravatar image

I'm new to Sage and Pari-GP. There does not seem to be any application which can act as a Pari interface nicely. In Sage the only solution is to use %%gp to write a pari-gp script. Is there a way to write a whole script without having to use %%gp at the start of every cell? Alternatively, if you have any suggestions for a GUI for Pari scripts, please let me know.

edit retag flag offensive close merge delete


Sage can use simple gp-commands / one-liners to associate to a gp-object a sage object. For instance:

sage: a = gp("intnum(t=0, 1, (exp(t)-1)/t)")
sage: a
sage: type(a)
<class ''>


sage: f = gp('factor(1/matdet(mathilbert(6)))')
sage: f
[2, 14; 3, 9; 5, 5; 7, 5; 11, 1]
sage: type(f)
<class ''>
sage: f.sage
<bound method InterfaceElement.sage of [2, 14; 3, 9; 5, 5; 7, 5; 11, 1]>
sage: f.sage()
[ 2 14]
[ 3  9]
[ 5  5]
[ 7  5]
[11  1]
sage: type(f.sage())
<class 'sage.matrix.matrix_integer_dense.Matrix_integer_dense'>

For short trips through pari this may be a way. Else the gp-interpreter is GUI enough (for me).

dan_fulea gravatar imagedan_fulea ( 2023-07-23 12:34:15 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2023-07-24 01:00:56 +0100

slelievre gravatar image

You can install pari-jupyter which provides a PARI Jupyter kernel.

The simplest way to install it is to type the following from within sage:

sage: %pip install pari-jupyter

or if you installed Sage using conda and mamba, activate the Sage conda environment

$ conda activate sage

and install pari-jupyter in it

$ mamba install pari_jupyter

Next time you start Jupyter Notebook or Jupyter Lab, you will have the option of creating Jupyter notebooks with the "pari-jupyter" PARI Jupyter kernel.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2023-07-23 07:55:50 +0100

Seen: 162 times

Last updated: Jul 24 '23