## `Dom::Fraction` -- the field of fractions of an integral domain

#### Introduction

`Dom::Fraction``(R)` creates a domain which represents the field of fractions of an integral domain R.

#### Domain

`Dom::Fraction(R)`

#### Parameters

`R` | - | an integral domain, i.e., a domain of category `Cat::IntegralDomain`

#### Details

- `Dom::Fraction``(R)` creates a domain which represents the field of fractions F = {x/y | x,y in R, y <> 0} of the integral domain R.
- An element of the domain `Dom::Fraction``(R)` has two operands, the numerator and denominator.
- If `Dom::Fraction``(R)` has the axiom `Ax::canonicalRep` (see below), the denominators have unit normal form and the gcds of numerators and denominators cancel.
- The domain `Dom::Fraction``(Dom::Integer)` represents the field of rational numbers. But the created domain is not the domain `Dom::Rational`, because it uses a different representation of its elements. Arithmetic in `Dom::Rational` is much more efficient than it is in `Dom::Fraction``(Dom::Integer)`.

#### Creating Elements

``Dom::Fraction`(R)(r)`

#### Parameters

`r` | - | a rational expression, or an element of `R`

#### Categories

`Cat::QuotientField(R)`
if `R` is a `Cat::DifferentialRing`, then
`Cat::DifferentialRing`
if `R` is a `Cat::PartialDifferentialRing`, then
`Cat::PartialDifferentialRing`

#### Related Domains

`Dom::Rational`

#### Details

- If `r` is a rational expression, then an element of the field of fractions `Dom::Fraction``(R)` is created by going through the operands of `r` and converting each operand into an element of `R`. The result of this process is `r` in the form x/y, where x and y are elements of `R`. If `R` has `Cat::GcdDomain`, then x and y are coprime.

  If one of the operands can not be converted into the domain `R`, an error message is issued.

#### Entries

characteristic

  is the characteristic of `R`.

coeffRing

  is the integral domain `R`.

one

  is the one of the field of fractions of `R`, i.e., the fraction 1/1.

zero

  is the zero of the field of fractions of `R`, i.e., the fraction 0/1.

#### Method _divide: divides two fractions

- `_divide(dom x, dom y)`
- - This method divides the fraction `x` by `y`, i.e., it computes x*y^(-1).
  - This method overloads the function `_divide` for fractions, i.e., one may use it in the form `x / y` or in functional notation: `_divide(x, y)`.

#### Method _invert: inverts a fraction

- `_invert(dom r)`
- - This method computes the inverse of r = x/y, i.e., it returns r^(-1) = y/x for x <> 0 (if x=0, then an error message is issued).
  - This method overloads the function `_invert` for fractions, i.e., one may use it in the form `1/r` or `r^(-1)`, or in functional notation: `_invert(r)`.

#### Method _less: less-than relation

- `_less(dom q, dom r)`
- - This method returns `TRUE` if q = xq/yq is smaller than r = xr/yr, i.e., if xq * yr < yq * xr.
  - An implementation is provided only if `R` is an ordered set, i.e., a domain of category `Cat::OrderedSet`.
  - This method overloads the function `_less` for fractions, i.e., one may use it in the form `q < r`, or in functional notation: `_less(q, r)`.

#### Method _mult: multiplies fractions by fractions or rational expressions

- `_mult(any q, any r)`
- - If `q` and `r` are both fractions of the same type, the product q * r is computed directly. The resulting fraction is normalized (see the methods `"normalize"` and `"normalizePrime"`).
  - If `q` is not of the domain type `Dom::Fraction``(R)`, it is considered as a rational expression which is converted into a fraction over `R` and multiplied with `q`. If the conversion fails, `FAIL` is returned.

    The same applies to `r`.

  - This method also handles more than two arguments. In this case, the argument list is splitted into two parts of the same length which both are multiplied with the function `_mult`. The two results are multiplied again with `_mult` whose result then is returned.
  - This method overloads the function `_mult` for fractions, i.e., one may use it in the form `q * r` or in functional notation: `_mult(q, r)`.

#### Method _negate: negates a fraction

- `_negate(dom r)`
- - This method computes -r by negating the numerator of r.
  - This method overloads the function `_negate` for fractions, i.e., one may use it in the form `-r` or in functional notation: `_negate(r)`.

#### Method _power: the integer power of a fraction

- `_power(dom r, integer n)`
- - This method computes r^n for integers `n`.
  - This method overloads the function `_power` for fractions, i.e., one may use it in the form `r^n` or in functional notation: `_power(r, n)`.

