Pari/GP Reference Documentation  Contents - Index - Meta commands

Transcendental functions


Euler   I   Pi   ^   abs   acos   acosh   agm   arg   asin   asinh   atan   atanh   bernfrac   bernreal   bernvec   besseljh   besselk   cos   cosh   cotan   dilog   eint1   erfc   eta   exp   gamma   gammah   hyperu   incgam   incgamc   lngamma   log   polylog   psi   sin   sinh   sqr   sqrt   sqrtn   tan   tanh   teichmuller   theta   thetanullk   weber   zeta  
 
^  

The expression x ^n is powering. If the exponent is an integer, then exact operations are performed using binary (left-shift) powering techniques. In particular, in this case x cannot be a vector or matrix unless it is a square matrix (and moreover invertible if the exponent is negative). If x is a p-adic number, its precision will increase if v_p(n) > 0. PARI is able to rewrite the multiplication x * x of two identical objects as x^2, or sqr(x) (here, identical means the operands are two different labels referencing the same chunk of memory; no equality test is performed). This is no longer true when more than two arguments are involved.

If the exponent is not of type integer, this is treated as a transcendental function (see Section (??)), and in particular has the effect of componentwise powering on vector or matrices.

As an exception, if the exponent is a rational number p/q and x an integer modulo a prime, return a solution y of y^q = x^p if it exists. Currently, q must not have large prime factors.

Beware that

? Mod(7,19)^(1/2)
 %1 = Mod(11, 19)/*is any square root*/
 ? sqrt(Mod(7,19))
 %2 = Mod(8, 19)/*is the smallest square root*/
 ? Mod(7,19)^(3/5)
 %3 = Mod(1, 19)
 ? %3^(5/3)
 %4 = Mod(1, 19)/*Mod(7,19) is just another cubic root*/

The library syntax is gpow(x,n,prec) for x ^n.

Euler  

Euler's constant 0.57721.... Note that Euler is one of the few special reserved names which cannot be used for variables (the others are I and Pi, as well as all function names).

The library syntax is mpeuler(prec) where prec must be given. Note that this creates gamma on the PARI stack, but a copy is also created on the heap for quicker computations next time the function is called.

I  

the complex number sqrt{-1}.

The library syntax is the global variable gi (of type GEN).

Pi  

the constant Pi (3.14159...).

The library syntax is mppi(prec) where prec must be given. Note that this creates Pi on the PARI stack, but a copy is also created on the heap for quicker computations next time the function is called.

abs(x)  

absolute value of x (modulus if x is complex). Power series and 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.

? abs(-1)
 %1 = 1
 ? abs(3/7 + 4/7*I)
 %2 = 5/7
 ? abs(1 + I)
 %3 = 1.414213562373095048801688724

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.

The library syntax is gabs(x,prec).

acos(x)  

principal branch of cos^{-1}(x), i.e.such that Re(acos(x)) belongs to [0,Pi]. If x belongs to R and |x| > 1, then acos(x) is complex.

The library syntax is gacos(x,prec).

acosh(x)  

principal branch of cosh^{-1}(x), i.e.such that Im(acosh(x)) belongs to [0,Pi]. If x belongs to R and x < 1, then acosh(x) is complex.

The library syntax is gach(x,prec).

agm(x,y)  

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.

The library syntax is agm(x,y,prec).

arg(x)  

argument of the complex number x, such that -Pi < arg(x) <= Pi.

The library syntax is garg(x,prec).

asin(x)  

principal branch of sin^{-1}(x), i.e.such that Re(asin(x)) belongs to [-Pi/2,Pi/2]. If x belongs to R and |x| > 1 then asin(x) is complex.

The library syntax is gasin(x,prec).

asinh(x)  

principal branch of sinh^{-1}(x), i.e.such that Im(asinh(x)) belongs to [-Pi/2,Pi/2].

The library syntax is gash(x,prec).

atan(x)  

principal branch of tan^{-1}(x), i.e.such that Re(atan(x)) belongs to ]-Pi/2,Pi/2[.

The library syntax is gatan(x,prec).

atanh(x)  

principal branch of tanh^{-1}(x), i.e.such that Im(atanh(x)) belongs to ]-Pi/2,Pi/2]. If x belongs to R and |x| > 1 then atanh(x) is complex.

The library syntax is gath(x,prec).

bernfrac(x)  

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

The library syntax is bernfrac(x).

bernreal(x)  

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

The library syntax is bernreal(x,prec).

bernvec(x)  

creates a vector containing, as rational numbers, the Bernoulli numbers B_0, B_2,..., B_{2x}. These Bernoulli numbers can then be used as follows. Assume that this vector has been put into a variable, say bernint. Then you can define under GP:

bern(x) =
 {
   if (x == 1, return(-1/2));
   if (x < 0 || x % 2, return(0));
   bernint[x/2+1]
 }

and then bern(k) gives the Bernoulli number of index k as a rational number, exactly as bernreal(k) gives it as a real number. If you need only a few values, calling bernfrac(k) each time will be much more efficient than computing the huge vector above.

The library syntax is bernvec(x).

besseljh(n,x)  

