15.1 PARI C-library interface

Module: sage.libs.pari.gen

PARI C-library interface

Author Log:

sage: pari('5! + 10/x')
(120*x + 10)/x
sage: pari('intnum(x=0,13,sin(x)+sin(x^2) + x)')
85.18856819515268446242866615                # 32-bit
85.188568195152684462428666150825866897      # 64-bit
sage: f = pari('x^3-1')
sage: v = f.factor(); v
[x - 1, 1; x^2 + x + 1, 1]
sage: v[0]   # indexing is 0-based unlike in GP.
[x - 1, x^2 + x + 1]~
sage: v[1]
[1, 1]~

Arithmetic obeys the usual coercion rules.

sage: type(pari(1) + 1)
<type 'sage.libs.pari.gen.gen'>
sage: type(1 + pari(1))
<type 'sage.libs.pari.gen.gen'>

Module-level Functions

init_pari_stack( )

Change the PARI scratch stack space to the given size.

The main application of this command is that you've done some individual PARI computation that used a lot of stack space. As a result the PARI stack may have doubled several times and is now quite large. That object you computed is copied off to the heap, but the PARI stack is never automatically shrunk back down. If you call this function you can shrink it back down.

If you set this too small then it will automatically be increased if it is exceeded, which could make some calculations initially slower (since they have to be redone until the stack is big enough).

Input:

size
- an integer (default: 8000000)

sage: get_memory_usage()                       # random output
'122M+'
sage: a = pari('2^100000000')
sage: get_memory_usage()                       # random output
'157M+'
sage: del a
sage: get_memory_usage()                       # random output
'145M+'

Hey, I want my memory back!

sage: sage.libs.pari.gen.init_pari_stack()
sage: get_memory_usage()                       # random output
'114M+'

Ahh, that's better.

max( )

max(x,y): Return the maximum of x and y.

min( )

min(x,y): Return the minimum of x and y.

vecsmall_to_intlist( )

Input:

v
- a gen of type Vecsmall
Output: a Python list of Python ints

Class: gen

class gen
Python extension class that models the PARI GEN type.

Functions: abs,$ \,$ acos,$ \,$ acosh,$ \,$ agm,$ \,$ algdep,$ \,$ arg,$ \,$ asin,$ \,$ asinh,$ \,$ atan,$ \,$ atanh,$ \,$ bernfrac,$ \,$ bernreal,$ \,$ bernvec,$ \,$ besselh1,$ \,$ besselh2,$ \,$ besseli,$ \,$ besselj,$ \,$ besseljh,$ \,$ besselk,$ \,$ besseln,$ \,$ bezout,$ \,$ binary,$ \,$ binomial,$ \,$ bitand,$ \,$ bitneg,$ \,$ bitnegimply,$ \,$ bitor,$ \,$ bittest,$ \,$ bitxor,$ \,$ bnfcertify,$ \,$ bnfinit,$ \,$ bnfisintnorm,$ \,$ bnfisprincipal,$ \,$ bnfnarrow,$ \,$ bnfunit,$ \,$ ceil,$ \,$ centerlift,$ \,$ changevar,$ \,$ charpoly,$ \,$ chinese,$ \,$ Col,$ \,$ component,$ \,$ concat,$ \,$ conj,$ \,$ conjvec,$ \,$ contfrac,$ \,$ contfracpnqn,$ \,$ copy,$ \,$ cos,$ \,$ cosh,$ \,$ cotan,$ \,$ denominator,$ \,$ deriv,$ \,$ dilog,$ \,$ dirzetak,$ \,$ disc,$ \,$ divrem,$ \,$ eint1,$ \,$ elementval,$ \,$ elladd,$ \,$ ellak,$ \,$ ellan,$ \,$ ellap,$ \,$ ellaplist,$ \,$ ellbil,$ \,$ ellchangecurve,$ \,$ ellchangepoint,$ \,$ elleisnum,$ \,$ elleta,$ \,$ ellglobalred,$ \,$ ellheight,$ \,$ ellheightmatrix,$ \,$ ellinit,$ \,$ ellisoncurve,$ \,$ ellj,$ \,$ elllocalred,$ \,$ elllseries,$ \,$ ellminimalmodel,$ \,$ ellorder,$ \,$ ellordinate,$ \,$ ellpointtoz,$ \,$ ellpow,$ \,$ ellrootno,$ \,$ ellsigma,$ \,$ ellsub,$ \,$ elltaniyama,$ \,$ elltors,$ \,$ ellwp,$ \,$ ellzeta,$ \,$ ellztopoint,$ \,$ erfc,$ \,$ eta,$ \,$ eval,$ \,$ exp,$ \,$ factor,$ \,$ factormod,$ \,$ factorpadic,$ \,$ fibonacci,$ \,$ floor,$ \,$ frac,$ \,$ gamma,$ \,$ gammah,$ \,$ gcd,$ \,$ gen_length,$ \,$ getattr,$ \,$ hilbert,$ \,$ hyperu,$ \,$ idealadd,$ \,$ idealappr,$ \,$ idealdiv,$ \,$ idealfactor,$ \,$ idealhnf,$ \,$ idealmul,$ \,$ idealnorm,$ \,$ idealred,$ \,$ idealtwoelt,$ \,$ idealval,$ \,$ imag,$ \,$ incgam,$ \,$ incgamc,$ \,$ int_unsafe,$ \,$ intformal,$ \,$ intvec_unsafe,$ \,$ ispower,$ \,$ isprime,$ \,$ ispseudoprime,$ \,$ issquare,$ \,$ issquarefree,$ \,$ j,$ \,$ kronecker,$ \,$ lcm,$ \,$ length,$ \,$ lex,$ \,$ lift,$ \,$ lindep,$ \,$ list,$ \,$ List,$ \,$ list_str,$ \,$ listinsert,$ \,$ listput,$ \,$ lllgram,$ \,$ lllgramint,$ \,$ lngamma,$ \,$ log,$ \,$ Mat,$ \,$ matadjoint,$ \,$ matdet,$ \,$ matfrobenius,$ \,$ mathnf,$ \,$ mathnfmod,$ \,$ mathnfmodid,$ \,$ matker,$ \,$ matkerint,$ \,$ matsnf,$ \,$ matsolve,$ \,$ mattranspose,$ \,$ max,$ \,$ min,$ \,$ Mod,$ \,$ modreverse,$ \,$ moebius,$ \,$ ncols,$ \,$ newtonpoly,$ \,$ nextprime,$ \,$ nfbasis,$ \,$ nfbasis_d,$ \,$ nfdisc,$ \,$ nffactor,$ \,$ nfgenerator,$ \,$ nfinit,$ \,$ nfisisom,$ \,$ nfrootsof1,$ \,$ nfsubfields,$ \,$ norm,$ \,$ nrows,$ \,$ numbpart,$ \,$ numdiv,$ \,$ numerator,$ \,$ numtoperm,$ \,$ omega,$ \,$ order,$ \,$ padicappr,$ \,$ padicprec,$ \,$ parent,$ \,$ permtonum,$ \,$ phi,$ \,$ Pol,$ \,$ polcoeff,$ \,$ polcompositum,$ \,$ poldegree,$ \,$ poldisc,$ \,$ poldiscreduced,$ \,$ polgalois,$ \,$ polhensellift,$ \,$ polinterpolate,$ \,$ polisirreducible,$ \,$ pollead,$ \,$ polrecip,$ \,$ polred,$ \,$ polredabs,$ \,$ polresultant,$ \,$ Polrev,$ \,$ polroots,$ \,$ polrootsmod,$ \,$ polrootspadic,$ \,$ polrootspadicfast,$ \,$ polsturm,$ \,$ polsturm_full,$ \,$ polsylvestermatrix,$ \,$ polsym,$ \,$ polylog,$ \,$ precision,$ \,$ primepi,$ \,$ printtex,$ \,$ psi,$ \,$ python,$ \,$ python_list,$ \,$ python_list_small,$ \,$ Qfb,$ \,$ qfbhclassno,$ \,$ qflll,$ \,$ qflllgram,$ \,$ qfminim,$ \,$ qfrep,$ \,$ random,$ \,$ real,$ \,$ reverse,$ \,$ rnfcharpoly,$ \,$ rnfdisc,$ \,$ rnfeltabstorel,$ \,$ rnfeltreltoabs,$ \,$ rnfequation,$ \,$ rnfidealabstorel,$ \,$ rnfidealhnf,$ \,$ rnfidealnormrel,$ \,$ rnfidealreltoabs,$ \,$ rnfidealtwoelt,$ \,$ rnfinit,$ \,$ rnfisfree,$ \,$ round,$ \,$ Ser,$ \,$ serconvol,$ \,$ serlaplace,$ \,$ serreverse,$ \,$ Set,$ \,$ shift,$ \,$ shiftmul,$ \,$ sign,$ \,$ simplify,$ \,$ sin,$ \,$ sinh,$ \,$ sizebyte,$ \,$ sizedigit,$ \,$ sqr,$ \,$ sqrt,$ \,$ sqrtn,$ \,$ Str,$ \,$ Strchr,$ \,$ Strexpand,$ \,$ Strtex,$ \,$ subst,$ \,$ substpol,$ \,$ sumdiv,$ \,$ sumdivk,$ \,$ tan,$ \,$ tanh,$ \,$ taylor,$ \,$ teichmuller,$ \,$ theta,$ \,$ thetanullk,$ \,$ thue,$ \,$ thueinit,$ \,$ trace,$ \,$ truncate,$ \,$ type,$ \,$ valuation,$ \,$ variable,$ \,$ Vec,$ \,$ vecextract,$ \,$ vecmax,$ \,$ vecmin,$ \,$ Vecrev,$ \,$ Vecsmall,$ \,$ weber,$ \,$ xgcd,$ \,$ zeta,$ \,$ znprimroot

