Returns a rational number, which is an approximation of the n'th Bernoulli
number for integer n. burn exploits the observation that
(rational) Bernoulli numbers can be approximated by (transcendental) zetas with
tolerable efficiency:

burn may be more efficient than bern for large, isolated n
as bern computes all the Bernoulli numbers up to index n before
returning. burn invokes the approximation for even integers n >
255. For odd integers and n <= 255 the function bern is called.

Computes a continued fraction approximation.
expr is an expression comprising continued fractions,
square roots of integers, and literal real numbers
(integers, rational numbers, ordinary floats, and bigfloats).
cf computes exact expansions for rational numbers,
but expansions are truncated at ratepsilon for ordinary floats
and 10^(-fpprec) for bigfloats.

Operands in the expression may be combined with arithmetic operators.
Maxima does not know about operations on continued fractions
outside of cf.

cf evaluates its arguments after binding listarith to
false. cf returns a continued fraction, represented as a list.

A continued fraction a + 1/(b + 1/(c + ...)) is represented by the list
[a, b, c, ...]. The list elements a, b, c, …
must evaluate to integers. expr may also contain 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 times the
period.

A continued fraction can be evaluated to a number by evaluating the arithmetic
representation returned by cfdisrep. See also cfexpand for
another way to evaluate a continued fraction.

Controls the value returned by ifactors. The default false
causes ifactors to provide information about multiplicities of the
computed prime factors. If factors_only is set to true,
ifactors returns nothing more than a list of prime factors.

For a positive integer n returns the factorization of n. If
n=p1^e1..pk^nk is the decomposition of n into prime
factors, ifactors returns [[p1, e1], ... , [pk, ek]].

Factorization methods used are trial divisions by primes up to 9973,
Pollard's rho and p-1 method and elliptic curves.

If the variable ifactor_verbose is set to true
ifactor produces detailed output about what it is doing including
immediate feedback as soon as a factor has been found.

The value returned by ifactors is controlled by the option variable factors_only.
The default false causes ifactors to provide information about
the multiplicities of the computed prime factors. If factors_only
is set to true, ifactors simply returns the list of
prime factors.

After calling lucas, the global variable
next_lucas is equal to lucas (n + 1),
the Lucas number following the last returned. The example shows
how Fibonacci numbers can be computed via lucas and next_lucas.

If x and y are real numbers and y is nonzero, return
x - y * floor(x / y). Further for all real
x, we have mod (x, 0) = x. For a discussion of the
definition mod (x, 0) = x, see Section 3.4, of
"Concrete Mathematics," by Graham, Knuth, and Patashnik. The function
mod (x, 1) is a sawtooth function with period 1 with
mod (1, 1) = 0 and mod (0, 1) = 0.

To find the principal argument (a number in the interval (-%pi, %pi]) of
a complex number, use the function
x |-> %pi - mod (%pi - x, 2*%pi), where x is an
argument.

When x and y are constant expressions (10 * %pi, for
example), mod uses the same big float evaluation scheme that floor
and ceiling uses. Again, it's possible, although unlikely, that
mod could return an erroneous value in such cases.

Expands the expression expr 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.

Primality test. If primep (n) returns false, n is a
composite number and if it returns true, n is a prime number
with very high probability.

For n less than 341550071728321 a deterministic version of
Miller-Rabin's test is used. If primep (n) returns
true, then n is a prime number.

For n bigger than 341550071728321 primep uses
primep_number_of_tests Miller-Rabin's pseudo-primality tests and one
Lucas pseudo-primality test. The probability that a non-prime n will
pass one Miller-Rabin test is less than 1/4. Using the default value 25 for
primep_number_of_tests, the probability of n being
composite is much smaller that 10^-15.

Returns the Riemann zeta function. If n is a negative integer, 0, or a
positive even integer, the Riemann zeta function simplifies to an exact value.
For a positive even integer the option variable zeta%pi has to be
true in addition (See zeta%pi). For a floating point or bigfloat
number the Riemann zeta function is evaluated numerically. Maxima returns a
noun form zeta (n) for all other arguments, including rational
noninteger, and complex arguments, or for even integers, if zeta%pi has
the value false.

zeta(1) is undefined, but Maxima knows the limit
limit(zeta(x), x, 1) from above and below.

The Riemann zeta function distributes over lists, matrices, and equations.

Returns a list containing the characteristic factors of the totient of n.

Using the characteristic factors a multiplication group modulo n
can be expressed as a group direct product of cyclic subgroups.

In case the group itself is cyclic the list only contains the totient
and using zn_primroot a generator can be computed.
If the totient splits into more than one characteristic factors
zn_factor_generators finds generators of the corresponding subgroups.

Each of the r factors in the list divides the right following factors.
For the last factor f_r therefore holds a^f_r = 1 (mod n)
for all a coprime to n.
This factor is also known as Carmichael function or Carmichael lambda.

If n > 2, then totient(n)/2^r is the number of quadratic residues,
and each of these has 2^r square roots.

Computes the discrete logarithm. Let (Z/nZ)* be a cyclic group, g a
primitive root modulo n and let a be a member of this group.
zn_log (a, g, n) then solves the congruence g^x = a mod n.

The applied algorithm needs a prime factorization of totient(n). This factorization
might be time consuming as well and in some cases it can be useful to factor first
and then to pass the list of factors to zn_log as the fourth argument.
The list must be of the same form as the list returned by ifactors(totient(n))
using the default option factors_only : false.

The algorithm uses a Pohlig-Hellman-reduction and Pollard's Rho-method for
discrete logarithms. The run time of zn_log primarily depends on the
bitlength of the totient's greatest prime factor.

