]>
Book Contents Previous Section 9.27 Float Next Section 9.29 FullPartialFractionExpansion Book Index

## 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

11 12

Type: Fraction Integer
b := 23/24

23 24

Type: Fraction Integer

The standard arithmetic operations are available.

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

313271 76032

Type: Fraction Integer

Extract the numerator and denominator by using numer numer Fraction and denom denom Fraction, respectively.

numer(a)

11

Type: PositiveInteger
denom(b)

24

Type: PositiveInteger

Operations like max max Fraction, min min Fraction, 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 factor factor Fraction, gcd gcd Fraction or lcm lcm Fraction if you apply them to fractions.

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

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

Type: Fraction Polynomial Integer

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

factor(r)

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

Type: Factored Fraction Polynomial Integer

Use map map Fraction to apply factor factor Fraction 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-3 2 2+1 3

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

2 3+4 5 i

Type: Complex Fraction Integer

Conversion is discussed in detail in Section ugTypesConvertPage .

g :: FRAC COMPLEX INT

10+12 i 15

Type: Fraction Complex Integer
Book Contents Previous Section 9.27 Float Next Section 9.29 FullPartialFractionExpansion Book Index