abs( )

Returns the absolute value of x (its modulus, if x is complex). Rational functions are not allowed. Contrary to most transcendental functions, an exact argument is not converted to a real number before applying abs and an exact result is returned if possible.

sage: x = pari("-27.1")
sage: x.abs()
27.10000000000000000000000000               # 32-bit
27.100000000000000000000000000000000000     # 64-bit

If x is a polynomial, returns -x if the leading coefficient is real and negative else returns x. For a power series, the constant coefficient is considered instead.

sage: pari('x-1.2*x^2').abs()
1.200000000000000000000000000*x^2 - x              # 32-bit
1.2000000000000000000000000000000000000*x^2 - x    # 64-bit

acos( )

The principal branch of $ \cos^{-1}(x)$ , so that $ \Re(\acos (x))$ belongs to $ [0,Pi]$ . If $ x$ is real and $ \vert x\vert > 1$ , then $ \acos (x)$ is complex.

sage: pari('0.5').acos()
1.047197551196597746154214461               # 32-bit
1.0471975511965977461542144610931676281     # 64-bit
sage: pari('1.1').acos()
-0.4435682543851151891329110664*I             # 32-bit
-0.44356825438511518913291106635249808665*I   # 64-bit
sage: pari('1.1+I').acos()
0.8493430542452523259630143655 - 1.097709866825328614547942343*I           
# 32-bit
0.84934305424525232596301436546298780187 -
1.0977098668253286145479423425784723444*I     # 64-bit

acosh( )

The principal branch of $ \cosh^{-1}(x)$ , so that $ \Im(\acosh (x))$ belongs to $ [0,Pi]$ . If $ x$ is real and $ x <
1$ , then $ \acosh (x)$ is complex.

sage: pari(2).acosh()
1.316957896924816708625046347              # 32-bit
1.3169578969248167086250463473079684440    # 64-bit
sage: pari(0).acosh()
1.570796326794896619231321692*I            # 32-bit
1.5707963267948966192313216916397514421*I  # 64-bit
sage: pari('I').acosh()
0.8813735870195430252326093250 + 1.570796326794896619231321692*I    #
32-bit
0.88137358701954302523260932497979230902 +
1.5707963267948966192313216916397514421*I   # 64-bit

agm( )

The arithmetic-geometric mean of x and y. In the case of complex or negative numbers, the principal square root is always chosen. p-adic or power series arguments are also allowed. Note that a p-adic AGM exists only if x/y is congruent to 1 modulo p (modulo 16 for p=2). x and y cannot both be vectors or matrices.

sage: pari('2').agm(2)                  
2.000000000000000000000000000             # 32-bit
2.0000000000000000000000000000000000000   # 64-bit
sage: pari('0').agm(1)
0
sage: pari('1').agm(2)
1.456791031046906869186432383             # 32-bit
1.4567910310469068691864323832650819750   # 64-bit
sage: pari('1+I').agm(-3)
-0.9647317222908759112270275374 + 1.157002829526317260939086020*I          
# 32-bit
-0.96473172229087591122702753739366831917 +
1.1570028295263172609390860195427517825*I    # 64-bit

algdep( )

sage: n = pari.set_real_precision (200)
sage: w1 = pari('z1=2-sqrt(26); (z1+I)/(z1-I)')
sage: f = w1.algdep(12); f
545*x^11 - 297*x^10 - 281*x^9 + 48*x^8 - 168*x^7 + 690*x^6 - 168*x^5 +
48*x^4 - 281*x^3 - 297*x^2 + 545*x
sage: f(w1)
7.75513996 E-200 + 5.70672991 E-200*I     # 32-bit
3.780069700150794274 E-209 - 9.362977321012524836 E-211*I   # 64-bit
sage: f.factor()
[x, 1; x + 1, 2; x^2 + 1, 1; x^2 + x + 1, 1; 545*x^4 - 1932*x^3 + 2790*x^2
- 1932*x + 545, 1]
sage: pari.set_real_precision(n)
200

arg( )

arg(x): argument of x,such that $ -\pi < \arg(x) \leq \pi$ .

       sage: pari('2+I').arg()               
       0.4636476090008061162142562315              # 32-bit
0.46364760900080611621425623146121440203    # 64-bit

asin( )