Without the optional argument gcdzn_mult_table(n) shows a
multiplication table of all elements in (Z/nZ)* which are all elements
coprime to n.

The optional second argument gcd allows to select a specific
subset of (Z/nZ). If gcd is an integer, a multiplication table of
all residues x with gcd(x,n) = gcd are returned.
Additionally row and column headings are added for better readability.
If necessary, these can be easily removed by submatrix(1, table, 1).

If gcd is set to all, the table is printed for all non-zero
elements in (Z/nZ).

The second example shows an alternative way to create a multiplication table
for subgroups.

The default table shows all elements in (Z/nZ)* and allows to demonstrate
and study basic properties of modular multiplication groups.
E.g. the principal diagonal contains all quadratic residues,
each row and column contains every element, the tables are symmetric, etc..

If gcd is set to all, the table is printed for all non-zero
elements in (Z/nZ).

If gcd is an integer, row and column headings are added for better readability.

If the subset chosen by gcd is a group there is another way to create
a multiplication table. An isomorphic mapping from a group with 1 as
identity builds a table which is easy to read. The mapping is accomplished via CRT.

In the second version of T36_4 the identity, here 28, is placed in
the top left corner, just like in table T9.

Returns a list with all n-th roots of x from the multiplication
subgroup of (Z/mZ) which contains x, or false, if x
is no n-th power modulo m or not contained in any multiplication
subgroup of (Z/mZ).

x is an element of a multiplication subgroup modulo m, if the
greatest common divisor g = gcd(x,m) is coprime to m/g.

zn_nth_root is based on an algorithm by Adleman, Manders and Miller
and on theorems about modulo multiplication groups by Daniel Shanks.

The algorithm needs a prime factorization of the modulus m.
So in case the factorization of m is known, the list of factors
can be passed as the fourth argument. This optional argument
must be of the same form as the list returned by ifactors(m)
using the default option factors_only: false.

Examples:

A power table of the multiplication group modulo 14
followed by a list of lists containing all n-th roots of 1
with n from 1 to 6.

In the following RSA-like example, where the modulus N is squarefree,
i.e. it splits into
exclusively first power factors, every x from 0 to N-1
is contained in a multiplication subgroup.

The process of decryption needs the e-th root.
e is coprime to totient(N) and therefore the e-th root is unique.
In this case zn_nth_root effectively performs CRT-RSA.
(Please note that flatten removes braces but no solutions.)

Returns the order of x if it is a unit of the finite group (Z/nZ)*
or returns false. x is a unit modulo n if it is coprime to n.

The applied algorithm needs a prime factorization of totient(n). This factorization
might be time consuming in some cases and it can be useful to factor first
and then to pass the list of factors to zn_log as the third argument.
The list must be of the same form as the list returned by ifactors(totient(n))
using the default option factors_only : false.

Without any optional argument zn_power_table(n)
shows a power table of all elements in (Z/nZ)*
which are all residue classes coprime to n.
The exponent loops from 1 to the greatest characteristic factor of
totient(n) (also known as Carmichael function or Carmichael lambda)
and the table ends with a column of ones on the right side.

The optional second argument gcd allows to select powers of a specific
subset of (Z/nZ). If gcd is an integer, powers of all residue
classes x with gcd(x,n) = gcd are returned,
i.e. the default value for gcd is 1.
If gcd is set to all, the table contains powers of all elements
in (Z/nZ).

If the optional third argument max_exp is given, the exponent loops from
1 to max_exp.

The default which is gcd = 1 allows to demonstrate and study basic
theorems of e.g. Fermat and Euler.

The argument gcd allows to select subsets of (Z/nZ) and to study
multiplication subgroups and isomorphisms.
E.g. the groups G10 and G10_2 are under multiplication both
isomorphic to G5. 1 is the identity in G5.
So are 1 resp. 6 the identities in G10 resp. G10_2.
There are corresponding mappings for primitive roots, n-th roots, etc..

If the multiplicative group (Z/nZ)* is cyclic, zn_primroot computes the
smallest primitive root modulo n. (Z/nZ)* is cyclic if n is equal to
2, 4, p^k or 2*p^k, where p is prime and
greater than 2 and k is a natural number. zn_primroot
performs an according pretest if the option variable zn_primroot_pretest
(default: false) is set to true. In any case the computation is limited
by the upper bound zn_primroot_limit.

If (Z/nZ)* is not cyclic or if there is no primitive root up to
zn_primroot_limit, zn_primroot returns false.

The applied algorithm needs a prime factorization of totient(n). This factorization
might be time consuming in some cases and it can be useful to factor first
and then to pass the list of factors to zn_log as an additional argument.
The list must be of the same form as the list returned by ifactors(totient(n))
using the default option factors_only : false.

If zn_primroot cannot find a primitve root, it stops at this upper bound.
If the option variable zn_primroot_verbose (default: false) is
set to true, a message will be printed when zn_primroot_limit is reached.

Checks whether x is a primitive root in the multiplicative group (Z/nZ)*.

The applied algorithm needs a prime factorization of totient(n). This factorization
might be time consuming and in case zn_primroot_p will be consecutively
applied to a list of candidates it can be useful to factor first and then to
pass the list of factors to zn_log as a third argument.
The list must be of the same form as the list returned by ifactors(totient(n))
using the default option factors_only : false.

The multiplicative group (Z/nZ)* is cyclic if n is equal to
2, 4, p^k or 2*p^k, where p is prime and
greater than 2 and k is a natural number.

zn_primroot_pretest controls whether zn_primroot will check
if one of these cases occur before it computes the smallest primitive root.
Only if zn_primroot_pretest is set to true this pretest will be
performed.