#### Method _plus: adds fractions

- `_plus(dom q, dom r...)`
- - Returns the sum q + r + ... of fractions. The returned fraction is normalized (see the methods `"normalize"` and `"normalizePrime"`).
  - If one of the arguments is not of the domain type `Dom::Fraction``(R)`, then `FAIL` is returned.
  - This method overloads the function `_plus` for fractions, i.e., one may use it in the form `q + r` or in functional notation: `_plus(q, r)`.

#### Method D: the differential operator

- `D(dom r)`
- - This method takes the derivative of the fraction r = x/y, i.e., it returns the fraction (D(x)*y - x*D(y)) / y^2.

    The resulting fraction is normalized (see the methods `"normalize"` and `"normalizePrime"`).

  - An implementation is provided only if `R` is a partial differential ring, i.e., a domain of category `Cat::PartialDifferentialRing`.
  - This method overloads the operator `D` for fractions, i.e., one may use it in the form `D(r)`.

#### Method denom: the denominator of a fraction

- `denom(dom r)`
- - This method returns the denominator of `r`, an element of the integral domain `R`.
  - This method overloads the function `denom` for fractions, i.e., one may use it in the form `denom(r)`.

#### Method diff: differentiation of fractions

- `diff(dom r, variable u)`
- - This method returns the fraction which results when differentiating the fraction r=x/y, i.e., it returns the fraction (diff(x,u)*y - x*diff(y,u)) / y^2.

    The resulting fraction is normalized (see the methods `"normalize"` and `"normalizePrime"`).

  - This method overloads the function `diff` for fractions, i.e., one may use it in the form `diff(r, u)`.
  - An implementation is provided only if `R` is a partial differential ring, i.e., a domain of category `Cat::PartialDifferentialRing`.

#### Method equal: test on equality of fractions

- `equal(dom q, dom r)`
- - This method tests if the fraction `q` is equal to `r`, and returns `TRUE`, `FALSE` or `UNKNOWN`, respectively.

#### Method factor: factorizes the numerator and denominator of a fraction

- `factor(dom r)`
- - This method factorizes the numerator and denominator of `r` into irreducible factors and returns `r` in the form r = u * r1^e1 * ... * rn^en.

    The result is a factored object, i.e., an element of the domain type `Factored`. Its factorization type is `"irreducible"` and the factorization ring is `R`.

  - The factors u, r1, ..., rn are fractions of type `Dom::Fraction``(R)`, the exponents e1, ..., en are integers.
  - The system function `factor` is used to perform the factorization of the numerator and denominator of `r`.
  - This method overloads the function `factor` for fractions, i.e., one may use it in the form `factor(r)`.

#### Method intmult: integer multiple of a fraction

- `intmult(dom r, integer n)`
- - This method computes n*r.

#### Method iszero: test for zero

- `iszero(dom r)`
- - This method returns `TRUE` if `r` is zero, and `FALSE` otherwise.
  - An element of the field `Dom::Fraction``(R)` is zero if its numerator is the zero element of `R`. Note that there may be more than one representation of the zero element if `R` does not have `Ax::canonicalRep`.
  - This method overloads the function `iszero` for fractions, i.e., one may use it in the form `iszero(r)`.

#### Method numer: the numerator of a fraction

- `numer(dom r)`
- - This method returns the numerator of `r`, an element of the integral domain `R`.
  - This method overloads the function `numer` for fractions, i.e., one may use it in the form `numer(r)`.

#### Method random: random fraction generation

