abs,
acos,
acosh,
agm,
arg,
asin,
asinh,
atan,
atanh,
bernfrac,
bernreal,
bernvec,
besselh1,
besselh2,
besseli,
besselj,
besseljh,
besselk,
besselk2,
besseln,
binary,
bitand,
bitneg,
bitnegimply,
bitor,
bittest,
bitxor,
ceil,
centerlift,
changevar,
charpoly,
Col,
component,
conj,
conjvec,
cos,
cosh,
cotan,
denominator,
dilog,
disc,
divrem,
eint1,
elladd,
ellak,
ellan,
ellap,
ellbil,
ellchangecurve,
ellchangepoint,
elleisnum,
ellheightmatrix,
ellminimalmodel,
ellwp,
erfc,
eta,
exp,
factor,
factorpadic,
floor,
frac,
gamma,
gammah,
hyperu,
imag,
incgam,
incgamc,
int_unsafe,
intformal,
intvec_unsafe,
isprime,
j,
length,
lex,
lift,
List,
list_str,
lngamma,
log,
Mat,
mathnf,
max,
min,
Mod,
nextprime,
numerator,
numtoperm,
omega,
padicappr,
padicprec,
permtonum,
Pol,
polcoeff,
poldegree,
poldisc,
polgalois,
polhensellift,
polinterpolate,
polisirreducible,
pollead,
Polrev,
polroots,
polylog,
precision,
psi,
python,
python_list,
Qfb,
random,
real,
reverse,
rnfinit,
round,
Ser,
serreverse,
Set,
shift,
shiftmul,
sign,
simplify,
sin,
sinh,
sizebyte,
sizedigit,
sqr,
sqrt,
sqrtn,
Str,
Strchr,
Strexpand,
Strtex,
subst,
tan,
tanh,
teichmuller,
theta,
thetanullk,
truncate,
valuation,
variable,
Vec,
vecmax,
vecmin,
Vecsmall,
weber,
zeta
These methods are defined as follows:
) |
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
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
) |
The principal branch of
, so that
belongs to
. If
is real and
,
then
is complex.
sage: pari(0.5).acos() 1.047197551196597746154214461 sage: pari(1.1).acos() -0.4435682543851151891329110664*I sage: pari('1.1+I').acos() 0.8493430542452523259630143655 - 1.097709866825328614547942343*I
) |
The principal branch of
, so that
belongs to
. If
is real and
, then
is complex.
sage: pari(2).acosh() 1.316957896924816708625046347 sage: pari(0).acosh() 1.570796326794896619231321692*I sage: pari('I').acosh() 0.8813735870195430252326093250 + 1.570796326794896619231321692*I
) |
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 sage: pari('0').agm(1) 0 sage: pari('1').agm(2) 1.456791031046906869186432383 sage: pari('1+I').agm(-3) -0.9647317222908759112270275373 + 1.157002829526317260939086019*I
) |
arg(x): argument of x,such that
.
sage: pari('2+I').arg() 0.4636476090008061162142562315
) |
The principal branch of
, so that
belongs to
. If
is real
and
then
is complex.
sage: pari(pari(0.5).sin()).asin() 0.5000000000000000000000000000 sage: pari(2).asin() 1.570796326794896619231321692 + 1.316957896924816708625046347*I
) |
The principal branch of
, so that
belongs
to
.
sage: pari(2).asinh() 1.443635475178810342493276740 sage: pari('2+I').asinh() 1.528570919480998161272456185 + 0.4270785863924761254806468833*I
) |
The principal branch of
, so that
belongs
to
.
sage: pari(1).atan() 0.7853981633974483096156608458 sage: pari('1.5+I').atan() 1.107148717794090503017065460 + 0.2554128118829953416027570481*I
) |
The principal branch of
, so that
belongs to
. If
is real
and
then
is complex.
sage: pari(0).atanh() 0.E-28 sage: pari(2).atanh() 0.5493061443340548456976226185 + 1.570796326794896619231321692*I
) |
The Bernoulli number
, where
,
,
expressed as a rational number. The
argument
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]
) |
The Bernoulli number
, as for the function bernfrac, but
is returned as a real number (with the current
precision).
sage: pari(18).bernreal() 54.97117794486215538847117794
) |
Creates a vector containing, as rational numbers, the
Bernoulli numbers
. 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]
) |
The
-Bessel function of index
and argument
.
sage: pari(2).besselh1(3) 0.4860912605858910769078310941 - 0.1604003934849237296757682995*I
) |
The
-Bessel function of index
and argument
.
sage: pari(2).besselh2(3) 0.4860912605858910769078310941 + 0.1604003934849237296757682995*I
) |
Bessel I function (Bessel function of the second kind), with
index
and argument
. If
converts to a power
series, the initial factor
is
omitted (since it cannot be represented in PARI when
is not
integral).
sage: pari(2).besseli(3) 2.245212440929951154625478386 sage: pari(2).besseli('3+I') 1.125394076139128134398383103 + 2.083138226706609118835787255*I
) |
Bessel J function (Bessel function of the first kind), with
index
and argument
. If
converts to a power
series, the initial factor
is
omitted (since it cannot be represented in PARI when
is not
integral).
sage: pari(2).besselj(3) 0.4860912605858910769078310941
) |
J-Bessel function of half integral index (Speherical Bessel
function of the first kind). More precisely, besseljh(n,x)
computes
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
is small.
sage: pari(2).besseljh(3) 0.4127100322097159935594550689
) |
K-Bessel function (modified Bessel function of the second kind) of index nu, which can be complex, and argument x. Only positive real positive arguments x are allowed in the current implementation (Pari version 2.2.11).
sage: pari('2+I').besselk(3) 0.04559077184075505871203211094 + 0.02891929465820812820828883526*I
) |
A different implementation of this besselk() which is faster when x » 1. Values of x are limited as for besselk().
sage: pari('2+I').besselk2(3) 0.04559077184075505871203211094 + 0.02891929465820812820828883526*I
) |
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
) |
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.
) |
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(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
.
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(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(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(x, long n): Returns bit number n (coefficient of
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(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
) |
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 sage: pari('3/4').ceil() 1
) |
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(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(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(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]~ 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(x, long n): Return n'th component of the internal representation of x. This 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): ... RuntimeError
) |
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): ... TypeError: x (=Mod(x, x^3 - 3)) has no conjugate.
) |
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]~ sage: pari('Mod(x,x^3-3)').conjvec() [1.442249570307408382321638311, -0.7211247851537041911608191554 + 1.249024766483406479413179544*I, -0.7211247851537041911608191554 - 1.249024766483406479413179544*I]~
) |
The cosine function.
sage: x = pari('1.5') sage: x.cos() 0.07073720166770291008818985142 sage: pari('1+I').cos() 0.8337300251311490488838853943 - 0.9888977057628650963821295409*I 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)
) |
The hyperbolic cosine function.
sage: x = pari('1.5') sage: x.cosh() 2.352409615243247325767667965 sage: pari('1+I').cosh() 0.8337300251311490488838853943 + 0.9888977057628650963821295409*I sage: pari('x+O(x^8)').cosh() 1 + 1/2*x^2 + 1/24*x^4 + 1/720*x^6 + O(x^8)
) |
The cotangent of x.
sage: pari(5).cotan() -0.2958129155327455404277671681
Note that cotangent of pi doesn't raise an error, but instead just returns a very large number:
sage: pari('Pi').cotan() 1.980704063 E28
) |
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
) |
The principal branch of the dilogarithm of
, i.e. the analytic
continuation of the power series
.
sage: pari(1).dilog() 1.644934066848226436472415167 sage: pari('1+I').dilog() 0.6168502750680849136771556876 + 1.460362116753119547679775739*I
) |
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(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).
sage:
) |
x.eint1(n): exponential integral E1(x):
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(self, z0, z1)
Sum of the points z0 and z1 on this elliptic curve.
INPUT: self -- 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,1,1]) [-3/4, -15/8]
) |
e.ellak(n): Returns the coefficient
of the
-function of
the elliptic curve e, i.e. the coefficient of a newform of
weight 2 newform.
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
) |
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) []
) |
e.ellap(p): Returns the prime-indexed coefficient
of the
-function of the elliptic curve
, i.e. the coefficient of a
newform of weight 2 newform.
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. 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
) |
sage: e = pari([0,1,1,-2,0]).ellinit() sage: e.ellbil([1, 0, 1], [-1, 1, 1]) 0.4181889844988605856298894585
) |
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]
) |
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,1]) sage: e.ellisoncurve([1,4,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
) |
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] sage: om.elleisnum(2) -5.288649339654257621791534695 sage: om.elleisnum(4) 112.0000000000000000000000000 sage: om.elleisnum(100) 2.153142485760776361127070332 E50
) |
ellheightmatrix(e,x)
Returns the height matrix for vector of points x on elliptic curve e using theta functions.
) |
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]
) |
ellwp(E, z,flag=0): Return the complex value of the Weierstrass P-function at z on the lattice defined by e.
INPUT: E -- list OR elliptic curve list -- [om1, om2], which are Z-generators for a lattice elliptic curve -- created using ellinit z -- (optional) complex number OR string (default = "z") complex number -- any number in the complex plane string (or PARI variable) -- name of a variable. n -- int (optional: default 20) if z is a variable, compute up to at least o(z^n). flag -- int: 0 (default): compute only P(z) 1 compute [P(z),P'(z)] 2 consider om or E as an elliptic curve and use P-function to compute the point on E (with the Weierstrass equation for E) P(z) for that curve (identical to ellztopoint in this case). OUTPUT: gen -- complex number or list of two complex numbers
We first define the elliptic curve X_0(11):
sage: E = pari([0,-1,1,-10,-20]).ellinit()
Compute P(1).
sage: E.ellwp(1) 13.96586952574849779469497769 + 2.660659330 E-28*I
Compute P(1+I), where I = sqrt(-1).
sage: E.ellwp(pari("1+I")) -1.115106825655550879209066487 + 2.334190523074698836184798800*I sage: E.ellwp("1+I") -1.115106825655550879209066487 + 2.334190523074698836184798800*I
The series expansion, to the default 20 precision:
sage: E.ellwp() z^-2 + 31/15*z^2 + 2501/756*z^4 + 961/675*z^6 + 77531/41580*z^8 + 1202285717/928746000*z^10 + 2403461/2806650*z^12 + 30211462703/43418875500*z^14 + 3539374016033/7723451736000*z^16 + 413306031683977/1289540602350000*z^18 + O(z^20)
Compute the series for wp to lower precision:
sage: E.ellwp(n=4) z^-2 + 31/15*z^2 + O(z^4)
Next we use the version where the input is generators for a lattice:
sage: pari([1.2692, '0.63 + 1.45*I']).ellwp(1) 13.96561469366894364802003736 + 0.0006448292728105361474541635979*I
With flag 1 compute the pair P(z) and P'(z):
sage: E.ellwp(1, flag=1) [13.96586952574849779469497769 + 2.660659330 E-28*I, 50.56193008800727525558465689 + 1.615587134 E-27*I]
With flag=2, the computed pair is (x,y) on the curve instead of [P(z),P'(z)]:
sage: E.ellwp(1, flag=2) [14.29920285908183112802831103 + 2.660659330 E-28*I, 50.06193008800727525558465689 + 1.615587134 E-27*I]
) |
Return the complementary error function:
sage: pari(1).erfc() 0.1572992070502851306587793649
) |
x.eta(flag=0): if flag=0,
function without the
,
otherwise
of the complex number
in the upper half plane
intelligently computed using
transformations.
DETAILS: This functions computes the following. If the input
is a complex number with positive imaginary part, the
result is
, where
. If
is a power series (or can be converted to a power
series) with positive valuation, the result it
.
sage: pari('I').eta() 0.9981290699259585132799623222
) |
x.exp(): exponential of x.
sage: pari(0).exp() 1.000000000000000000000000000 sage: pari(1).exp() 2.718281828459045235360287471 sage: pari('x+O(x^8)').exp() 1 + x + 1/2*x^2 + 1/6*x^3 + 1/24*x^4 + 1/120*x^5 + 1/720*x^6 + 1/5040*x^7 + O(x^8)
) |
factor(x,lim): factorization of x. lim is optional and can be set whenever x is of (possibly recursive) rational type. If lim is set return partial factorization, using primes up to lim (up to primelimit if lim=0)
) |
self.factorpadic(p,r=20,flag=0): p-adic factorization of the polynomial x to precision r. flag is optional and may be set to 0 (use round 4) or 1 (use Buchmann-Lenstra)
) |
floor(x): Return the floor of x, which is the largest integer <= x. This function also works component-wise on polynomials, vectors, etc.
INPUT: x -- gen OUTPUT: gen
sage: pari('5/9').floor() 0 sage: pari('11/9').floor() 1 sage: pari('1.17').floor() 1 sage: pari('x').floor() x sage: pari('x+1.5').floor() x + 1.500000000000000000000000000 sage: pari('[1.5,2.3,4.99]').floor() [1, 2, 4] sage: pari('[[1.1,2.2],[3.3,4.4]]').floor() [[1, 2], [3, 4]]
sage: pari('"hello world"').floor() Traceback (most recent call last): ... TypeError: x (=hello world) has no floor.
) |
frac(x): Return the fractional part of x, which is x - floor(x).
INPUT: x -- gen OUTPUT: gen
sage: pari('1.7').frac() 0.7000000000000000000000000000 sage: pari('sqrt(2)').frac() 0.4142135623730950488016887242
sage: pari('sqrt(-2)').frac() Traceback (most recent call last): ... TypeError: Fractional part of 1.4142135623730950488016887242*I not defined.
) |
s.gamma(precision): Gamma function at s.
INPUT: s -- gen (real or complex number precision -- optional precisiion OUTPUT: gen -- value of the Gamma function at s.
sage: pari(2).gamma() 1.000000000000000000000000000 sage: pari(5).gamma() 24.00000000000000000000000000 sage: pari('1+I').gamma() 0.4980156681183560427136911175 - 0.1549498283018106851249551305*I
) |
x.gammah(): Gamma function evaluated at the argument x+1/2, for x an integer.
sage: pari(2).gammah() 1.329340388179137020473625612 sage: pari(5).gammah() 52.34277778455352018114900849 sage: pari('1+I').gammah() 0.5753151880634517207185443722 + 0.08821067754409390991246464371*I
) |
a.hyperu(b,x): U-confluent hypergeometric function.
sage: pari(1).hyperu(2,3) 0.3333333333333333333333333333
) |
imag(x): Return the imaginary part of x. This function also works component-wise.
INPUT: x -- gen OUTPUT: gen
sage: pari('1+2*I').imag() 2 sage: pari('sqrt(-2)').imag() 1.414213562373095048801688724 sage: pari('x+I').imag() 1 sage: pari('x+2*I').imag() 2 sage: pari('(1+I)*x^2+2*I').imag() x^2 + 2 sage: pari('[1,2,3] + [4*I,5,6]').imag() [4, 0, 0]
) |
s.incgam(x, y, precision): incomplete gamma function. y is optional and is the precomputed value of gamma(s).
NOTE: This function works for any complex input (unlike in older version of PARI).
INPUT: s, x, y -- gens precision -- option precision OUTPUT: gen -- value of the incomplete Gamma function at s.
sage: pari('1+I').incgam('3-I') -0.04582978599199457259586742327 + 0.04336968187266766812050474477*I
) |
s.incgamc(x): complementary incomplete gamma function.
The arguments
and
are complex numbers such that
is
not a pole of
and
is not much larger
than
(otherwise, the convergence is very slow). The
function returns the value of the integral
sage: pari(1).incgamc(2) 0.8646647167633873081060005048
) |
Returns int form of self, but raises an exception if int does not fit into a long integer.
This is about 5 times faster than the usual int conversion.
) |
x.intformal(y): formal integration of x with respect to the main variable of y, or to the main variable of x if y is omitted
) |
Returns Python int list form of entries of self, but raises an exception if int does not fit into a long integer. Here self must be a vector.
) |
isprime(x, flag=0): Returns True if x is a PROVEN prime number, and False otherwise.
INPUT: flag -- int 0 (default): use a combination of algorithms. 1: certify primality using the Pocklington-Lehmer Test. 2: certify primality using the APRCL test. OUTPUT: bool -- True or False
sage: pari(9).isprime() False sage: pari(17).isprime() True sage: n = pari(561) # smallest Carmichael number sage: n.isprime() # not just a pseudo-primality test! False sage: n.isprime(1) False sage: n.isprime(2) False
) |
e.j(): return the j-invariant of the elliptic curve e.
sage: e = pari([0, -1, 1, -10, -20]).ellinit() sage: e.j() -122023936/161051 sage: _.factor() [-1, 1; 2, 12; 11, -5; 31, 3]
) |
length(x): Return the number of non-code words in x. If x is a string, this is the number of characters of x.
?? terminator ?? carriage return ??
) |
lex(x,y): Compare x and y lexicographically (1 if x>y, 0 if x==y, -1 if x<y)
) |
lift(x,v): Returns the lift of an element of Z/nZ to Z or R[x]/(P) to R[x] for a type R if v is omitted. If v is given, lift only polymods with main variable v. If v does not occur in x, lift only intmods.
INPUT: x -- gen v -- (optional) variable OUTPUT: gen
sage: x = pari("x") sage: a = x.Mod(x**3 + 17*x + 3) sage: a Mod(x, x^3 + 17*x + 3) sage: b = a**4; b Mod(-17*x^2 - 3*x, x^3 + 17*x + 3) sage: b.lift() -17*x^2 - 3*x
??? more examples
) |
List(x): transforms the PARI vector or list x into a list.
sage: v = pari([1,2,3]) sage: v [1, 2, 3] sage: v.type() 't_VEC' sage: w = v.List() sage: w List([1, 2, 3]) sage: w.type() 't_LIST'
) |
Return str that might correctly evaluate to a Python-list.
) |
x.lngamma(): logarithm of the gamma function of x.
This function returns the principal branch of the logarithm of
the gamma function of
. The function
is
analytic on the complex plane with non-positive integers
removed. This function can have much larger inputs than
itself.
The
-adic analogue of this function is unfortunately not
implemented.
sage: pari(100).lngamma() 359.1342053695753987760440105
) |
x.log(): natural logarithm of x.
This function returns the principal branch of the natural
logarithm of
, i.e., the branch such that
The result is complex (with imaginary part equal
to
) if
and
. In general, the algorithm
uses the formula
if
Note that
-adic arguments can also be given as input,
with the convention that
. Hence, in
particular,
is not in general
equal to
but instead to a
root of
unity (or
if
) times a power of
.
sage: pari(5).log() 1.609437912434100374600759333 sage: pari('I').log() 0.E-29 + 1.570796326794896619231321692*I
) |
Mat(x): Returns the matrix defined by x.
* If x is already a matrix, a copy of x is created and returned.
* If x is not a vector or a matrix, this function returns a 1x1 matrix.
* If x is a row (resp. column) vector, this functions returns a 1-row (resp. 1-column) matrix, *unless* all elements are column (resp. row) vectors of the same length, in which case the vectors are concatenated sideways and the associated big matrix is returned.
INPUT: x -- gen OUTPUT: gen -- a PARI matrix
sage: x = pari(5) sage: x.type() 't_INT' sage: y = x.Mat() sage: y Mat(5) sage: y.type() 't_MAT' sage: x = pari('[1,2;3,4]') sage: x.type() 't_MAT' sage: x = pari('[1,2,3,4]') sage: x.type() 't_VEC' sage: y = x.Mat() sage: y Mat([1, 2, 3, 4]) sage: y.type() 't_MAT'
sage: v = pari('[1,2;3,4]').Vec(); v [[1, 3]~, [2, 4]~] sage: v.Mat() [1, 2; 3, 4] sage: v = pari('[1,2;3,4]').Col(); v [[1, 2], [3, 4]]~ sage: v.Mat() [1, 2; 3, 4]
) |
mathnf(A,flag=0): (upper triangular) Hermite normal form of A, basis for the lattice formed by the columns of A. flag is optional whose value range from 0 to 4 (0 if omitted), meaning : 0: naive algorithm. 1: Use Batut's algorithm. Output 2-component vector [H,U] such that H is the HNF of A, and U is a unimodular matrix such that xU=H. 3: Use Batut's algorithm. Output [H,U,P] where P is a permutation matrix such that P A U = H. 4: as 1, using a heuristic variant of LLL reduction along the way.
) |
max(x,y): Return the maximum of x and y.
) |
min(x,y): Return the minumum of x and y.
) |
Mod(x, y): Returns the object x modulo y, denoted Mod(x, y).
The input y must be a an integer or a polynomial:
* If y is an INTEGER, x must also be an integer, a rational number, or a p-adic number compatible with the modulus y.
* If y is a POLYNOMIAL, x must be a scalar (which is not a polmod), a polynomial, a rational function, or a power series.
WARNING: This function is not the same as x which is an integer or a polynomial.
INPUT: x -- gen y -- integer or polynomial OUTPUT: gen -- intmod or polmod
sage: z = pari(3) sage: x = z.Mod(pari(7)) sage: x Mod(3, 7) sage: x**2 Mod(2, 7) sage: x**100 Mod(4, 7) sage: x.type() 't_INTMOD'
sage: f = pari("x^2 + x + 1") sage: g = pari("x") sage: a = g.Mod(f) sage: a Mod(x, x^2 + x + 1) sage: a*a Mod(-x - 1, x^2 + x + 1) sage: a.type() 't_POLMOD'
) |
nextprime(x): smallest pseudoprime >= x
) |
numerator(x): Returns the numerator of x.
INPUT: x -- gen OUTPUT: gen
) |
numtoperm(k, n): Return the permutation number k (mod n!) of n letters, where n is an integer.
INPUT: k -- gen, integer n -- int OUTPUT: gen -- vector (permutation of {1,...,n})
) |
e.omega(): return basis for the period lattice of the elliptic curve e.
sage: e = pari([0, -1, 1, -10, -20]).ellinit() sage: e.omega() [1.269209304279553421688794617, 0.6346046521397767108443973084 + 1.458816616938495229330889612*I]
) |
x.padicappr(a): p-adic roots of the polynomial x congruent to a mod p
) |
padicprec(x,p): Return the absolute p-adic precision of the object x.
INPUT: x -- gen OUTPUT: int
) |
permtonum(x): Return the ordinal (between 1 and n!) of permutation vector x. ??? Huh ??? say more. what is a perm vector. 0 to n-1 or 1-n.
INPUT: x -- gen (vector of integers) OUTPUT: gen -- integer
) |
Pol(x, v): convert x into a polynomial with main variable v and return the result.
* If x is a scalar, returns a constant polynomial.
* If x is a power series, the effect is identical
to kbdtruncate, i.e. it chops off the
.
* If x is a vector, this function creates the polynomial whose coefficients are given in x, with x[0] being the leading coefficient (which can be zero).
WARNING: This is *not* a substitution function. It will not transform an object containing variables of higher priority than v:
sage: pari('x+y').Pol('y') Traceback (most recent call last): ... RuntimeError: PARI error 8: error in Pol
INPUT: x -- gen v -- (optional) which variable, defaults to 'x' OUTPUT: gen -- a polynomial
sage: v = pari("[1,2,3,4]") sage: f = v.Pol() sage: f x^3 + 2*x^2 + 3*x + 4 sage: f*f x^6 + 4*x^5 + 10*x^4 + 20*x^3 + 25*x^2 + 24*x + 16
sage: v = pari("[1,2;3,4]") sage: v.Pol() [1, 3]~*x + [2, 4]~
) |
sage: f = pari("x^2 + y^3 + x*y") sage: f x^2 + y*x + y^3 sage: f.polcoeff(1) y sage: f.polcoeff(3) 0 sage: f.polcoeff(3, "y") 1 sage: f.polcoeff(1, "y") x
) |
f.poldegree(var=x): Return the degree of this polynomial.
) |
f.poldist(var=x): Return the discriminant of this polynomial.
) |
f.polgalois(): Galois group of the polynomial f
) |
self.polhensellift(factors, p, e): lift the factorization y of
self modulo p to a factorization modulo
using Hensel
lift. The factors in y must be pairwise relatively prime
modulo p.
) |
self.polinterpolate(ya,x,&e): polynomial interpolation at x according to data vectors self, ya (i.e. return P such that P(self[i]) = ya[i] for all i). Also return an error estimate on the returned value.
) |
f.polisirreducible(): Returns True if f is an irreducible non-constant polynomial, or False if f is reducible or constant.
) |
self.pollead(v): leading coefficient of polynomial or series self, or self itself if self is a scalar. Error otherwise. With respect to the main variable of self if v is omitted, with respect to the variable v otherwise
) |
Polrev(x, v): Convert x into a polynomial with main variable v and return the result. This is the reverse of Pol if x is a vector, otherwise it is identical to Pol. By "reverse" we mean that the coefficients are reversed.
INPUT: x -- gen OUTPUT: gen -- a polynomial
sage: v = pari("[1,2,3,4]") sage: f = v.Polrev() sage: f 4*x^3 + 3*x^2 + 2*x + 1 sage: v.Pol() x^3 + 2*x^2 + 3*x + 4 sage: v.Polrev('y') 4*y^3 + 3*y^2 + 2*y + 1
Note that Polrev does *not* reverse the coefficients of a polynomial!
sage: f 4*x^3 + 3*x^2 + 2*x + 1 sage: f.Polrev() 4*x^3 + 3*x^2 + 2*x + 1 sage: v = pari("[1,2;3,4]") sage: v.Polrev() [2, 4]~*x + [1, 3]~
) |
polroots(x,flag=0): complex roots of the polynomial x. flag is optional, and can be 0: default, uses Schonhage's method modified by Gourdon, or 1: uses a modified Newton method.
) |
x.polylog(m,flag=0): m-th polylogarithm of x. flag is optional, and can be 0: default, 1: D_m -modified m-th polylog of x, 2: D_m-modified m-th polylog of x, 3: P_m-modified m-th polylog of x.
TODO: Add more explanation, copied from the PARI manual.
sage: pari(10).polylog(3) 5.641811414751341250600725771 - 8.328202076980270580884185851*I sage: pari(10).polylog(3,0) 5.641811414751341250600725771 - 8.328202076980270580884185851*I sage: pari(10).polylog(3,1) 0.5237784535024110488342571115 sage: pari(10).polylog(3,2) -0.4004590561634505605364328953
) |
precision(x,n): Change the precision of x to be n, where n is a C-integer). If n is omitted, output the real precision of x.
INPUT: x -- gen n -- (optional) int OUTPUT: nothing or gen if n is omitted
) |
x.psi(): psi-function at x.
Return the
-function of
, i.e., the logarithmic
derivative
.
sage: pari(1).psi() -0.5772156649015328606065120901
) |
Return Python eval of self.
) |
Return a Python list of the PARI gens. This object must be of type t_VEC
INPUT: None OUTPUT: list -- Python list whose elements are the elements of the input gen.
sage: v=pari([1,2,3,10,102,10]) sage: w = v.python_list() sage: w [1, 2, 3, 10, 102, 10] sage: type(w[0]) <type 'gen.gen'>
) |
Qfb(a,b,c,D=0.): Returns the binary quadratic form
The optional D is 0 by default and initializes Shanks's distance if
NOTE: Negative definite forms are not implemented, so use their positive definitine counterparts instead. (I.e., if f is a negative definite quadratic form, then -f is positive definite.)
INPUT: a -- gen b -- gen c -- gen D -- gen (optional, defaults to 0) OUTPUT: gen -- binary quadratic form
sage: pari(3).Qfb(7, 2) Qfb(3, 7, 2, 0.E-28)
) |
random({N=
: Return a pseudo-random integer between 0 and
})
.
INPUT: N -- gen, integer OUTPUT: gen -- integer
) |
real(x): Return the real part of x.
INPUT: x -- gen OUTPUT: gen
) |
Return the polynomial obtained by reversing the coefficients of this polynomial.
) |
We construct a relative number field.
sage: f = pari('y^3+y+1') sage: K = f.nfinit() sage: x = pari('x'); y = pari('y') sage: g = x**5 - x**2 + y sage: L = K.rnfinit(g)
) |
round(x,estimat=False): If x is a real number, returns x rounded to the nearest integer (rounding up). If the optional argument estimate is True, also returns the binary exponent e of the difference between the original and the rounded value (the "fractional part") (this is the integer ceiling of log_2(error)).
When x is a general PARI object, this function returns the result of rounding every coefficient at every level of PARI object. Note that this is different than what the truncate function does (see the example below).
One use of round is to get exact results after a long approximate computation, when theory tells you that the coefficients must be integers.
INPUT: x -- gen estimate -- (optional) bool, False by default OUTPUT: * if estimate == False, return a single gen. * if estimate == True, return rounded verison of x and error estimate in bits, both as gens.
sage: pari('1.5').round() 2 sage: pari('1.5').round(True) (2, -1) sage: pari('1.5 + 2.1*I').round() 2 + 2*I sage: pari('1.0001').round(True) (1, -14) sage: pari('(2.4*x^2 - 1.7)/x').round() (2*x^2 - 2)/x sage: pari('(2.4*x^2 - 1.7)/x').truncate() 2.400000000000000000000000000*x
) |
Ser(x,v=x): Create a power series from x with main variable v and return the result.
* If x is a scalar, this gives a constant power series with precision given by the default series precision, as returned by get_series_precision().
* If x is a polynomial, the precision is the greatest of get_series_precision() and the degree of the polynomial.
* If x is a vector, the precision is similarly given, and the coefficients of the vector are understood to be the coefficients of the power series starting from the constant term (i.e. the reverse of the function Pol).
WARNING: This is *not* a substitution function. It will not transform an object containing variables of higher priority than v.
INPUT: x -- gen v -- PARI variable (default: x) OUTPUT: gen -- PARI object of PARI type t_SER
sage: pari(2).Ser() 2 + O(x^16) sage: x = pari([1,2,3,4,5]) sage: x.Ser() 1 + 2*x + 3*x^2 + 4*x^3 + 5*x^4 + O(x^5) sage: f = x.Ser('v'); print f 1 + 2*v + 3*v^2 + 4*v^3 + 5*v^4 + O(v^5) sage: pari(1)/f 1 - 2*v + v^2 + O(v^5) sage: pari(1).Ser() 1 + O(x^16)
) |
serreverse(f): reversion of the power series f.
If f(t) is a series in t with valuation 1, find the series g(t) such that g(f(t)) = t.
) |
Set(x): convert x into a set, i.e. a row vector of strings in increasing lexicographic order.
INPUT: x -- gen OUTPUT: gen -- a vector of strings in increasing lexicographic order.
sage: pari([1,5,2]).Set() ["1", "2", "5"] sage: pari([]).Set() # the empty set [] sage: pari([1,1,-1,-1,3,3]).Set() ["-1", "1", "3"] sage: pari(1).Set() ["1"] sage: pari('1/(x*y)').Set() ["1/(y*x)"] sage: pari('["bc","ab","bc"]').Set() ["ab", "bc"]
) |
shift(x,n): shift x left n bits if n>=0, right -n bits if n<0.
) |
shiftmul(x,n): Return the product of x by
.
) |
sign(x): Return the sign of x, where x is of type integer, real or fraction.
) |
simplify(x): Simplify the object x as much as possible, and return the result.
A complex or quadratic number whose imaginary part is an exact 0 (i.e., not an approximate one such as O(3) or 0.E-28) is converted to its real part, and a a polynomial of degree 0 is converted to its constant term. Simplification occurs recursively.
This function is useful before using arithmetic functions, which expect integer arguments:
sage: y = pari('y') sage: x = pari('9') + y - y sage: x 9 sage: x.type() 't_POL' sage: x.factor() matrix(0,2) sage: pari('9').factor() Mat([3, 2]) sage: x.simplify() 9 sage: x.simplify().factor() Mat([3, 2]) sage: x = pari('1.5 + 0*I') sage: x.type() 't_COMPLEX' sage: x.simplify() 1.500000000000000000000000000 sage: y = x.simplify() sage: y.type() 't_REAL'
) |
x.sin(): The sine of x.
sage: pari(1).sin() 0.8414709848078965066525023216 sage: pari('1+I').sin() 1.298457581415977294826042366 + 0.6349639147847361082550822030*I
) |
The hyperbolic sine function.
sage: pari(0).sinh() 0.E-28 sage: pari('1+I').sinh() 0.6349639147847361082550822030 + 1.298457581415977294826042366*I
) |
sizebyte(x): Return the total number of bytes occupied by the complete tree of the object x.
INPUT: x -- gen OUTPUT: int (a Python int)
sage: pari('1').sizebyte() 12 sage: pari('10').sizebyte() 12 sage: pari('10000000000000').sizebyte() 16 sage: pari('10^100').sizebyte() 52 sage: pari('x').sizebyte() 36 sage: pari('x^20').sizebyte() 264 sage: pari('[x, 10^100]').sizebyte() 100
) |
sizedigit(x): Return a quick estimate for the maximal number of decimal digits before the decimal point of any component of x.
INPUT: x -- gen OUTPUT: int -- Python integer
sage: x = pari('10^100') sage: x.Str().length() 101 sage: x.sizedigit() 101
Note that digits after the decimal point are ignored.
sage: x = pari('1.234') sage: x 1.234000000000000000000000000 sage: x.sizedigit() 1
The estimate can be one too big:
sage: pari('7234.1').sizedigit() 4 sage: pari('9234.1').sizedigit() 5
) |
x.sqr(): square of x. NOT identical to x*x.
TODO: copy extensive notes about this function from PARI manual. Put examples below.
sage: pari(2).sqr() 4
) |
x.sqrt(precision): The square root of x.
sage: pari(2).sqrt() 1.414213562373095048801688724
) |
x.sqrtn(n): return the principal branch of the n-th root
of x, i.e., the one such that
.
Also returns a second argument which is a suitable root
of unity allowing one to recover all the other roots.
If it was not possible to find such a number, then this
second return value is 0. If the argument is present and
no square root exists, return 0 instead of raising an error.
NOTE: intmods (modulo a prime) and
-adic numbers are
allowed as arguments.
INPUT: x -- gen n -- integer OUTPUT: gen -- principal n-th root of x gen -- z that gives the other roots
TODO: ??? lots of good examples in the PARI docs ???
sage: s, z = pari(2).sqrtn(5) sage: z 0.3090169943749474241022934172 + 0.9510565162951535721164393334*I sage: s 1.148698354997035006798626947 sage: s**5 2.000000000000000000000000000 sage: (s*z)**5 2.000000000000000000000000000 + 4.038967835 E-28*I
) |
Str(self): Concatenate the entries of the vector self into a single string. If self is not a t_VEC its print representation is returned.
INPUT: self -- gen OUTPUT: gen -- a PARI gen of type t_STR, i.e., a PARI string
sage: pari([1,2,['abc',1]]).Str() 12[abc, 1] sage: pari([1,1,1.54]).Str() 111.540000000000000000000000000 sage: pari([1,1.54,1]).Str() 11.5400000000000000000000000001 sage: pari(1).Str() # 1 is automatically converted to string rep 1 sage: x = pari('x') # PARI variable "x" sage: x.Str() # is converted to string rep. x sage: x.Str().type() 't_STR'
) |
Strchr(x): converts x to a string, translating each integer into a character (in ASCII).
NOTE: Vecsmall is (essentially) the inverse to Strchr().
INPUT: x -- PARI vector of integers OUTPUT: gen -- a PARI string
sage: pari([65,66,123]).Strchr() AB{ sage: pari('"SAGE"').Vecsmall() # pari('"SAGE"') --> PARI t_STR Vecsmall([83, 65, 71, 69]) sage: _.Strchr() SAGE sage: pari([83, 65, 71, 69]).Strchr() SAGE
) |
Strexpand(x): Concatenate the entries of the vector x into a single string, performing tilde expansion.
NOTE: I have no clue what the point of this function is. - William
) |
Strtex(x): Translates the vector x of PARI gens to TeX format and returns the resulting concatenated strings as a PARI t_STR.
INPUT: x -- gen OUTPUT: gen -- PARI t_STR (string)
sage: v=pari('x^2') sage: v.Strtex() x^2 sage: v=pari(['1/x^2','x']) sage: v.Strtex() \frac{1}{x^2}x sage: v=pari(['1 + 1/x + 1/(y+1)','x-1']) sage: v.Strtex() \frac{ \left(\frac{y + 2}{y + 1}\right) x + 1}{x}x - 1
) |
sage: x = pari("x"); y = pari("y") sage: f = x**3 + 17*x + 3 sage: f.subst(x, y) y^3 + 17*y + 3 sage: f.subst(x, "z") z^3 + 17*z + 3 sage: f.subst(x, "z")**2 z^6 + 34*z^4 + 6*z^3 + 289*z^2 + 102*z + 9 sage: f.subst(x, "x+1") x^3 + 3*x^2 + 20*x + 21 sage: f.subst(x, "xyz") xyz^3 + 17*xyz + 3 sage: f.subst(x, "xyz")**2 xyz^6 + 34*xyz^4 + 6*xyz^3 + 289*xyz^2 + 102*xyz + 9
) |
x.tan() - tangent of x
sage: pari(2).tan() -2.185039863261518991643306102 sage: pari('I').tan() 0.E-29 + 0.7615941559557648881194582826*I
) |
x.tanh() - hyperbolic tangent of x
sage: pari(1).tanh() 0.7615941559557648881194582826 sage: pari('I').tanh() -2.524354897 E-29 + 1.557407724654902230506974807*I
) |
teichmuller(x): teichmuller character of p-adic number x.
This is the unique
th root of unity congruent to
modulo
.
sage: pari('2+O(7^5)').teichmuller() 2 + 4*7 + 6*7^2 + 3*7^3 + O(7^5)
) |
q.theta(z): Jacobi sine theta-function.
sage: pari(0.5).theta(2) 1.632025902952598833772353216
) |
q.thetanullk(k): return the k-th derivative at z=0 of theta(q,z)
sage: pari(0.5).thetanullk(1) 0.5489785325603405618549383537
) |
truncate(x,estimate=False): Return the truncation of x. If estimate is True, also return the number of error bits.
When x is in the real numbers, this means that the part after the decimal point is chopped away, e is the binary exponent of the difference between the original and truncated value (the "fractional part"). If x is a rational function, the result is the integer part (Euclidean quotient of numerator by denominator) and if requested the error estimate is 0.
When truncate is applied to a power series (in X), it
transforms it into a polynomial or a rational function with
denominator a power of X, by chopping away the
.
Similarly, when applied to a p-adic number, it transforms it
into an integer or a rational number by chopping away the
.
INPUT: x -- gen estimate -- (optional) bool, which is False by default OUTPUT: * if estimate == False, return a single gen. * if estimate == True, return rounded verison of x and error estimate in bits, both as gens. OUTPUT:
sage: pari('(x^2+1)/x').round() (x^2 + 1)/x sage: pari('(x^2+1)/x').truncate() x sage: pari('1.043').truncate() 1 sage: pari('1.043').truncate(True) (1, -5) sage: pari('1.6').truncate() 1 sage: pari('1.6').round() 2 sage: pari('1/3 + 2 + 3^2 + O(3^3)').truncate() 34/3 sage: pari('sin(x+O(x^10))').truncate() 1/362880*x^9 - 1/5040*x^7 + 1/120*x^5 - 1/6*x^3 + x sage: pari('sin(x+O(x^10))').round() # each coefficient has abs < 1 x + O(x^10)
) |
valuation(x,p): Return the valuation of x with respect to p.
The valuation is the highest exponent of p dividing x.
* If p is an integer, x must be an integer, an intmod whose modulus is divisible by p, a rational number, a p-adic number, or a polynomial or power series in which case the valuation is the minimal of the valuations of the coefficients.
* If p is a polynomial, x must be a polynomial or a rational fucntion. If p is a monomial then x may also be a power series.
* If x is a vector, complex or quadratic number, then the valuation is the minimum of the component valuations.
* If x = 0, the result is
on 32-bit machines or
on 64-bit machines if x is an exact object.
If x is a p-adic number or power series, the result
is the exponent of the zero.
INPUT: x -- gen p -- coercible to gen OUTPUT: gen -- integer
sage: pari(9).valuation(3) 2 sage: pari(9).valuation(9) 1 sage: x = pari(9).Mod(27); x.valuation(3) 2 sage: pari('5/3').valuation(3) -1 sage: pari('9 + 3*x + 15*x^2').valuation(3) 1 sage: pari([9,3,15]).valuation(3) 1 sage: pari('9 + 3*x + 15*x^2 + O(x^5)').valuation(3) 1
sage: pari('x^2*(x+1)^3').valuation(pari('x+1')) 3 sage: pari('x + O(x^5)').valuation('x') 1 sage: pari('2*x^2 + O(x^5)').valuation('x') 2
sage: pari(0).valuation(3) # on 32-bit machine 2147483647
) |
variable(x): Return the main variable of the object x, or p if x is a p-adic number.
This function raises a TypeError exception on scalars, i.e., on objects with no variable associated to them.
INPUT: x -- gen OUTPUT: gen
sage: pari('x^2 + x -2').variable() x sage: pari('1+2^3 + O(2^5)').variable() 2 sage: pari('x+y0').variable() x sage: pari('y0+z0').variable() y0
) |
Vec(x): Transforms the object x into a vector.
INPUT: x -- gen OUTPUT: gen -- of PARI type t_VEC
sage: pari(1).Vec() [1] sage: pari('x^3').Vec() [1, 0, 0, 0] sage: pari('x^3 + 3*x - 2').Vec() [1, 0, 3, -2] sage: pari([1,2,3]).Vec() [1, 2, 3] sage: pari('ab').Vec() [1, 0]
) |
vecmax(x): Return the maximum of the elements of the vector/matrix x,
) |
vecmin(x): Return the maximum of the elements of the vector/matrix x,
) |
Vecsmall(x): transforms the object x into a t_VECSMALL.
INPUT: x -- gen OUTPUT: gen -- PARI t_VECSMALL
sage: pari([1,2,3]).Vecsmall() Vecsmall([1, 2, 3]) sage: pari('"SAGE"').Vecsmall() Vecsmall([83, 65, 71, 69]) sage: pari(1234).Vecsmall() Vecsmall([1234])
) |
x.weber(flag=0): One of Weber's f function of x.
flag is optional, and can be
0: default, function f(x)=exp(-i*Pi/24)*eta((x+1)/2)/eta(x)
such that
,
1: function f1(x)=eta(x/2)/eta(x) such that
,
2: function f2(x)=sqrt(2)*eta(2*x)/eta(x) such that
.
TODO: Add further explanation from PARI manual.
sage: pari('I').weber() 1.189207115002721066717499970 + 0.E-28*I sage: pari('I').weber(1) 1.090507732665257659207010656 sage: pari('I').weber(2) 1.090507732665257659207010656
) |
zeta(s): Riemann zeta function at s with s a complex or a p-adic number.
TODO: Add extensive explanation from PARI user's manual.
INPUT: s -- gen (real or complex number) OUTPUT: gen -- value of zeta at s.
sage: pari(2).zeta() 1.644934066848226436472415167 sage: pari('Pi^2/6') 1.644934066848226436472415167 sage: pari(3).zeta() 1.202056903159594285399738162
See About this document... for information on suggesting changes.