# 9.28 FractionΒΆ

The Fraction domain implements quotients. The elements must belong to a domain of category IntegralDomain: multiplication must be commutative and the product of two non-zero elements must not be zero. This allows you to make fractions of most things you would think of, but don’t expect to create a fraction of two matrices! The abbreviation for Fraction is FRAC.

Use / to create a fraction.

a := 11/12


 1112

Type: Fraction Integer

b := 23/24


 2324

Type: Fraction Integer

The standard arithmetic operations are available.

3 - a*b^2 + a + b/a


 31327176032

Type: Fraction Integer

Extract the numerator and denominator by using numernumerFraction and denomdenomFraction, respectively.

numer(a)


 11

Type: PositiveInteger

denom(b)


 24

Type: PositiveInteger

Operations like maxmaxFraction, minminFraction, negative?negative?Fraction, positive?positive?Fraction and zero?zero?Fraction are all available if they are provided for the numerators and denominators. See IntegerXmpPage for examples.

Don’t expect a useful answer from factorfactorFraction, gcdgcdFraction or lcmlcmFraction if you apply them to fractions.

r := (x^2 + 2*x + 1)/(x^2 - 2*x + 1)


 x2+2x+1x2-2x+1

Type: Fraction Polynomial Integer

Since all non-zero fractions are invertible, these operations have trivial definitions.

factor(r)


 x2+2x+1x2-2x+1

Type: Factored Fraction Polynomial Integer

Use mapmapFraction to apply factorfactorFraction to the numerator and denominator, which is probably what you mean.

map(factor,r)


 (x+1)2(x-1)2

Type: Fraction Factored Polynomial Integer

Other forms of fractions are available. Use continuedFraction to create a continued fraction.

continuedFraction(7/12)



Type: ContinuedFraction Integer

Use partialFraction to create a partial fraction. See ContinuedFractionXmpPage and PartialFractionXmpPage for additional information and examples.

partialFraction(7,12)


 1-322+13

Type: PartialFraction Integer

Use conversion to create alternative views of fractions with objects moved in and out of the numerator and denominator.

g := 2/3 + 4/5*%i


 23+45i

Type: Complex Fraction Integer

Conversion is discussed in detail in Section ugTypesConvertPage .

g :: FRAC COMPLEX INT


 10+12i15

Type: Fraction Complex Integer