PARI/GP in Quarto

PARI-GP-ENGINE

PARI-GP-ENGINE lets you put PARI/GP code in a Quarto document, run it, and show the results — with the code highlighted properly.

Everything on this site is rendered by the extension itself. The block below is real code that ran when this page was built:

p = nextprime(10^40)
factor(p - 1)
10000000000000000000000000000000000000121

[                      2 3]

[                      5 1]

[                     11 1]

[                     17 1]

[                  12973 1]

[             1821309023 1]

[56581485446137975519811 1]

Install

quarto add oeistools/PARI-GP-ENGINE

You need Quarto 1.9 or newer and the gp executable on your PATH. See Get started.

What you get

Execution. `` cells run in onegpsession per document, so state carries from cell to cell, exactly as it would at thegp` prompt.

Highlighting. A syntax definition covering the full function set of PARI/GP 2.17, applied automatically — nothing to configure. The engine itself works with gp 2.13 and newer.

Figures. Plots exported as SVG become real figures, with captions and cross-references. See Figures.

Errors that behave. A PARI/GP error stops the render and tells you which cell, unless you asked for the error to be part of the document.

A taste

The class number and regulator of \(\mathbb{Q}(\sqrt[3]{2})\):

K = bnfinit(x^3 - 2, 1);
[K.no, K.reg]
[1, 1.3473773483293841009181878914456530463]

And because the session persists, its fundamental units are still one cell away:

K.fu
[Mod(x - 1, x^3 - 2)]