Skip to content

Commit da192db

Browse files
committed
better example in README
1 parent bc7c70c commit da192db

File tree

1 file changed

+45
-9
lines changed

1 file changed

+45
-9
lines changed

README.rst

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,26 @@ setup.py install`` will produce an error.
5151
Usage
5252
-----
5353

54-
Here is an example of some PARI/GP computations in Python
54+
The interface as been kept as close as possible from PARI/GP. The following
55+
computation in GP
56+
57+
::
58+
59+
? zeta(2)
60+
%1 = 1.6449340668482264364724151666460251892
61+
62+
? p = x^3 + x^2 + x - 1;
63+
? modulus = t^3 + t^2 + t - 1;
64+
? fq = factorff(p, 3, modulus);
65+
? centerlift(lift(fq))
66+
%5 =
67+
[ x - t 1]
68+
69+
[x + (t^2 + t - 1) 1]
70+
71+
[ x + (-t^2 - 1) 1]
72+
73+
translates into
5574

5675
::
5776

@@ -61,12 +80,11 @@ Here is an example of some PARI/GP computations in Python
6180
>>> pari(2).zeta()
6281
1.64493406684823
6382

64-
>>> pari(2197).ispower(3)
65-
(3, 13)
66-
67-
>>> K = pari("bnfinit(x^3 - 2)")
68-
>>> K.bnfunit()
69-
[x - 1]
83+
>>> p = pari("x^3 + x^2 + x - 1")
84+
>>> modulus = pari("t^3 + t^2 + t - 1")
85+
>>> fq = p.factorff(3, modulus)
86+
>>> fq.lift().centerlift()
87+
[x - t, 1; x + (t^2 + t - 1), 1; x + (-t^2 - 1), 1]
7088

7189
The object **pari** above is the object for the interface and acts as a
7290
constructor. It can be called with basic Python objects like integer
@@ -76,9 +94,27 @@ the corresponding string is interpreted as if it was executed in a GP shell.
7694
Beyond the interface object **pari** of type **Pari**, any object you get a
7795
handle on is of type **Gen** (that is a wrapper around the **GEN** type from
7896
libpari). All PARI/GP functions are then available in their original names as
79-
*methods* like **zeta**, **ispower** or **bnfunit** above.
97+
*methods* like **zeta**, **factorff**, **lift** or **centerlift** above.
98+
99+
Alternatively, the pari functions are accessible as methods of **pari**. The
100+
same computations be done via
101+
102+
::
103+
104+
>>> import cypari2
105+
>>> pari = cypari2.Pari()
106+
107+
>>> pari.zeta(2)
108+
1.64493406684823
109+
110+
>>> p = pari("x^3 + x^2 + x - 1")
111+
>>> modulus = pari("t^3 + t^2 + t - 1")
112+
>>> fq = pari.factorff(p, 3, modulus)
113+
>>> pari.centerlift(pari.lift(fq))
114+
[x - t, 1; x + (t^2 + t - 1), 1; x + (-t^2 - 1), 1]
80115

81-
The complete documentation is available at http://cypari2.readthedocs.io
116+
The complete documentation of cypari2 is available at http://cypari2.readthedocs.io and
117+
the PARI/GP documentation at http://pari.math.u-bordeaux.fr/doc.html
82118

83119
Contributing
84120
------------

0 commit comments

Comments
 (0)