The principal branch of $ \sin^{-1}(x)$ , so that $ \Re(\asin (x))$ belongs to $ [-\pi/2,\pi/2]$ . If $ x$ is real and $ \vert x\vert > 1$ then $ \asin (x)$ is complex.

sage: pari(pari('0.5').sin()).asin()
0.5000000000000000000000000000               # 32-bit
0.50000000000000000000000000000000000000     # 64-bit
sage: pari(2).asin()
1.570796326794896619231321692 + 1.316957896924816708625046347*I            
# 32-bit
1.5707963267948966192313216916397514421 +
1.3169578969248167086250463473079684440*I  # 64-bit

asinh( )

The principal branch of $ \sinh^{-1}(x)$ , so that $ \Im(\asinh (x))$ belongs to $ [-\pi/2,\pi/2]$ .

sage: pari(2).asinh()
1.443635475178810342493276740                # 32-bit
1.4436354751788103424932767402731052694      # 64-bit
sage: pari('2+I').asinh()
1.528570919480998161272456185 + 0.4270785863924761254806468833*I      #
32-bit
1.5285709194809981612724561847936733933 +
0.42707858639247612548064688331895685930*I      # 64-bit

atan( )

The principal branch of $ \tan^{-1}(x)$ , so that $ \Re(\atan (x))$ belongs to $ ]-\pi/2, \pi/2[$ .

sage: pari(1).atan()
0.7853981633974483096156608458              # 32-bit
0.78539816339744830961566084581987572104    # 64-bit
sage: pari('1.5+I').atan()
1.107148717794090503017065460 + 0.2554128118829953416027570482*I           
# 32-bit
1.1071487177940905030170654601785370401 +
0.25541281188299534160275704815183096744*I     # 64-bit

atanh( )

The principal branch of $ \tanh^{-1}(x)$ , so that $ \Im(\atanh (x))$ belongs to $ ]-\pi/2,\pi/2]$ . If $ x$ is real and $ \vert x\vert > 1$ then $ \atanh (x)$ is complex.

sage: pari(0).atanh()
0.E-250   # 32-bit
0.E-693   # 64-bit
sage: pari(2).atanh()
0.5493061443340548456976226185 + 1.570796326794896619231321692*I          
# 32-bit
0.54930614433405484569762261846126285232 +
1.5707963267948966192313216916397514421*I     # 64-bit

bernfrac( )

The Bernoulli number $ B_x$ , where $ B_0 = 1$ , $ B_1 = -1/2$ , $ B_2 = 1/6,\ldots,$ expressed as a rational number. The argument $ x$ should be of type integer.

sage: pari(18).bernfrac()
43867/798
sage: [pari(n).bernfrac() for n in range(10)]
[1, -1/2, 1/6, 0, -1/30, 0, 1/42, 0, -1/30, 0]

bernreal( )

The Bernoulli number $ B_x$ , as for the function bernfrac, but $ B_x$ is returned as a real number (with the current precision).

sage: pari(18).bernreal()
54.97117794486215538847117794                  # 32-bit
54.971177944862155388471177944862155388        # 64-bit

bernvec( )

Creates a vector containing, as rational numbers, the Bernoulli numbers $ B_0, B_2,\ldots, B_{2x}$ . This routine is obsolete. Use bernfrac instead each time you need a Bernoulli number in exact form.

Note: this routine is implemented using repeated independent calls to bernfrac, which is faster than the standard recursion in exact arithmetic.

sage: pari(8).bernvec()
[1, 1/6, -1/30, 1/42, -1/30, 5/66, -691/2730, 7/6, -3617/510]
sage: [pari(2*n).bernfrac() for n in range(9)]
[1, 1/6, -1/30, 1/42, -1/30, 5/66, -691/2730, 7/6, -3617/510]

besselh1( )

The $ H^1$ -Bessel function of index $ \nu$ and argument $ x$ .

sage: pari(2).besselh1(3)
0.4860912605858910769078310941 - 0.1604003934849237296757682995*I          
# 32-bit
0.48609126058589107690783109411498403480 -
0.16040039348492372967576829953798091810*I    # 64-bit

besselh2( )

The $ H^2$ -Bessel function of index $ \nu$ and argument $ x$ .

sage: pari(2).besselh2(3)
0.4860912605858910769078310941 + 0.1604003934849237296757682995*I          
# 32-bit
0.48609126058589107690783109411498403480 +
0.16040039348492372967576829953798091810*I     # 64-bit

besseli( )

Bessel I function (Bessel function of the second kind), with index $ u$ and argument $ x$ . If $ x$ converts to a power series, the initial factor $ (x/2)^{
u}/\Gamma(
u+1)$ is omitted (since it cannot be represented in PARI when $ u$ is not integral).

sage: pari(2).besseli(3)
2.245212440929951154625478386              # 32-bit
2.2452124409299511546254783856342650577    # 64-bit
sage: pari(2).besseli('3+I')
1.125394076139128134398383103 + 2.083138226706609118835787255*I      #
32-bit
1.1253940761391281343983831028963896470 +
2.0831382267066091188357872547036161842*I    # 64-bit

besselj( )

Bessel J function (Bessel function of the first kind), with index $ \nu$ and argument $ x$ . If $ x$ converts to a power series, the initial factor $ (x/2)^{\nu}/\Gamma(\nu+1)$ is omitted (since it cannot be represented in PARI when $ \nu$ is not integral).

sage: pari(2).besselj(3)
0.4860912605858910769078310941            # 32-bit
0.48609126058589107690783109411498403480  # 64-bit

besseljh( )

J-Bessel function of half integral index (Speherical Bessel function of the first kind). More precisely, besseljh(n,x) computes $ J_{n+1/2}(x)$ where n must an integer, and x is any complex value. In the current implementation (PARI, version 2.2.11), this function is not very accurate when $ x$ is small.

sage: pari(2).besseljh(3)
0.4127100322097159934374967959      # 32-bit
0.41271003220971599343749679594186271499    # 64-bit

besselk( )

nu.besselk(x, flag=0): K-Bessel function (modified Bessel function of the second kind) of index nu, which can be complex, and argument x.

Input:

nu
- a complex number
x
- real number (positive or negative)
flag
- default: 0 or 1: use hyperu (hyperu is much slower for small x, and doesn't work for negative x).

WARNING/TODO - with flag = 1 this function is incredibly slow (on 64-bit Linux) as it is implemented using it from the C library, but it shouldn't be (e.g., it's not slow via the GP interface.) Why?

sage: pari('2+I').besselk(3)
0.04559077184075505871203211094 + 0.02891929465820812820828883526*I     #
32-bit
0.045590771840755058712032110938791854704 +
0.028919294658208128208288835257608789842*I     # 64-bit

sage: pari('2+I').besselk(-3)
-4.348708749867516799575863067 - 5.387448826971091267230878827*I        #
32-bit
-4.3487087498675167995758630674661864255 -
5.3874488269710912672308788273655523057*I  # 64-bit

sage: pari('2+I').besselk(300, flag=1)   # long time
3.742246033197275082909500148 E-132 + 2.490710626415252262644383350 E-134*I
# 32-bit
3.7422460331972750829095001475885825717 E-132 +
2.4907106264152522626443833495225745762 E-134*I   # 64-bit