- `random()`
- - This method returns a randomly generated fraction. It uses the method `"random"` of the domain `R` to randomly generate its numerator and denominator.
  - The returning fraction is normalized (see the methods `"normalize"` and `"normalizePrime"`.

#### Method convert_to: fraction conversion

- `convert_to(dom r, any T)`
- - This method tries to convert `r` into an element of the domain `T`, or, if `T` is not a domain, to the domain type of `T`.
  - If the conversion fails, `FAIL` is returned.
  - The conversion succeeds if `T` is one of the following domains: `Dom::Expression` or `Dom::ArithmeticalExpression`.
  - Use the function `expr` to convert `r` into an object of a kernel domain (see below).

#### Method expr: converts a fraction into an object of a kernel domain

- `expr(dom r)`
- - This method converts `r` into an expression by converting numerator and denominator into expressions (using the method `"expr"` of `R`).
  - The result is an object of a kernel domain (e.g., `DOM_RAT` or `DOM_EXPR`).
  - This method overloads the function `expr` for fractions, i.e., one may use it in the form `expr(r)`.

#### Method TeX: TeX formatting of a fraction

- `TeX(dom r)`
- - This method returns a TeX-formatted string for the fraction `r` in form of a TeX `\frac` construct.
  - The method `TeX` of the component ring `R` is used to get the TeX-representations of the numerator and denominator of `r`, respectively.

#### Method retract: retraction to base domain

- `retract(dom r)`
- - This method divides the numerator of `r` by the denominator of `r` and returns the result, if it is an element of `R`. Otherwise, `FAIL` is returned.

#### Method normalize: normalizing fractions

- `normalize(R x, R y)`
- - This method normalizes the fraction x / y which then is returned.
  - Normalization means to remove the gcd of `x` and `y`. Hence, `R` needs to be of category `Cat::GcdDomain`. Otherwise, normalization cannot be performed and the result of this method is the fraction x / y.

#### Method normalizePrime: normalizing fractions over integral domains with a gcd

- `normalizePrime(R x, R y)`
- - This method returns the fraction x / y. If `x` is zero, the fraction is normalized to zero.
  - In rings of category `Cat::GcdDomain`, elements are assumed to be relatively prime. Hence, there is no need to normalize the fraction x / y.
  - In rings not of category `Cat::GcdDomain`, normalization of elements can not be performed and the result of this method is the fraction x / y.

#### Example 1

We define the field of rational functions over the rationals:

    >> F := Dom::Fraction(Dom::Polynomial(Dom::Rational))

              Dom::Fraction(Dom::Polynomial(Dom::Rational, LexOrder))

and create an element of `F`:

    >> a := F(y/(x - 1) + 1/(x + 1))

                                  x + y + x y - 1
                                  ---------------
                                       2
                                      x  - 1

To calculate with such elements use the standard arithmetical operators:

    >> 2*a, 1/a, a*a

                                      2
          2 x + 2 y + 2 x y - 2      x  - 1
          ---------------------, ---------------,
                  2              x + y + x y - 1
                 x  - 1

                            2    2        2      2      2  2
             - 2 x - 2 y + x  + y  + 2 x y  + 2 x  y + x  y  + 1
             ---------------------------------------------------
                                    2    4
                               - 2 x  + x  + 1

Some system functions are overloaded for elements of domains generated by `Dom::Fraction`, such as `diff`, `numer` or `denom` (see the description of the corresponding methods `"diff"`, `"numer"` and `"denom"` above).

For example, to differentiate the fraction `a` with respect to `x` enter:

    >> diff(a, x)

                                             2    2
                          2 x - y - 2 x y - x  - x  y - 1
                          -------------------------------
                                       2    4
                                  - 2 x  + x  + 1

If one knows the variables in advance, then using the domain `Dom::DistributedPolynomial` yields a more efficient arithmetic of rational functions:

    >> Fxy := Dom::Fraction(
         Dom::DistributedPolynomial([x, y], Dom::Rational)
       )

          Dom::Fraction(Dom::DistributedPolynomial([x, y],

             Dom::Rational, LexOrder))

    >> b := Fxy(y/(x - 1) + 1/(x + 1)):
       b^3

                                  2    3      2    3        2      2
          (3 x + 3 y - 3 x y - 3 x  + x  - 3 y  + y  - 3 x y  - 3 x  y +

                  3      3        2  2      2  3      3  2    3  3
             3 x y  + 3 x  y + 3 x  y  + 3 x  y  + 3 x  y  + x  y  - 1) /

                 2      4    6
             (3 x  - 3 x  + x  - 1)

#### Example 2

We create the field of rational numbers as the field of fractions of the integers, i.e., Q = {x/y | x,y in Z }:

    >> Q := Dom::Fraction(Dom::Integer):
       Q(1/3)

                                        1/3

    >> domtype(%)

                            Dom::Fraction(Dom::Integer)

Another representation of Q in MuPAD is the domain `Dom::Rational` where the rationals are of the kernel domains `DOM_INT` and `DOM_RAT`. Therefore it is much more efficient to work with `Dom::Rational` than with `Dom::Fraction``(Dom::Integer)`.

#### Super-Domain

`Dom::BaseDomain`

#### Axioms

`Ax::normalRep`
if `R` has `Ax::canonicalRep`
if `R` is a `Cat::GcdDomain`
if `R` has `Ax::canonicalUnitNormal`
`Ax::canonicalRep`

#### Changes

- New method `"factor"` for factoring fractions.

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000