J-Bessel function of half integral index. More precisely, besseljh(n,x) computes J_{n+1/2}(x) where n must be of type integer, and x is any element of C. In the present version 2.1.1, this function is not very accurate when x is small.

The library syntax is jbesselh(n,x,prec).

besselk(nu,x,{flag = 0})  

K-Bessel function of index nu (which can be complex) and argument x. Only real and positive arguments x are allowed in the present version 2.1.1. If flag is equal to 1, uses another implementation of this function which is often faster.

The library syntax is kbessel(nu,x,prec) and kbessel2(nu,x,prec) respectively.

cos(x)  

cosine of x.

The library syntax is gcos(x,prec).

cosh(x)  

hyperbolic cosine of x.

The library syntax is gch(x,prec).

cotan(x)  

cotangent of x.

The library syntax is gcotan(x,prec).

dilog(x)  

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

The library syntax is dilog(x,prec).

eint1(x,{n})  

exponential integral int_x^ oo (e^{-t})/(t)dt (x belongs to R)

If n is present, outputs the n-dimensional vector [ eint1(x),..., eint1(nx)] (x >= 0). This is faster than repeatedly calling eint1(i * x).

The library syntax is veceint1(x,n,prec). Also available is eint1(x,prec).

erfc(x)  

complementary error function (2/sqrtPi)int_x^ oo e^{-t^2}dt.

The library syntax is erfc(x,prec).

eta(x,{flag = 0})  

Dedekind's eta function, without the q^{1/24}. This means the following: if x is a complex number with positive imaginary part, the result is prod_{n = 1}^ oo (1-q^n), where q = e^{2iPi x}. If x is a power series (or can be converted to a power series) with positive valuation, the result is prod_{n = 1}^ oo (1-x^n).

If flag = 1 and x can be converted to a complex number (i.e.is not a power series), computes the true eta function, including the leading q^{1/24}.

The library syntax is eta(x,prec).

exp(x)  

exponential of x. p-adic arguments with positive valuation are accepted.

The library syntax is gexp(x,prec).

gammah(x)  

gamma function evaluated at the argument x+1/2. When x is an integer, this is much faster than using gamma(x+1/2).

The library syntax is ggamd(x,prec).

gamma(x)  

gamma function of x. In the present version 2.1.1 the p-adic gamma function is not implemented.

The library syntax is ggamma(x,prec).

hyperu(a,b,x)  

U-confluent hypergeometric function with parameters a and b. The parameters a and b can be complex but the present implementation requires x to be positive.

The library syntax is hyperu(a,b,x,prec).

incgam(s,x,{y})  

incomplete gamma function.

x must be positive and s real. The result returned is int_x^ oo e^{-t}t^{s-1}dt. When y is given, assume (of course without checking!) that y = Gamma(s). For small x, this will tremendously speed up the computation.

The library syntax is incgam(s,x,prec) and incgam4(s,x,y,prec), respectively. There exist also the functions incgam1 and incgam2 which are used for internal purposes.

incgamc(s,x)  

complementary incomplete gamma function.

The arguments s and x must be positive. The result returned is int_0^x e^{-t}t^{s-1}dt, when x is not too large.

The library syntax is incgam3(s,x,prec).

log(x,{flag = 0})  

principal branch of the natural logarithm of x, i.e.such that Im(ln(x)) belongs to ]-Pi,Pi]. The result is complex (with imaginary part equal to Pi) if x belongs to R and x < 0.

p-adic arguments are also accepted for x, with the convention that ln(p) = 0. Hence in particular exp(ln(x))/x will not in general be equal to 1 but to a (p-1)-th root of unity (or ±1 if p = 2) times a power of p.

If flag is equal to 1, use an agm formula suggested by Mestre, when x is real, otherwise identical to log.

The library syntax is glog(x,prec) or glogagm(x,prec).

lngamma(x)  

principal branch of the logarithm of the gamma function of x. Can have much larger arguments than gamma itself. In the present version 2.1.1, the p-adic lngamma function is not implemented.

The library syntax is glngamma(x,prec).

polylog(m,x,{flag = 0})  

one of the different polylogarithms, depending on flag:

If flag = 0 or is omitted: m^th polylogarithm of x, i.e.analytic continuation of the power series Li_m(x) = sum_{n >= 1}x^n/n^m. The program uses the power series when |x|^2 <= 1/2, and the power series expansion in log(x) otherwise. It is valid in a large domain (at least |x| < 230), but should not be used too far away from the unit circle since it is then better to use the functional equation linking the value at x to the value at 1/x, which takes a trivial form for the variant below. Power series, polynomial, rational and vector/matrix arguments are allowed.

For the variants to follow we need a notation: let Re_m denotes Re or Im depending whether m is odd or even.

If flag = 1: modified m^th polylogarithm of x, called ~ D_m(x) in Zagier, defined for |x| <= 1 by Re_m(sum_{k = 0}^{m-1} ((-log|x|)^k)/(k!)Li_{m-k}(x) +((-log|x|)^{m-1})/(m!)log|1-x|).