besseln( )

nu.besseln(x): Bessel N function (Spherical Bessel function of the second kind) of index nu and argument x.

sage: pari('2+I').besseln(3)
-0.2807755669582439141676487005 - 0.4867085332237257928816949747*I     #
32-bit
-0.28077556695824391416764870046044688871 -
0.48670853322372579288169497466916637395*I    # 64-bit

binary( )

binary(x): gives the vector formed by the binary digits of abs(x), where x is of type t_INT.

Input:

x
- gen of type t_INT
Output:
gen
- of type t_VEC

sage: pari(0).binary()
[0]
sage: pari(-5).binary()
[1, 0, 1]
sage: pari(5).binary()
[1, 0, 1]
sage: pari(2005).binary()
[1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1]

sage: pari('"2"').binary()
Traceback (most recent call last):
...
TypeError: x (=2) must be of type t_INT, but is of type t_STR.

binomial( )

binomial(x, k): return the binomial coefficient "x choose k".

Input:

x
- any PARI object (gen)
k
- integer

sage: pari(6).binomial(2)
15
sage: pari('x+1').binomial(3)
1/6*x^3 - 1/6*x
sage: pari('2+x+O(x^2)').binomial(3)
1/3*x + O(x^2)

bitand( )

bitand(x,y): Bitwise and of two integers x and y. Negative numbers behave as if modulo some large power of 2.

Input:

x
- gen (of type t_INT)
y
- coercible to gen (of type t_INT)
Output:
gen
- of type type t_INT

sage: pari(8).bitand(4)
0
sage: pari(8).bitand(8)
8
sage: pari(6).binary()
[1, 1, 0]
sage: pari(7).binary()
[1, 1, 1]
sage: pari(6).bitand(7)
6
sage: pari(19).bitand(-1)
19
sage: pari(-1).bitand(-1)
-1

bitneg( )

bitneg(x,n=-1): Bitwise negation of the integer x truncated to n bits. n=-1 (the default) represents an infinite sequence of the bit 1. Negative numbers behave as if modulo some large power of 2.

With n=-1, this function returns -n-1. With n >= 0, it returns a number a such that $ a\cong -n-1 \pmod{2^n}$ .

Input:

x
- gen (t_INT)
n
- long, default = -1
Output:
gen
- t_INT

sage: pari(10).bitneg()
-11
sage: pari(1).bitneg()
-2
sage: pari(-2).bitneg()
1
sage: pari(-1).bitneg()
0
sage: pari(569).bitneg()
-570
sage: pari(569).bitneg(10)
454
sage: 454 % 2^10
454
sage: -570 % 2^10
454

bitnegimply( )

bitnegimply(x,y): Bitwise negated imply of two integers x and y, in other words, x BITAND BITNEG(y). Negative numbers behave as if modulo big power of 2.

Input:

x
- gen (of type t_INT)
y
- coercible to gen (of type t_INT)
Output:
gen
- of type type t_INT

sage: pari(14).bitnegimply(0)    
14
sage: pari(8).bitnegimply(8)
0
sage: pari(8+4).bitnegimply(8)
4

bitor( )

bitor(x,y): Bitwise or of two integers x and y. Negative numbers behave as if modulo big power of 2.

Input:

x
- gen (of type t_INT)
y
- coercible to gen (of type t_INT)
Output:
gen
- of type type t_INT

sage: pari(14).bitor(0)
14
sage: pari(8).bitor(4)
12
sage: pari(12).bitor(1)
13
sage: pari(13).bitor(1)
13

bittest( )

bittest(x, long n): Returns bit number n (coefficient of $ 2^n$ in binary) of the integer x. Negative numbers behave as if modulo a big power of 2.

Input:

x
- gen (pari integer)
Output:
bool
- a Python bool

sage: x = pari(6)
sage: x.bittest(0)
False
sage: x.bittest(1)
True
sage: x.bittest(2)
True
sage: x.bittest(3)
False
sage: pari(-3).bittest(0)
True
sage: pari(-3).bittest(1)
False
sage: [pari(-3).bittest(n) for n in range(10)]
[True, False, True, True, True, True, True, True, True, True]

bitxor( )

bitxor(x,y): Bitwise exclusive or of two integers x and y. Negative numbers behave as if modulo big power of 2.

Input:

x
- gen (of type t_INT)
y
- coercible to gen (of type t_INT)
Output:
gen
- of type type t_INT

sage: pari(6).bitxor(4)
2
sage: pari(0).bitxor(4)
4
sage: pari(6).bitxor(0)
6

bnfcertify( )

bnf being as output by bnfinit, checks whether the result is correct, i.e. whether the calculation of the contents of self are correct without assuming the Generalized Riemann Hypothesis. If it is correct, the answer is 1. If not, the program may output some error message, but more probably will loop indefinitely. In no occasion can the program give a wrong answer (barring bugs of course): if the program answers 1, the answer is certified.

Note: WARNING! By default, most of the bnf routines depend on the correctness of a heuristic assumption which is stronger than GRH. In order to obtain a provably-correct result you must specify $ c=c_2=12$ for the technical optional parameters to the function. There are known counterexamples for smaller $ c$ (which is the default).

ceil( )

Return the smallest integer >= x.

Input:

x
- gen
Output:
gen
- integer

sage: pari(1.4).ceil()
2
sage: pari(-1.4).ceil()
-1
sage: pari('x').ceil()
x
sage: pari('x^2+5*x+2.2').ceil()
x^2 + 5*x + 2.200000000000000000000000000             # 32-bit
x^2 + 5*x + 2.2000000000000000000000000000000000000   # 64-bit
sage: pari('3/4').ceil()
1

centerlift( )

centerlift(x,v): Centered lift of x. This function returns exactly the same thing as lift, except if x is an integer mod.

Input:

x
- gen
v
- var (default: x)
Output: gen

sage: x = pari(-2).Mod(5)
sage: x.centerlift()
-2
sage: x.lift()
3
sage: f = pari('x-1').Mod('x^2 + 1')
sage: f.centerlift()
x - 1
sage: f.lift()
x - 1
sage: f = pari('x-y').Mod('x^2+1')
sage: f
Mod(x - y, x^2 + 1)
sage: f.centerlift('x')
x - y
sage: f.centerlift('y')
Mod(x - y, x^2 + 1)

changevar( )

changevar(gen x, y): change variables of x according to the vector y.

WARNING: This doesn't seem to work right at all in SAGE (!). Use with caution. *STRANGE*

Input:

x
- gen
y
- gen (or coercible to gen)
Output: gen

sage: pari('x^3+1').changevar(pari(['y']))
y^3 + 1

charpoly( )

charpoly(A,v=x,flag=0): det(v*Id-A) = characteristic polynomial of A using the comatrix. flag is optional and may be set to 1 (use Lagrange interpolation) or 2 (use Hessenberg form), 0 being the default.

Col( )

Col(x): Transforms the object x into a column vector.

The vector will have only one component, except in the following cases:

