tropical-0.0.0.2: A library for tropical mathematics.

Copyright2014, Peter Harpending.
LicenseBSD3
MaintainerPeter Harpending <pharpend2@gmail.com>
Stabilityexperimental
PortabilityLinux
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Semiring.Tropical

Contents

Description

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 ∈ 𝕋

Synopsis

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.

Constructors

Tropical

Any tropical number

Fields

realValue :: t
 
Infinity

Infinity

Instances

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 ∈ ℝ

Infinity is the additive identity, or zero, in Semiring terms.

Tropical multiplication is the sum. Because

a + 0 = 0, ∀ a ∈ ℝ

Tropical 0 is the multiplicative identity, or one in Semiring terms.

Tropical operations

(.+.) :: Semiring s => s -> s -> s

(.*.) :: Semiring s => s -> s -> s

(./.) :: 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 Operator a = a -> a -> a Source

Helper type for binary operators

type TropicalOperator a = Operator (Tropical a) Source

An operator over something tropical

zero :: Semiring s => s

one :: Semiring s => s