Copyright | 2014, Peter Harpending. |
---|---|
License | BSD3 |
Maintainer | Peter Harpending <pharpend2@gmail.com> |
Stability | experimental |
Portability | Linux |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This is a module for Tropical numbers. If you don't know what those are, read this Wikipedia entry.
Tropical numbers form a Semiring
. Semirings are like
normal rings, but
you can't subtract.
The Tropical semiring, or 𝕋, is {ℝ ∪ {∞}, ⊕, ⊙}. Those are, in Haskell
terms, Real
, Infinity
, '(.+.)', and '(.*.)', respectively.
Tropical addition and multiplication are
a ⊕ b = min {a, b}, ∀ a, b ∈ 𝕋
a ⊙ b = a + b, ∀ a, b ∈ 𝕋
Tropical things
data Real t => Tropical t Source
Tropical numbers are like real numbers, except zero is the same thing as Infinity, and you can't subtract.
Real t => Eq (Tropical t) | |
Real t => Ord (Tropical t) | |
(Real t, Show t) => Show (Tropical t) | |
Real a => Semiring (Tropical a) | Some notes - Tropical addition is the same as taking the minimum. Because min {a, ∞} = a, ∀ a ∈ ℝ
Tropical multiplication is the sum. Because a + 0 = 0, ∀ a ∈ ℝ
|
Tropical operations
(./.) :: Real a => TropicalOperator a Source
Tropical division. Remember, if Infinity is tropical zero, then you can't divide by it!
(.^.) :: Real a => TropicalOperator a Source
Tropical exponentiation - same as classical multiplication. A mildly interesting correlary is that tropical exponentiation is commutative. That is, y .^. x = x .^. y, for x and y tropical.
Helper Things
type TropicalOperator a = Operator (Tropical a) Source
An operator over something tropical