Element Operations

A variety of different types of operations are provided for rational elements including arithmetic operations, comparison and predicates and converting to a sequence.

Contents

Parent and Category

Parent(r) : FldRatElt -> FldRat
Category(r) : FldRatElt -> Cat

Arithmetic Operators

+ a : FldRatElt -> FldRatElt
- a : FldRatElt -> FldRatElt
a + b : FldRatElt, FldRatElt -> FldRatElt
a - b : FldRatElt, FldRatElt -> FldRatElt
a * b : FldRatElt, FldRatElt -> FldRatElt
a ^ k : FldRatElt, RngIntElt -> FldRatElt
a / b : FldRatElt, FldRatElt -> FldRatElt
a +:= b : FldRatElt, FldRatElt -> FldRatElt
a -:= b : FldRatElt, FldRatElt -> FldRatElt
a *:= b : FldRatElt, FldRatElt -> FldRatElt
a /:= b : FldRatElt, FldRatElt -> FldRatElt
a ^:= k : FldRatElt, RngIntElt -> FldRatElt

Numerator and Denominator

Numerator(q) : FldRatElt -> RngIntElt
The (integer) numerator of the rational number q in reduced form.
Denominator(q) : FldRatElt -> RngIntElt
The (integer) denominator of the rational number q in reduced form. This will always be a positive integer.

Example FldRat_numerator (H21E3)

Rational numbers are always immediately put in reduced form, that is, the greatest common divisor of numerator and denominator is taken out, and the denominator will be positive.
> Numerator(10/-4);
-5
> Denominator(10/-4);
2

Equality and Membership

a eq b : FldRatElt, FldRatElt -> BoolElt
a ne b : FldRatElt, FldRatElt -> BoolElt
a in R : FldRatElt, Rng -> BoolElt
a notin R : FldRatElt, Rng -> BoolElt

Predicates on Ring Elements

IsZero(a) : FldRatElt -> BoolElt
IsOne(a) : FldRatElt -> BoolElt
IsMinusOne(a) : FldRatElt -> BoolElt
IsNilpotent(a) : FldRatElt -> BoolElt
IsIdempotent(a) : FldRatElt -> BoolElt
IsUnit(a) : FldRatElt -> BoolElt
IsZeroDivisor(a) : FldRatElt -> BoolElt
IsRegular(a) : FldRatElt -> BoolElt
IsIrreducible(a) : FldRatElt -> BoolElt
IsPrime(a) : FldRatElt -> BoolElt
IsIntegral(q) : FldRatElt -> BoolElt
Returns true if the rational number q is an element of the ring of integers, false otherwise.

Comparison

a gt b : FldRatElt, FldRatElt -> BoolElt
a ge b : FldRatElt, FldRatElt -> BoolElt
a lt b : FldRatElt, FldRatElt -> BoolElt
a le b : FldRatElt, FldRatElt -> BoolElt
Maximum(a, b) : FldRatElt, FldRatElt -> FldRatElt
Maximum(Q) : [FldRatElt] -> FldRatElt
Minimum(a, b) : FldRatElt, FldRatElt -> FldRatElt
Minimum(Q) : [FldRatElt] -> FldRatElt

Conjugates, Norm and Trace

ComplexConjugate(q) : FldRatElt -> FldRatElt
The complex conjugate of q, which will be the rational number q itself.
Conjugate(q) : FldRatElt -> FldRatElt
The conjugate of q, which will be the rational number q itself.
Norm(q) : FldRatElt -> FldRatElt
The norm (in Q) of q, which will be the rational number q itself.
Trace(q) : FldRatElt -> FldRatElt
The trace (in Q) of q, which will be the rational number q itself.
MinimalPolynomial(q) : FldRatElt -> RngUPolElt
Returns the minimal polynomial of the rational number q, which is the monic linear polynomial with constant coefficient q in a univariate polynomial ring R over the rational field. (If R has not been created before with a name for its indeterminate, $.1-q will be returned.)

Absolute Value and Sign

