Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Data.Number
Description
A library for real number arithmetics
- data Continued a
- type Number = Continued Nat
- data Nat
- data Whole = Whole Nat Sign
- fromList :: [Nat] -> Number
- toList :: Number -> [Nat]
- fromNumber :: RealFrac a => Number -> a
- toNumber :: RealFrac a => a -> Number
- σ :: Number
- φ :: Number
- π :: Number
- e :: Number
- hom :: Hom -> Number -> Number
- biHom :: BiHom -> Number -> Number -> Number
- cut :: Nat -> Number -> Number
Classes
Continued fraction type
Represents a simple continued fraction of the form:
Supports Haskell arithmetic operators though the use of the operator
function is to be preferred since provide shortcuts to calculations.
It can be an infinite sequence. Be careful with functions like show
and precision
: they may not terminate.
Cons operator
n :| x
equivalent to n
+ 1/x
Negate operator
M x
equivalent to -x
Lazy Peano numbers. Allow calculation with infinite values.
Instances
Bounded Nat Source | The lower bound is zero, the upper bound is infinity. |
Enum Nat Source | The |
Eq Nat Source | |
Integral Nat Source | Since negative numbers are not allowed,
n |
Num Nat Source | Addition, multiplication, and subtraction are lazy in both arguments, meaning that, in the case of infinite values, they can produce an infinite stream of S-constructors. As long as the callers of these functions only consume a finite amount of these, the program will not hang.
|
Ord Nat Source | All methods work as long as at least one operand is finite. |
Real Nat Source | Since |
Show Nat Source | |
Peano Nat Source | Peano class instance |
Whole numbers (Z).
Instances
Bounded Whole Source | The bounds are negative and positive infinity. |
Enum Whole Source |
|
Eq Whole Source | Positive and negative zero are considered equal. |
Integral Whole Source | Integer conversions and division |
Num Whole Source | Implements arithmetics for Whole numbers |
Ord Whole Source | The ordering is the standard total order on Z. Positive and negative zero are equal. |
Real Whole Source | Since |
Peano Whole Source | Peano class instance defines infinity (positive) and other functions handling the sign |
Functions
Constants
Internals
hom :: Hom -> Number -> Number Source
Homographic function
Given the Hom
matrix
and a Number
x
calculates
See http://perl.plover.com/yak/cftalk/INFO/gosper.txt for a complete explanation.