* When x is a vector or a quadratic form, the resulting vector is the initial object considered as a column vector.

* When x is a matrix, the resulting vector is the column of row vectors comprising the matrix.

* When x is a character string, the result is a column of individual characters.

* When x is a polynomial, the coefficients of the vector start with the leading coefficient of the polynomial.

* When x is a power series, only the significant coefficients are taken into account, but this time by increasing order of degree.

Input:

x
- gen
Output: gen

sage: pari('1.5').Col()
[1.500000000000000000000000000]~               # 32-bit
[1.5000000000000000000000000000000000000]~     # 64-bit
sage: pari([1,2,3,4]).Col()
[1, 2, 3, 4]~
sage: pari('[1,2; 3,4]').Col()
[[1, 2], [3, 4]]~
sage: pari('"SAGE"').Col()
["S", "A", "G", "E"]~
sage: pari('3*x^3 + x').Col()
[3, 0, 1, 0]~
sage: pari('x + 3*x^3 + O(x^5)').Col()
[1, 0, 3, 0]~

component( )

component(x, long n): Return n'th component of the internal representation of x. This function is 1-based instead of 0-based.

NOTE: For vectors or matrices, it is simpler to use x[n-1]. For list objects such as is output by nfinit, it is easier to use member functions.

Input:

x
- gen
n
- C long (coercible to)
Output: gen

sage: pari([0,1,2,3,4]).component(1)
0
sage: pari([0,1,2,3,4]).component(2)
1
sage: pari([0,1,2,3,4]).component(4)
3
sage: pari('x^3 + 2').component(1)
2
sage: pari('x^3 + 2').component(2)
0
sage: pari('x^3 + 2').component(4)
1

sage: pari('x').component(0)
Traceback (most recent call last):
...
PariError:  (8)

conj( )

conj(x): Return the algebraic conjugate of x.

Input:

x
- gen
Output: gen

sage: pari('x+1').conj()
x + 1
sage: pari('x+I').conj()
x - I
sage: pari('1/(2*x+3*I)').conj()
1/(2*x - 3*I)
sage: pari([1,2,'2-I','Mod(x,x^2+1)', 'Mod(x,x^2-2)']).conj()
[1, 2, 2 + I, Mod(-x, x^2 + 1), Mod(-x, x^2 - 2)]
sage: pari('Mod(x,x^2-2)').conj()
Mod(-x, x^2 - 2)
sage: pari('Mod(x,x^3-3)').conj()
Traceback (most recent call last):
...
PariError: incorrect type (20)

conjvec( )

conjvec(x): Returns the vector of all conjugates of the algebraic number x. An algebraic number is a polynomial over Q modulo an irreducible polynomial.

Input:

x
- gen
Output: gen

sage: pari('Mod(1+x,x^2-2)').conjvec()
[-0.4142135623730950488016887242, 2.414213562373095048801688724]~          
# 32-bit
[-0.41421356237309504880168872420969807857,
2.4142135623730950488016887242096980786]~     # 64-bit
sage: pari('Mod(x,x^3-3)').conjvec()
[1.442249570307408382321638311, -0.7211247851537041911608191554 +
1.249024766483406479413179544*I, -0.7211247851537041911608191554 -
1.249024766483406479413179544*I]~           # 32-bit
[1.4422495703074083823216383107801095884,
-0.72112478515370419116081915539005479419 +
1.2490247664834064794131795437632536350*I,
-0.72112478515370419116081915539005479419 -
1.2490247664834064794131795437632536350*I]~       # 64-bit

contfrac( )

contfrac(x,b,lmax): continued fraction expansion of x (x rational, real or rational function). b and lmax are both optional, where b is the vector of numerators of the continued fraction, and lmax is a bound for the number of terms in the continued fraction expansion.

contfracpnqn( )

contfracpnqn(x): [p_n,p_n-1; q_n,q_n-1] corresponding to the continued fraction x.

cos( )

The cosine function.

       sage: x = pari('1.5')
       sage: x.cos()
       0.07073720166770291008818985142     # 32-bit
0.070737201667702910088189851434268709084    # 64-bit
       sage: pari('1+I').cos()
       0.8337300251311490488838853943 - 0.9888977057628650963821295409*I  
# 32-bit
       0.83373002513114904888388539433509447980 -
0.98889770576286509638212954089268618864*I   # 64-bit
       sage: pari('x+O(x^8)').cos()
       1 - 1/2*x^2 + 1/24*x^4 - 1/720*x^6 + 1/40320*x^8 + O(x^9)

cosh( )

The hyperbolic cosine function.

sage: x = pari('1.5')
sage: x.cosh()
2.352409615243247325767667965               # 32-bit
2.3524096152432473257676679654416441702     # 64-bit
sage: pari('1+I').cosh()
0.8337300251311490488838853943 + 0.9888977057628650963821295409*I          
# 32-bit
0.83373002513114904888388539433509447980 +
0.98889770576286509638212954089268618864*I   # 64-bit
sage: pari('x+O(x^8)').cosh()
1 + 1/2*x^2 + 1/24*x^4 + 1/720*x^6 + O(x^8)

cotan( )

The cotangent of x.

sage: pari(5).cotan()
-0.2958129155327455404277671681     # 32-bit
-0.29581291553274554042776716808248528607    # 64-bit

On a 32-bit computer computing the cotangent of $ \pi$ doesn't raise an error, but instead just returns a very large number. On a 64-bit computer it raises a RuntimeError.

       sage: pari('Pi').cotan()  
       1.980704062 E28                      # 32-bit
Traceback (most recent call last):   # 64-bit
       ...	                                 # 64-bit
       PariError: division by zero (46)     # 64-bit

denominator( )

denominator(x): Return the denominator of x. When x is a vector, this is the least common multiple of the denominators of the components of x.

what about poly? Input:

x
- gen
Output: gen

sage: pari('5/9').denominator()
9
sage: pari('(x+1)/(x-2)').denominator()
x - 2
sage: pari('2/3 + 5/8*x + 7/3*x^2 + 1/5*y').denominator()
1
sage: pari('2/3*x').denominator()
1
sage: pari('[2/3, 5/8, 7/3, 1/5]').denominator()
120

dilog( )

The principal branch of the dilogarithm of $ x$ , i.e. the analytic continuation of the power series $ \log_2(x) = \sum_{n>=1} x^n/n^2$ .

sage: pari(1).dilog()
1.644934066848226436472415167              # 32-bit
1.6449340668482264364724151666460251892    # 64-bit
sage: pari('1+I').dilog()
0.6168502750680849136771556875 + 1.460362116753119547679775739*I    #
32-bit
0.61685027506808491367715568749225944595 +
1.4603621167531195476797757394917875976*I   # 64-bit

disc( )

e.disc(): return the discriminant of the elliptic curve e.

sage: e = pari([0, -1, 1, -10, -20]).ellinit()
sage: e.disc()
-161051
sage: _.factor()
[-1, 1; 11, 5]

divrem( )

divrem(x, y, v): Euclidean division of x by y giving as a 2-dimensional column vector the quotient and the remainder, with respect to v (to main variable if v is omitted).