AbsoluteValue(q) : FldRatElt -> FldRatElt
Abs(q) : FldRatElt -> FldRatElt
The absolute value |q|of a rational number q.
Sign(q) : FldRatElt -> RngIntElt
Returns the sign of the rational number q, which is one of the integers -1, 0, 1, corresponding to the cases q<0, q=0, and q>0.
Height(q) : FldRatElt -> RngIntElt
The height of q=r/s. For r and s coprime, the height is defined as the maximum of the absolute value of r and s.

Rounding and Truncating

Ceiling(q) : FldRatElt -> RngIntElt
The ceiling of the rational number q, that is, the least integer greater than or equal to q.
Floor(q) : FldRatElt -> RngIntElt
The floor of the rational number q, that is, the largest integer less than or equal to q.
Round(q) : FldRatElt -> RngIntElt
This function returns the integer value of the rational number q rounded to the nearest integer. In the case of a tie, rounding is done away from zero (that is, i + (1/2) is rounded to i + 1, for non-negative integers i and i - (1/2) is rounded to i - 1, for non-positive integers i).
Truncate(q) : FldRatElt -> RngIntElt
This function returns the integer truncation of the rational number q, that is the integral part of q. Thus the effect is that of rounding towards 0.
Qround(q, M) : FldRatElt, RngIntElt -> FldRatElt
    ContFrac: BoolElt                   Default: false
Finds a rational approximation d of q such that the denominator of d is bounded by M. If ContFrac is given then an optimal approximation is computed using the continued fraction process. By default d is obtained by some rounding procedure which is faster but gives worse results.

Continued Fractions

ContinuedFraction(r) : FldRatElt -> [ RngIntElt ]
Given a rational r, return the sequence of partial quotients of the continued fraction expansion of r.
ContinuedFractionValue(C) : [ RngIntElt ] -> FldRatElt
Given a continued fraction expansion C, return the rational r such that C equals ContinuedFraction(r).
HirzebruchJungContinuedFraction(r) : FldRatElt -> [ RngIntElt ]
HJContinuedFraction(r) : FldRatElt -> [ RngIntElt ]
Given a rational r, return the sequence of partial quotients of the Hirzebruch-Jung continued fraction expansion of r.
HirzebruchJungContinuedFractionValue(C) : [ RngIntElt ] -> FldRatElt
HJContinuedFractionValue(C) : [ RngIntElt ] -> FldRatElt
Given a Hirzebruch-Jung continued fraction expansion C, return the rational r so that HJContinuedFraction(r) equals C.

Rational Reconstruction

Under certain circumstances it is useful to have a partial inverse of the function ψm:Q -> Z/mZ of taking residues modulo m (where the obvious value of ψm is only defined for rational numbers with denominator in smallest terms coprime to m); the partial inverse of the function is sometimes referred to as `rational reconstruction'. For s∈Z/mZ the value of ψ - 1(s) is the rational number r for which ψm(r)=s and, in addition, the absolute values of both the numerator and denominator of r are at most Sqrt(m/2); such r does not always exist, but if r exists it is unique.

RationalReconstruction(s) : RngIntResElt -> BoolElt, FldRatElt
RationalReconstruction(s) : FldFinElt -> BoolElt, FldRatElt
Given an element s of a ring S of m elements, return a Boolean flag indicating whether or not a rational number r exists such that for the representation r=n/d in minimal terms it holds that n.d - 1 ≡ s mod m, |n|≤Sqrt(m/2) and 0 < d ≤Sqrt(m/2). If the flag is true, the element r is also returned. The ring S is allowed to be a residue class ring Integers(m) or a finite field of prime cardinality p=m: FiniteField(p).

In addition, s is allowed to be a matrix over a prime finite field, in which case the existence (and, if possible, value) of a rational reconstruction of the matrix is determined.

Valuation

Valuation(x, p) : FldRatElt, RngIntElt -> RngIntElt, FldRatElt
Valuation(x, I) : FldRatElt, RngIntElt -> RngIntElt, FldRatElt
The valuation v of the rational number x at the prime p (the prime ideal I). This is the difference of the valuations of the numerator and denominator of x. The optional second return value is the rational u such that x = pv u.

Sequence Conversions

ElementToSequence(a) : FldRatElt -> [FldRatElt]
Eltseq(a) : FldRatElt -> [FldRatElt]
The sequence [a] for compatibility with the other field types.
V2.28, 13 July 2023