Go to the first, previous, next, last section, table of contents.

Number Theory

Definitions for Number Theory

Function: BERN (x)
gives the Xth Bernoulli number for integer X. ZEROBERN[TRUE] if set to FALSE excludes the zero BERNOULLI numbers. (See also BURN).

Function: BERNPOLY (v, n)
generates the nth Bernoulli polynomial in the variable v.

Function: BFZETA (exp,n)
BFLOAT version of the Riemann Zeta function. The 2nd argument is how many digits to retain and return, it's a good idea to request a couple of extra. This function is available by doing LOAD(BFFAC); .

Function: BGZETA (S, FPPREC)
BGZETA is like BZETA, but avoids arithmetic overflow errors on large arguments, is faster on medium size arguments (say S=55, FPPREC=69), and is slightly slower on small arguments. It may eventually replace BZETA. BGZETA is available by doing LOAD(BFAC);.

gives FPPREC digits of

This is available by doing LOAD(BFFAC);.

Function: BINOMIAL (X, Y)
the binomial coefficient X*(X-1)*...*(X-Y+1)/Y!. If X and Y are integers, then the numerical value of the binomial coefficient is computed. If Y, or the value X-Y, is an integer, the binomial coefficient is expressed as a polynomial.

Function: BURN (N)
is like BERN(N), but without computing all of the uncomputed Bernoullis of smaller index. So BURN works efficiently for large, isolated N. (BERN(402) takes about 645 secs vs 13.5 secs for BURN(402). BERN's time growth seems to be exponential, while BURN's is about cubic. But if next you do BERN(404), it only takes 12 secs, since BERN remembers all in an array, whereas BURN(404) will take maybe 14 secs or maybe 25, depending on whether MACSYMA needs to BFLOAT a better value of %PI.) BURN is available by doing LOAD(BFFAC);. BURN uses an observation of WGD that (rational) Bernoulli numbers can be approximated by (transcendental) zetas with tolerable efficiency.

Function: BZETA
- This function is obsolete, see BFZETA.

Function: CF (exp)
converts exp into a continued fraction. exp is an expression composed of arithmetic operators and lists which represent continued fractions. A continued fraction a+1/(b+1/(c+...)) is represented by the list [a,b,c,...]. a,b,c,.. must be integers. Exp may also involve SQRT(n) where n is an integer. In this case CF will give as many terms of the continued fraction as the value of the variable CFLENGTH[1] times the period. Thus the default is to give one period. (CF binds LISTARITH to FALSE so that it may carry out its function.)

Function: CFDISREP (list)
converts the continued fraction represented by list into general representation.
(C1) CF([1,2,-3]+[1,-2,1]);
(D1)                 [1, 1, 1, 2]
(D2)                1 + ---------
                        1 + -----
                            1 + -

Function: CFEXPAND (x)
gives a matrix of the numerators and denominators of the next-to-last and last convergents of the continued fraction x.
(C1) CF(SQRT(3));
(D1)                 [1, 1, 2, 1, 2, 1, 2, 1]
                             [71  97]
(D2)                         [      ]
                             [41  56]
(C3) D2[1,2]/D2[2,2],NUMER;
(D3)                        1.7321429

Variable: CFLENGTH
default: [1] controls the number of terms of the continued fraction the function CF will give, as the value CFLENGTH[1] times the period. Thus the default is to give one period.

Function: CGAMMA
- The Gamma function in the complex plane. Do LOAD(CGAMMA) to use these functions. Functions Cgamma, Cgamma2, and LogCgamma2. These functions evaluate the Gamma function over the complex plane using the algorithm of Kuki, CACM algorithm 421. Calculations are performed in single precision and the relative error is typically around 1.0E-7; evaluation at one point costs less than 1 msec. The algorithm provides for an error estimate, but the Macsyma implementation currently does not use it. Cgamma is the general function and may be called with a symbolic or numeric argument. With symbolic arguments, it returns as is; with real floating or rational arguments, it uses the Macsyma Gamma function; and for complex numeric arguments, it uses the Kuki algorithm. Cgamma2 of two arguments, real and imaginary, is for numeric arguments only; LogCgamma2 is the same, but the log-gamma function is calculated. These two functions are somewhat more efficient.

Function: CGAMMA2

Function: DIVSUM (n,k)
adds up all the factors of n raised to the kth power. If only one argument is given then k is assumed to be 1.

Function: EULER (X)
gives the Xth Euler number for integer X. For the Euler-Mascheroni constant, see %GAMMA.

Function: FACTORIAL (X)
The factorial function. FACTORIAL(X) = X! . See also MINFACTORIAL and FACTCOMB. The factorial operator is !, and the double factorial operator is !!.

Function: FIB (X)
the Xth Fibonacci number with FIB(0)=0, FIB(1)=1, and FIB(-N)=(-1)^(N+1) *FIB(N). PREVFIB is FIB(X-1), the Fibonacci number preceding the last one computed.

Function: FIBTOPHI (exp)
converts FIB(n) to its closed form definition. This involves the constant %PHI (= (SQRT(5)+1)/2 = 1.618033989). If you want the Rational Function Package to know About %PHI do TELLRAT(%PHI^2-%PHI-1)$ ALGEBRAIC:TRUE$ .

Function: INRT (X,n)
takes two integer arguments, X and n, and returns the integer nth root of the absolute value of X.

Function: JACOBI (p,q)
is the Jacobi symbol of p and q.

Function: LCM (exp1,exp2,...)
returns the Least Common Multiple of its arguments. Do LOAD(FUNCTS); to access this function.

Variable: MAXPRIME
default: [489318] - the largest number which may be given to the PRIME(n) command, which returns the nth prime.

Function: MINFACTORIAL (exp)
examines exp for occurrences of two factorials which differ by an integer. It then turns one into a polynomial times the other. If exp involves binomial coefficients then they will be converted into ratios of factorials.
(C1) N!/(N+1)!;
(D1)                             --------
                                 (N + 1)!
(D2)                               -----
                                   N + 1

Function: PARTFRAC (exp, var)
expands the expression exp in partial fractions with respect to the main variable, var. PARTFRAC does a complete partial fraction decomposition. The algorithm employed is based on the fact that the denominators of the partial fraction expansion (the factors of the original denominator) are relatively prime. The numerators can be written as linear combinations of denominators, and the expansion falls out. See EXAMPLE(PARTFRAC); for examples.

Function: PRIME (n)
gives the nth prime. MAXPRIME[489318] is the largest number accepted as argument. Note: The PRIME command does not work in maxima, since it required a large file of primes, which most users do not want. PRIMEP does work however.

Function: PRIMEP (n)
returns TRUE if n is a prime, FALSE if not.

Function: QUNIT (n)
gives the principal unit of the real quadratic number field SQRT(n) where n is an integer, i.e. the element whose norm is unity. This amounts to solving Pell's equation A**2- n*B**2=1.
(C1) QUNIT(17);
(D1)              SQRT(17)+4
(C2)  EXPAND(%*(SQRT(17)-4));
(D2)               1

Function: TOTIENT (n)
is the number of integers less than or equal to n which are relatively prime to n.

Variable: ZEROBERN
default: [TRUE] - if set to FALSE excludes the zero BERNOULLI numbers. (See the BERN function.)

Function: ZETA (X)
gives the Riemann zeta function for certain integer values of X.

Variable: ZETA%PI
default: [TRUE] - if FALSE, suppresses ZETA(n) giving coeff*%PI^n for n even.

Go to the first, previous, next, last section, table of contents.