eint1( )

x.eint1(n): exponential integral E1(x):

$\displaystyle \int_{x}^{\infty} \frac{e^{-t}}{t} dt
$

If n is present, output the vector [eint1(x), eint1(2*x), ..., eint1(n*x)]. This is faster than repeatedly calling eint1(i*x).

REFERENCE: See page 262, Prop 5.6.12, of Cohen's book "A Course in Computational Algebraic Number Theory".

elladd( )

e.elladd(z0, z1): return the sum of the points z0 and z1 on this elliptic curve.

Input:

e
- elliptic curve E
z0
- point on E
z1
- point on E

Output: point on E

First we create an elliptic curve:

sage: e = pari([0, 1, 1, -2, 0]).ellinit()
sage: str(e)[:65]   # first part of output
'[0, 1, 1, -2, 0, 4, -4, 1, -3, 112, -856, 389, 1404928/389, [0.90'

Next we add two points on the elliptic curve. Notice that the Python lists are automatically converted to PARI objects so you don't have to do that explicitly in your code.

sage: e.elladd([1,0], [-1,1])
[-3/4, -15/8]

ellak( )

e.ellak(n): Returns the coefficient $ a_n$ of the $ L$ -function of the elliptic curve e, i.e. the $ n$ -th Fourier coefficient of the weight 2 newform associated to e (according to Shimura-Taniyama).

Note: The curve $ e$ must be a medium or long vector of the type given by ellinit. For this function to work for every n and not just those prime to the conductor, e must be a minimal Weierstrass equation. If this is not the case, use the function ellminimalmodel first before using ellak (or you will get INCORRECT RESULTS!)

Input:

e
- a PARI elliptic curve.
n
- integer.

sage: e = pari([0, -1, 1, -10, -20]).ellinit()
sage: e.ellak(6)
2
sage: e.ellak(2005)        
2
sage: e.ellak(-1)
0
sage: e.ellak(0)
0

ellan( )

Return the first $ n$ Fourier coefficients of the modular form attached to this elliptic curve. See ellak for more details.

Input:

n
- a long integer
python_ints
- bool (default is False); if True, return a list of Python ints instead of a PARI gen wrapper.

sage: e = pari([0, -1, 1, -10, -20]).ellinit()
sage: e.ellan(3)
[1, -2, -1]
sage: e.ellan(20)
[1, -2, -1, 2, 1, 2, -2, 0, -2, -2, 1, -2, 4, 4, -1, -4, -2, 4, 0, 2]
sage: e.ellan(-1)
[]
sage: v = e.ellan(10, python_ints=True); v
[1, -2, -1, 2, 1, 2, -2, 0, -2, -2]
sage: type(v)
<type 'list'>
sage: type(v[0])
<type 'int'>

ellap( )

e.ellap(p): Returns the prime-indexed coefficient $ a_p$ of the $ L$ -function of the elliptic curve $ e$ , i.e. the $ p$ -th Fourier coefficient of the newform attached to e.

The computation uses the baby-step giant-step method and a trick due to Mestre, and requires $ O(p^{1/4})$ time and $ O(p^{1/4})$ storage.

Note: If p is not prime, this function will return an incorrect answer.

The curve e must be a medium or long vector of the type given by ellinit. For this function to work for every n and not just those prime to the conductor, e must be a minimal Weierstrass equation. If this is not the case, use the function ellminimalmodel first before using ellap (or you will get INCORRECT RESULTS!)

Input:

e
- a PARI elliptic curve.
p
- prime integer

sage: e = pari([0, -1, 1, -10, -20]).ellinit()
sage: e.ellap(2)
-2
sage: e.ellap(2003)
4
sage: e.ellak(-1)
0

ellaplist( )

e.ellaplist(n): Returns a PARI list of all the prime-indexed coefficients $ a_p$ (up to n) of the $ L$ -function of the elliptic curve $ e$ , i.e. the Fourier coefficients of the newform attached to $ e$ .

Input:

n
- a long integer
python_ints
- bool (default is False); if True, return a list of Python ints instead of a PARI gen wrapper.

Note: The curve e must be a medium or long vector of the type given by ellinit. For this function to work for every n and not just those prime to the conductor, e must be a minimal Weierstrass equation. If this is not the case, use the function ellminimalmodel first before using ellaplist (or you will get INCORRECT RESULTS!)

Input:

e
- a PARI elliptic curve.
n
- an integer

sage: e = pari([0, -1, 1, -10, -20]).ellinit()
sage: v = e.ellaplist(10); v
[-2, -1, 1, -2]
sage: type(v)
<type 'sage.libs.pari.gen.gen'>
sage: v.type()
't_VEC'
sage: e.ellan(10)
[1, -2, -1, 2, 1, 2, -2, 0, -2, -2]
sage: v = e.ellaplist(10, python_ints=True); v
[-2, -1, 1, -2]
sage: type(v)
<type 'list'>
sage: type(v[0])
<type 'int'>

ellbil( )

e.ellbil(z0, z1): return the value of the canonical bilinear form on z0 and z1.

Input:

e
- elliptic curve (assumed integral given by a minimal model, as returned by ellminimalmodel)
z0, z1
- rational points on e

sage: e = pari([0,1,1,-2,0]).ellinit().ellminimalmodel()[0]
sage: e.ellbil([1, 0], [-1, 1])
0.4181889844988605856298894582              # 32-bit
0.41818898449886058562988945821587638238    # 64-bit

ellchangecurve( )

e.ellchangecurve(ch): return the new model (equation) for the elliptic curve e given by the change of coordinates ch.

The change of coordinates is specified by a vector ch=[u,r,s,t]; if $ x'$ and $ y'$ are the new coordinates, then $ x = u^2 x' + r$ and $ y = u^3 y' + su^2 x' + t$ .

Input:

e
- elliptic curve
ch
- change of coordinates vector with 4 entries

sage: e = pari([1,2,3,4,5]).ellinit()
sage: e.ellglobalred()
[10351, [1, -1, 0, -1], 1]
sage: f = e.ellchangecurve([1,-1,0,-1])
sage: f[:5]
[1, -1, 0, 4, 3]

ellchangepoint( )

self.ellchangepoint(y): change data on point or vector of points self on an elliptic curve according to y=[u,r,s,t]

sage: e = pari([0,1,1,-2,0]).ellinit()
sage: x = pari([1,0])
sage: e.ellisoncurve([1,4])
False
sage: e.ellisoncurve(x)
True
sage: f = e.ellchangecurve([1,2,3,-1])
sage: f[:5]   # show only first five entries
[6, -2, -1, 17, 8]
sage: x.ellchangepoint([1,2,3,-1])
[-1, 4]
sage: f.ellisoncurve([-1,4])
True

elleisnum( )

om.elleisnum(k, flag=0, prec): om=[om1,om2] being a 2-component vector giving a basis of a lattice L and k an even positive integer, computes the numerical value of the Eisenstein series of weight k. When flag is non-zero and k=4 or 6, this gives g2 or g3 with the correct normalization.

Input:

om
- gen, 2-component vector giving a basis of a lattice L
k
- int (even positive)
flag
- int (default 0)
pref
- precision

