Orbital library

## orbital.math Interface Fraction

All Superinterfaces:
Arithmetic, Normed

`public interface Fractionextends Arithmetic`

Representation of a fraction a⁄s ∈ S-1M = MS.

S-1M := MS := M×S/~ = {a⁄s ¦ a∈M ∧ s∈S} with congruence relation ~ defined by

a⁄s ~ b⁄t :⇔ ∃sʹ∈S sʹ⋅(a⋅t-b⋅s)=0 (⇔ a⋅t-b⋅s = 0 if M is an integrity domain)
is the RS-module (or ring or monoid) of fractions of the R-module (or commutative ring with 1 or monoid) M with denominators in S≤(R,⋅). This means that S≤(R,⋅) is a submonoid of the multiplicative group of R. S-1M is also called localisation of M to S. If p⊲R is prime, then Rp := RR\p is called localisation of R in p and is a local ring.

Especially, for an integrity domain R, Quot(R) := R(0) = (R∖{0})-1R is the field of fractions of R, and for R-modules M, MR∖{0} is a Quot(R)-vector space. If the underlying integrity domain R has an order, its field of fractions supports a unique order that restricts to the order on R (an extends `Comparable`).

A fraction a⁄s ∈ S-1M with numerator a and denominator s is usually written as

```  a
s
```

There is the canonical embedding homomorphism ιS:a↦a⁄1 which is injective if and only if S does not contain zero divisors. The ring of fractions RSis the presenting object of the presentable functor

 Rng1 → Ens R' ↦ {φ∈HomRng1(R,R') ¦ φ(S)⊆(R')×}
Therefore it enjoys the following universal mapping property
∀φ:R→R' homomorphism of rings with 1 with φ(S)⊆(R')×
∃!φ̃:RS→R' homomorphism of rings with 1 where φ=φ̃∘ιS

For R-modules M and S≤(R,⋅) it is

∀I⊴R MS ≅ M ⊗R RS

Author:
André Platzer
`ValueFactory.fraction(Arithmetic,Arithmetic)`, "N. Bourbaki, Algebra I.2.4: Monoid of fractions of a commutative monoid.", "N. Bourbaki, Algebra VI.2.2: Ordered fields."

Field Summary

Fields inherited from interface orbital.math.Arithmetic
`numerical`

Method Summary
` Fraction` `add(Fraction bt)`
Adds two fractions returning a third as a result.
` Arithmetic` `denominator()`
Returns the denominator component.
` Fraction` `divide(Fraction bt)`
Divides two fractions returning a third as a result.
` Fraction` `multiply(Fraction bt)`
Multiplies two fractions returning a third as a result.
` Arithmetic` `numerator()`
Returns the numerator component.
` Arithmetic` `scale(Arithmetic alpha)`
Multiplies a scalar with this arithmetic object returning the result.
` Fraction` `subtract(Fraction bt)`
Subtracts two fractions returning a third as a result.

Methods inherited from interface orbital.math.Arithmetic
`add, divide, equals, inverse, isOne, isZero, minus, multiply, one, power, subtract, toString, valueFactory, zero`

Methods inherited from interface orbital.math.Normed
`norm`

Method Detail

### numerator

`Arithmetic numerator()`
Returns the numerator component.

Returns:
a of this fraction a⁄s.

### denominator

`Arithmetic denominator()`
Returns the denominator component.

Returns:
s of this fraction a⁄s.

`Fraction add(Fraction bt)`
Adds two fractions returning a third as a result.

Returns:
a⁄s + b⁄t := (a⋅t+b⋅s)⁄(s⋅t).

### subtract

`Fraction subtract(Fraction bt)`
Subtracts two fractions returning a third as a result.

Returns:
a⁄s - b⁄t := (a⋅t-b⋅s)⁄(s⋅t).

### multiply

`Fraction multiply(Fraction bt)`
Multiplies two fractions returning a third as a result.

Returns:
a⁄s ⋅ b⁄t := (a⋅b)⁄(s⋅t).

### divide

`Fraction divide(Fraction bt)`
Divides two fractions returning a third as a result.

Returns:
a⁄s ∕ b⁄t := (a⋅t)⁄(s⋅b).
Throws:
`java.lang.ArithmeticException` - if b∉S and b is not invertible.
Preconditions:
b∈S ∨ b invertible anyway

### scale

`Arithmetic scale(Arithmetic alpha)`
Multiplies a scalar with this arithmetic object returning the result.

Specified by:
`scale` in interface `Arithmetic`
Parameters:
`alpha` - the factor α to scale this arithmetic object with (per law of action of scalar multiplication).
Returns:
α·this
`Arithmetic.multiply(Arithmetic)`