As a general rule, which of course in some cases may have exceptions, transcendental functions operate in the following way:
If the argument is either an integer, a real, a rational, a complex
or a quadratic number, it is, if necessary, first converted to a real
(or complex) number using the current held in the variable
prec. Under GP this is transparent to the user, but when programming
in library mode, care must be taken to supply the parameter prec as
the last argument of the function if the first argument is an exact object
(see 1.2.5.), otherwise disaster will occur.
Then, the function is computed. Note that even if the argument is real, the result may be complex (e.g. acos(2.0) or acosh(0.0)). Note also that the principal branch is always chosen.
If the argument is an integermod or a p-adic, at present only a
few functions like sqrt (square root), sqr (square), log,
exp, powering, teich (Teichmüller character) and agm
(arithmetic-geometric mean) are implemented.
Note that in the case of a 2-adic number,
(x) is not identical to x*x: for example if
x = 1 + O(25) then
x*x = 1 + O(25) while
(x) = 1 + O(26).
(Remark: note that if we wanted to be strictly consistent with the
PARI philosophy, we should have
x*y = (4 mod 8) when both x and y are
congruent to 2 modulo 4, or
(x) = (4 mod 32) when x is
congruent to 2 modulo 4. However, since an integermod is an exact object,
PARI assumes that the modulus must not change, and the result is hence
0 mod 4 in both cases. On the other hand, p-adics are not exact objects,
hence are treated differently.)
If the argument is a polynomial, power series or rational function,
it is, if necessary, first converted to a power series using the current
precision held in the variable . Under GP this again is
transparent to the user. When programming in library mode, however, the
global variable precdl must be set before calling the function
if the argument has an exact type (i.e. not a power series). Here precdl is
not an argument of the function, but a global variable.
Then the taylor series expansion of the function around X = 0 (where X is the main variable) is computed to a number of terms depending on the number of terms of the argument and the function being computed.
If the argument is a vector or a matrix, the result is componentwise evaluation of the function. In particular, transcendental functions on square matrices, which are not implemented in the present version 1.35 (see Appendix C however), will have a slightly different name if they are implemented some day.
x
y: if y is not of type integer, this has the same
effect as
exp(y*ln(x)). It can be applied to p-adic numbers as
well as to the more usual types.powering
The library syntax is
gpui(x, y, prec).
abs(x): absolute value of x. Polynomials, power series and rational functions are not allowed.
The library syntax is
gabs(x, prec) where the second argument
prec is necessary only in the complex or imaginary quadratic case.
acos(x): principal branch of
cos-1(x),
i.e. such that
Re(acos(x))∈[0, π]. If
x∈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))∈[0, π]. If
x∈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).
asin(x): principal branch of
sin-1(x),
i.e. such that
Re(asin(x))∈[- π/2, π/2]. If
x∈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)∈[- π/2, π/2].
The library syntax is
gash(x, prec).
atan(x): principal branch of tan-1(x), i.e. such that Re(atan(x))∈] - π/2, π/2[.
The library syntax is
gatan(x, prec).
atanh(x): principal branch of
tanh-1(x).
i.e. such that
Im(atanh(x))∈] - π/2, π/2]. If
x∈R and | x| > 1 then
atanh(x) is complex.
The library syntax is
gath(x, prec).
bernreal(x): Bernoulli number Bx, where B0 = 1, B1 = - 1/2, B2 = 1/6,..., expressed 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 B0, B2,..., B2x. These Bernoulli numbers can then be used as follows. Assume that this vector has been put into a variable, say b. Then we define under GP:
bern(x)=if(x==1,-1/2,if((x<0)||(x%2),0,b[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.
The library syntax is
bernvec(x).
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).
dilog(x): principal branch of the dilogarithm of x, i.e.
analytic continuation of the power series
log2(x) = xn/n2.
The library syntax is
dilog(x, prec).
eint1(x): exponential integral
dt.
The library syntax is
eint1(x, prec).
erfc(x): complementary error function
(2/)
e-t2 dt.
The library syntax is
erfc(x, prec).
eta(x): Dedekind's η function, without the
q1/24. The meaning is this. If x is a complex number with
positive imaginary part, the result is
(1 - qn),
where
q = e2iπx. If x is a power series (or can be converted
to a power series) with positive valuation, the result is
(1 - xn).
The library syntax is
eta(x, prec).
euler: Euler's constant 0.57721 ... .
Note that euler is one of the few special reserved names which cannot be used for variables.
The library syntax is
mpeuler(prec) where prec must be
given.
Note that this creates γ on the PARI stack. If one does not want to
create it on that stack but be able to use it later under the global
name
(with no parentheses) use instead
consteuler(prec).
exp(x): exponential of x. p-adic arguments with positive valuation are accepted.
The library syntax is
gexp(x, prec).
gamh(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.
The library syntax is
ggamma(x, prec).
hyperu(a, b, x): U-confluent hypergeometric function with parameters a and b.
The library syntax is
hyperu(a, b, x, prec).
incgam(x, y): incomplete gamma function.
The arguments x and y must be positive. The result returned is
e-ttx-1 dt.
The library syntax is
incgam(x, y, prec).
Note: in addition, there exist also the functions
,
and
,
which are used for internal purposes. The only really useful one of the three
in addition to the standard incgam, is the function incgam3
which computes
e-ttx-1 dt. when y is not too large.
jbesselh(n, x): J-bessel function of half integral index.
More precisely, jbesselh(n,x) computes
Jn+1/2(x) where n
must be of type integer, and x is any element of C. In the
present version 1.35, this function is not very accurate when x is
small. This will be improved soon.
The library syntax is
jbesselh(n, x, prec).
jell(x): elliptic j-invariant. x must be a complex number with positive imaginary part, or convertible into a power series or a p-adic number with positive valuation.
The library syntax is
jell(x, prec).
kbessel(nu, x): 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 1.35.
The library syntax is
kbessel(nu, x, prec).
Note: in addition, another implementation of this function which is often
faster than kbessel is the function .
ln(x) or log(x):log pricipal branch of the
natural logarithm of x, i.e. such that
Im(ln(x))∈] - π, π].
The result is complex (with imaginary part equal to π) if
x∈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.
The library syntax is
glog(x, prec).
lngamma(x): principal branch of the logarithm of the gamma function of x. Can have much larger arguments than gamma itself.
The library syntax is
glngamma(x, prec).
logagm(x): principal branch of the natural logarithm of x, computed using an agm formula suggested by Mestre, when x is real, otherwise identical to log.
The library syntax is
glogagm(x, prec).
pi: the constant pi ( 3.14159 ... ).
The library syntax is
mppi(prec) where prec must be given.
Note that this creates π on the PARI stack. If one does not want to
create it on that stack but be able to use it later under the global
name
(with no parentheses) use instead
constpi(prec).
polylog(m, x):
mth polylogarithm of x, i.e. analytic
continuation of the power series
logm(x) = xn/nm.
The library syntax is
polylog(m, x, prec).
polylogd(m, x): modified mth polylogarithm of x, called Dm(x) in Zagier, defined for | x|≤1 by
The library syntax is
polylogd(m, x, prec).
polylogp(m, x): another modified mth polylogarithm of x, called Pm(x) in Zagier, defined for | x|≤1 by
The library syntax is
polylogp(m, x, prec).
psi(x): the ψ-function of x, i.e. the logarithmic derivative Γ'(x)/Γ(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. Not identical to x*x in
the case of 2-adics (see above), and acts componentwise
on vectors and matrices. In particular, if x is a square matrix, sqr(x)
is not the square of x (use instead x*x or
x2).
The library syntax is
gsqr(x).
sqrt(x): principal branch of the square root of x,
i.e. such that
Arg(sqrt(x))∈] - π/2, π/2], or in other words
such that
Re(sqrt(x)) > 0 or
Re(sqrt(x)) = 0 and
Im(sqrt(x)) > = 0.
Integermod a prime and p-adics are allowed as arguments.
If
x∈R and x < 0 the result is complex with positive imaginary part.
The library syntax is
gsqrt(x, 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).
teich(x): teichmuller character of the p-adic number x.
The library syntax is
teich(x).
wf(x): Weber's f function, i.e. such that j = (f24 -16)3/f24.
The library syntax is
wf(x, prec).
wf2(x): Weber's f2 function, i.e. such that j = (f224 +16)3/f224.
The library syntax is
wf2(x, prec).
zeta(s): Riemann's zeta function
ζ(s) = n-s,
computed using the Euler-Maclaurin summation formula.
The library syntax is
gzeta(s, prec).