Output:
gen
- numerical value of E_k

sage: e = pari([0,1,1,-2,0]).ellinit()
sage: om = e.omega()
sage: om
[2.490212560855055075321357792, 1.971737701551648204422407698*I]           
# 32-bit
[2.4902125608550550753213577919423024602,
1.9717377015516482044224076981513423349*I]   # 64-bit
sage: om.elleisnum(2)
-5.288649339654257621791534695              # 32-bit
-5.2886493396542576217915346952045657616    # 64-bit
sage: om.elleisnum(4)
112.0000000000000000000000000               # 32-bit
112.00000000000000000000000000000000000     # 64-bit
sage: om.elleisnum(100)
2.153142485760776361127070349 E50              # 32-bit
2.1531424857607763611270703492586704424 E50    # 64-bit

elleta( )

e.elleta(): return the vector [eta1,eta2] of quasi-periods associated with the period lattice e.omega() of the elliptic curve e.

sage: e = pari([0,0,0,-82,0]).ellinit()
sage: e.elleta()
[3.605463601432652085915820564, 10.81639080429795625774746169*I] # 32-bit
[3.6054636014326520859158205642077267748,
10.816390804297956257747461692623180324*I] # 64-bit

ellglobalred( )

e.ellglobalred(): return information related to the global minimal model of the elliptic curve e.

Input:

e
- elliptic curve (returned by ellinit)

Output:
gen
- the (arithmetic) conductor of e
gen
- a vector giving the coordinate change over Q from e to its minimal integral model (see also ellminimalmodel)
gen
- the product of the local Tamagawa numbers of e

sage: e = pari([0, 5, 2, -1, 1]).ellinit()
sage: e.ellglobalred()
[20144, [1, -2, 0, -1], 1]
sage: e = pari(EllipticCurve('17a').a_invariants()).ellinit()
sage: e.ellglobalred()
[17, [1, 0, 0, 0], 4]

ellheight( )

e.ellheight(a, flag=2): return the global N'eron-Tate height of the point a on the elliptic curve e.

Input:

e
- elliptic curve over $ \mathbf{Q}$ , assumed to be in a standard minimal integral model (as given by ellminimalmodel)
a
- rational point on e
flag (optional)
- specifies which algorithm to be used for computing the archimedean local height:
0
- uses sigma- and theta-functions and a trick due to J. Silverman
1
- uses Tate's $ 4^n$ algorithm
2
- uses Mestre's AGM algorithm (this is the default, being faster than the other two)

sage: e = pari([0,1,1,-2,0]).ellinit().ellminimalmodel()[0]
sage: e.ellheight([1,0])
0.4767116593437395373794860589 # 32-bit
0.47671165934373953737948605888465305946 # 64-bit
sage: e.ellheight([1,0], flag=0)
0.4767116593437395373794860589 # 32-bit
0.47671165934373953737948605888465305946 # 64-bit
sage: e.ellheight([1,0], flag=1)
0.4767116593437395373794860589 # 32-bit
0.47671165934373953737948605888465305946 # 64-bit

ellheightmatrix( )

e.ellheightmatrix(x): return the height matrix for the vector x of points on the elliptic curve e.

In other words, it returns the Gram matrix of x with respect to the height bilinear form on e (see ellbil).

Input:

e
- elliptic curve over $ \mathbf{Q}$ , assumed to be in a standard minimal integral model (as given by ellminimalmodel)
x
- vector of rational points on e

sage: e = pari([0,1,1,-2,0]).ellinit().ellminimalmodel()[0]
sage: e.ellheightmatrix([[1,0], [-1,1]])
[0.4767116593437395373794860589, 0.4181889844988605856298894582;
0.4181889844988605856298894582, 0.6866670833055865857235521030] # 32-bit
[0.47671165934373953737948605888465305946,
0.41818898449886058562988945821587638238;
0.41818898449886058562988945821587638238,
0.68666708330558658572355210295409678906] # 64-bit

ellisoncurve( )

e.ellisoncurve(x): return True if the point x is on the elliptic curve e, False otherwise.

If the point or the curve have inexact coefficients, an attempt is made to take this into account.

sage: e = pari([0,1,1,-2,0]).ellinit()
sage: e.ellisoncurve([1,0])
True
sage: e.ellisoncurve([1,1])
False
sage: e.ellisoncurve([1,0.00000000000000001])
False
sage: e.ellisoncurve([1,0.000000000000000001])
True
sage: e.ellisoncurve([0])
True

elllocalred( )

e.elllocalred(p): computes the data of local reduction at the prime p on the elliptic curve e

For more details on local reduction and Kodaira types, see IV.8 and IV.9 in J. Silverman's book "Advanced topics in the arithmetic of elliptic curves".

Input:

e
- elliptic curve with coefficients in $ \mathbf{Z}$
p
- prime number

Output:
gen
- the exponent of p in the arithmetic conductor of e
gen
- the Kodaira type of e at p, encoded as an integer:
1
- type $ I_0$ : good reduction, nonsingular curve of genus 1
2
- type $ II$ : rational curve with a cusp
3
- type $ III$ : two nonsingular rational cuves intersecting tangentially at one point
4
- type $ IV$ : three nonsingular rational curves intersecting at one point
5
- type $ I_1$ : rational curve with a node
6 or larger
- think of it as $ 4+v$ , then it is type $ I_v$ : $ v$ nonsingular rational curves arranged as a $ v$ -gon
-1
- type $ I_0^*$ : nonsingular rational curve of multiplicity two with four nonsingular rational curves of multiplicity one attached
-2
- type $ II^*$ : nine nonsingular rational curves in a special configuration
-3
- type $ III^*$ : eight nonsingular rational curves in a special configuration
-4
- type $ IV^*$ : seven nonsingular rational curves in a special configuration
-5 or smaller
- think of it as $ -4-v$ , then it is type $ I_v^*$ : chain of $ v+1$ nonsingular rational curves of multiplicity two, with two nonsingular rational curves of multiplicity one attached at either end
gen
- a vector with 4 components, giving the coordinate changes done during the local reduction; if the first component is 1, then the equation for e was already minimal at p
gen
- the local Tamagawa number $ c_p$

Type $ I_0$ :

sage: e = pari([0,0,0,0,1]).ellinit()
sage: e.elllocalred(7)
[0, 1, [1, 0, 0, 0], 1]

Type $ II$ :

sage: e = pari(EllipticCurve('27a3').a_invariants()).ellinit()
sage: e.elllocalred(3)
[3, 2, [1, -1, 0, 1], 1]

Type $ III$ :

sage: e = pari(EllipticCurve('24a4').a_invariants()).ellinit()
sage: e.elllocalred(2)
[3, 3, [1, 1, 0, 1], 2]

Type $ IV$ :

sage: e = pari(EllipticCurve('20a2').a_invariants()).ellinit()
sage: e.elllocalred(2)
[2, 4, [1, 1, 0, 1], 3]

Type $ I_1$ :

sage: e = pari(EllipticCurve('11a2').a_invariants()).ellinit()
sage: e.elllocalred(11)
[1, 5, [1, 0, 0, 0], 1]