If flag = 2: modified m^th polylogarithm of x, called D_m(x) in Zagier, defined for |x| <= 1 by Re_m(sum_{k = 0}^{m-1}((-log|x|)^k)/(k!)Li_{m-k}(x) -(1)/(2)((-log|x|)^m)/(m!)).

If flag = 3: another modified m^th polylogarithm of x, called P_m(x) in Zagier, defined for |x| <= 1 by Re_m(sum_{k = 0}^{m-1}(2^kB_k)/(k!)(log|x|)^kLi_{m-k}(x) -(2^{m-1}B_m)/(m!)(log|x|)^m).

These three functions satisfy the functional equation f_m(1/x) = (-1)^{m-1}f_m(x).

The library syntax is polylog0(m,x,flag,prec).

psi(x)  

the psi-function of x, i.e.the logarithmic derivative Gamma'(x)/Gamma(x).

The library syntax is gpsi(x,prec).

sin(x)  

sine of x.

The library syntax is gsin(x,prec).

sinh(x)  

hyperbolic sine of x.

The library syntax is gsh(x,prec).

sqr(x)  

square of x. This operation is not completely straightforward, i.e.identical to x * x, since it can usually be computed more efficiently (roughly one-half of the elementary multiplications can be saved). Also, squaring a 2-adic number increases its precision. For example,

? (1 + O(2^4))^2
 %1 = 1 + O(2^5)
 ? (1 + O(2^4)) * (1 + O(2^4))
 %2 = 1 + O(2^4)

Note that this function is also called whenever one multiplies two objects which are known to be identical, e.g.they are the value of the same variable, or we are computing a power.

? x = (1 + O(2^4)); x * x
 %3 = 1 + O(2^5)
 ? (1 + O(2^4))^4
 %4 = 1 + O(2^6)

(note the difference between %2 and %3 above).

The library syntax is gsqr(x).

sqrt(x)  

principal branch of the square root of x, i.e.such that Arg(sqrt(x)) belongs to ]-Pi/2, Pi/2], or in other words such that Re(sqrt(x)) > 0 or Re(sqrt(x)) = 0 and Im(sqrt(x)) >= 0. If x belongs to R and x < 0, then the result is complex with positive imaginary part.

Integermod a prime and p-adics are allowed as arguments. In that case, the square root (if it exists) which is returned is the one whose first p-adic digit (or its unique p-adic digit in the case of integermods) is in the interval [0,p/2]. When the argument is an integermod a non-prime (or a non-prime-adic), the result is undefined.

The library syntax is gsqrt(x,prec).

sqrtn(x,n,{&z})  

principal branch of the nth root of x, i.e.such that Arg(sqrt(x)) belongs to ]-Pi/n, Pi/n].

Integermod a prime and p-adics are allowed as arguments.

If z is present, it is set to a suitable root of unity allowing to recover all the other roots. If it was not possible, z is set to zero.

The following script computes all roots in all possible cases:

sqrtnall(x,n)=
 {
   local(V,r,z,r2);
   r = sqrtn(x,n, &z);
   if (!z, error("Impossible case in sqrtn"));
   if (type(x) == "t_INTMOD" || type(x)=="t_PADIC" ,
     r2 = r*z; n = 1;
     while (r2!=r, r2*=z;n++));
   V = vector(n); V[1] = r;
   for(i=2, n, V[i] = V[i-1]*z);
   V
 }
 addhelp(sqrtnall,"sqrtnall(x,n):compute the vector of nth-roots of x");

The library syntax is gsqrtn(x,n,&z,prec).

tan(x)  

tangent of x.

The library syntax is gtan(x,prec).

tanh(x)  

hyperbolic tangent of x.

The library syntax is gth(x,prec).

teichmuller(x)  

Teichmüller character of the p-adic number x.

The library syntax is teich(x).

theta(q,z)  

Jacobi sine theta-function.

The library syntax is theta(q,z,prec).

thetanullk(q,k)  

k-th derivative at z = 0 of theta(q,z).

The library syntax is thetanullk(q,k,prec), where k is a long.

weber(x,{flag = 0})  

one of Weber's three f functions. If flag = 0, returns f(x) = exp(-iPi/24).eta((x+1)/2)/eta(x) such that j = (f^{24}-16)^3/f^{24}, where j is the elliptic j-invariant (see the function ellj). If flag = 1, returns f_1(x) = eta(x/2)/eta(x) such that j = (f_1^{24}+16)^3/f_1^{24}. Finally, if flag = 2, returns f_2(x) = sqrt{2}eta(2x)/eta(x) such that j = (f_2^{24}+16)^3/f_2^{24}. Note the identities f^8 = f_1^8+f_2^8 and ff_1f_2 = sqrt2.

The library syntax is weber0(x,flag,prec), or wf(x,prec), wf1(x,prec) or wf2(x,prec).

zeta(s)  

Riemann's zeta function zeta(s) = sum_{n >= 1}n^{-s}, computed using the Euler-Maclaurin summation formula, except when s is of type integer, in which case it is computed using Bernoulli numbers for s <= 0 or s > 0 and even, and using modular forms for s > 0 and odd.

The library syntax is gzeta(s,prec).