# ore_algebra.tools¶

Auxiliary functions

Functions

 clear_denominators(elts[, dom]) Recursively clear denominators in a list (or other iterable) of elements. make_factor_iterator(ring[, multiplicities]) Creates an iterator for factoring polynomials in the given ring. q_log(q, u) Determines, if possible, an integer n such that q^n = u. shift_factor(p[, ram, q]) Returns the roots of p in an appropriate extension of the base ring, sorted according to shift equivalence classes.
ore_algebra.tools.clear_denominators(elts, dom=None)

Recursively clear denominators in a list (or other iterable) of elements.

Typically intended for elements of fields like QQ(x)(y).

ore_algebra.tools.make_factor_iterator(ring, multiplicities=True)

Creates an iterator for factoring polynomials in the given ring.

The ring must be a univariate polynomial ring over some base ring R, and the method will attempt to construct a factorizer for elements as if they were elements of Frac(R)[x]. Only factors with positive x-degree will be returned. The factors will not be casted back to elements of R[x]. If multiplicities is set to True (default), the iterator will return pairs (p, e), otherwise just the irreducible factors p.

EXAMPLES:

sage: from ore_algebra.tools import make_factor_iterator
sage: R0.<a,b> = ZZ['a','b']; R.<x> = R0['x']
sage: f = make_factor_iterator(R)
sage: [(p, e) for p, e in f(((a+b)*x - 2)^3*(2*x+a)*(2*x+b))]
[(2*x + b, 1), (2*x + a, 1), ((a + b)*x - 2, 3)]
sage: f = make_factor_iterator(ZZ[x])
sage: [(p, e) for p, e in f((2*x-3)*(4*x^3-5)*(3*x^5-4))]
[(2*x - 3, 1), (4*x^3 - 5, 1), (3*x^5 - 4, 1)]
sage: f = make_factor_iterator(QQ.extension(QQ[x](x^2+1), "ii")[x])
sage: [(p, e) for p, e in f((x^2+1)^2*(4*x^3-5)*(3*x^5-4))]
[(x - ii, 2), (x + ii, 2), (x^3 - 5/4, 1), (x^5 - 4/3, 1)]

ore_algebra.tools.q_log(q, u)

Determines, if possible, an integer n such that q^n = u.

Requires that both q and u belong to either QQ or some rational function field over QQ.

q must not be zero or a root of unity.

A ValueError is thrown if no n exists.

ore_algebra.tools.shift_factor(p, ram=1, q=1)

Returns the roots of p in an appropriate extension of the base ring, sorted according to shift equivalence classes.

INPUT:

• p – a univariate polynomial over QQ or a number field
• ram (optional) – positive integer
• q (optional) – if set to a quantity different from 1 or 0, the factorization will be made according to the q-shift instead of the ordinary shift. The value must not be a root of unity.

OUTPUT:

A list of pairs (q, e) where

• q is an irreducible factor of p
• e is a tuple of pairs (a, b) of nonnegative integers
• p = c*prod( sigma^(a/ram)(q)^b for (q, e) in output list for (a, b) in e ) for some nonzero constant c (in the q-case, a possible power of x is also omitted)
• e[0][0] == 0, and e[i][0] < e[i+1][0] for all i
• any two distinct q have no roots at integer distance.

The constant domain must have characteristic zero.

In the q-case, ramification greater than 1 requires that q^(1/ram) exists in the constant domain.

Note that rootof(q) is the largest root of every class. The other roots are given by rootof(q) - e[i][0]/ram.

EXAMPLES:

sage: from ore_algebra.tools import shift_factor
sage: x = ZZ['x'].gen()
sage: shift_factor((x-2)*(x-4)*(x-8)*(2*x+3)*(2*x+15))
[[x - 8, [(0, 1), (4, 1), (6, 1)]], [2*x + 3, [(0, 1), (6, 1)]]]
sage: shift_factor((x-2)*(x-4)*(x-8)*(2*x+3)*(2*x+15), q=2)
[[-1/8*x + 1, [(0, 1), (1, 1), (2, 1)]], [2/3*x + 1, [(0, 1)]], [2/15*x + 1, [(0, 1)]]]