Type $ I_2$ :

sage: e = pari(EllipticCurve('14a4').a_invariants()).ellinit()
sage: e.elllocalred(2)
[1, 6, [1, 0, 0, 0], 2]

Type $ I_6$ :

sage: e = pari(EllipticCurve('14a1').a_invariants()).ellinit()
sage: e.elllocalred(2)
[1, 10, [1, 0, 0, 0], 2]

Type $ I_0^*$ :

sage: e = pari(EllipticCurve('32a3').a_invariants()).ellinit()
sage: e.elllocalred(2)
[5, -1, [1, 1, 1, 0], 1]

Type $ II^*$ :

sage: e = pari(EllipticCurve('24a5').a_invariants()).ellinit()
sage: e.elllocalred(2)
[3, -2, [1, 2, 1, 4], 1]

Type $ III^*$ :

sage: e = pari(EllipticCurve('24a2').a_invariants()).ellinit()
sage: e.elllocalred(2)
[3, -3, [1, 2, 1, 4], 2]

Type $ IV^*$ :

sage: e = pari(EllipticCurve('20a1').a_invariants()).ellinit()
sage: e.elllocalred(2)
[2, -4, [1, 0, 1, 2], 3]

Type $ I_1^*$ :

sage: e = pari(EllipticCurve('24a1').a_invariants()).ellinit()
sage: e.elllocalred(2)
[3, -5, [1, 0, 1, 2], 4]

Type $ I_6^*$ :

sage: e = pari(EllipticCurve('90c2').a_invariants()).ellinit()
sage: e.elllocalred(3)
[2, -10, [1, 96, 1, 316], 4]

elllseries( )

e.elllseries(s, A=1): return the value of the $ L$ -series of the elliptic curve e at the complex number s.

This uses an $ O(N^{1/2})$ algorithm in the conductor N of e, so it is impractical for large conductors (say greater than $ 10^{12}$ ).

Input:

e
- elliptic curve defined over $ \mathbf{Q}$
s
- complex number
A (optional)
- cutoff point for the integral, which must be chosen close to 1 for best speed.

sage: e = pari([0,1,1,-2,0]).ellinit()
sage: e.elllseries(2.1)
0.4028380479566455155
sage: e.elllseries(1)   # random, close to 0
-3.241361318972148540775276458 E-29
sage: e.elllseries(-2)
0

The following example differs for the last digit on 32 vs. 64 bit systems

sage: e.elllseries(2.1, A=1.1)
0.402838047956645515...

ellminimalmodel( )

ellminimalmodel(e): return the standard minimal integral model of the rational elliptic curve e and the corresponding change of variables. Input:

e
- gen (that defines an elliptic curve)
Output:
gen
- minimal model
gen
- change of coordinates

sage: e = pari([1,2,3,4,5]).ellinit()
sage: F, ch = e.ellminimalmodel()
sage: F[:5]
[1, -1, 0, 4, 3]
sage: ch
[1, -1, 0, -1]
sage: e.ellchangecurve(ch)[:5]
[1, -1, 0, 4, 3]

ellorder( )

e.ellorder(x): return the order of the point x on the elliptic curve e (return 0 if x is not a torsion point)

Input:

e
- elliptic curve defined over $ \mathbf{Q}$
x
- point on e

sage: e = pari(EllipticCurve('65a1').a_invariants()).ellinit()

A point of order two:

sage: e.ellorder([0,0])
2

And a point of infinite order:

sage: e.ellorder([1,0])
0

ellordinate( )

e.ellordinate(x): return the $ y$ -coordinates of the points on the elliptic curve e having x as $ x$ -coordinate.

Input:

e
- elliptic curve
x
- x-coordinate (can be a complex or p-adic number, or a more complicated object like a power series)

sage: e = pari([0,1,1,-2,0]).ellinit()
sage: e.ellordinate(0)
[0, -1]
sage: e.ellordinate(I)
[0.5822035897217411772333894787 - 1.386060824641769718531183421*I,
-1.582203589721741177233389479 + 1.386060824641769718531183421*I] # 32-bit
[0.58220358972174117723338947874993600727 -
1.3860608246417697185311834209833653345*I,
-1.5822035897217411772333894787499360073 +
1.3860608246417697185311834209833653345*I] # 64-bit
sage: e.ellordinate(1+3*5^1+O(5^3))
[4*5 + 5^2 + O(5^3), 4 + 3*5^2 + O(5^3)]
sage: e.ellordinate('z+2*z^2+O(z^4)')
[-2*z - 7*z^2 - 23*z^3 + O(z^4), -1 + 2*z + 7*z^2 + 23*z^3 + O(z^4)]

ellpointtoz( )

e.ellpointtoz(P): return the complex number (in the fundamental parallelogram) corresponding to the point P on the elliptic curve e, under the complex uniformization of e given by the Weierstrass p-function.

The complex number z returned by this function lies in the parallelogram formed by the real and complex periods of e, as given by e.omega().

sage: e = pari([0,0,0,1,0]).ellinit()
sage: e.ellpointtoz([0,0])
1.854074677301371918433850347 # 32-bit
1.8540746773013719184338503471952600462 # 64-bit

The point at infinity is sent to the complex number 0:

sage: e.ellpointtoz([0])
0

ellpow( )

e.ellpow(z, n): return n times the point z on the elliptic curve e.

Input:

e
- elliptic curve
z
- point on e
n
- integer, or a complex quadratic integer of complex multiplication for e (CM case is currently broken in pari)

We consider a CM curve:

sage: e = pari([0,0,0,1,0]).ellinit()

Multiplication by two:

sage: e.ellpow([0,0], 2)
[0]

Complex multiplication (this is broken at the moment):

sage: e.ellpow([0,0], I+1) # optional

ellrootno( )

e.ellrootno(p): return the (local or global) root number of the $ L$ -series of the elliptic curve e

If p is a prime number, the local root number at p is returned. If p is 1, the global root number is returned. Note that the global root number is the sign of the functional equation of the $ L$ -series, and therefore conjecturally equal to the parity of the rank of e.

Input:

e
- elliptic curve over $ \mathbf{Q}$
p (default = 1)
- 1 or a prime number

Output: 1 or -1

Here is a curve of rank 3:

sage: e = pari([0,0,0,-82,0]).ellinit()
sage: e.ellrootno()
-1
sage: e.ellrootno(2)
1
sage: e.ellrootno(1009)
1

ellsigma( )

e.ellsigma(z, flag=0): return the value at the complex point z of the Weierstrass $ \sigma$ function associated to the elliptic curve e.

ellsub( )

e.ellsub(z0, z1): return z0-z1 on this elliptic curve.

Input:

e
- elliptic curve E
z0
- point on E
z1
- point on E

Output: point on E

sage: e = pari([0, 1, 1, -2, 0]).ellinit()
sage: e.ellsub([1,0], [-1,1])
[0, 0]

elltors( )

e.elltors(flag = 0): return information about the torsion subgroup of the elliptic curve e

Input:

e
- elliptic curve over