Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Field classes
Documentation
type Field a = (Ring a, Divisive a) Source #
A Field is a set on which addition, subtraction, multiplication, and division are defined. It is also assumed that multiplication is distributive over addition.
A summary of the rules inherited from super-classes of Field:
zero + a == a a + zero == a ((a + b) + c) (a + (b + c)) a + b == b + a a - a == zero negate a == zero - a negate a + a == zero a + negate a == zero one * a == a a * one == a ((a * b) * c) == (a * (b * c)) (a * (b + c)) == (a * b + a * c) ((a + b) * c) == (a * c + b * c) a * zero == zero zero * a == zero a / a == one || a == zero recip a == one / a || a == zero recip a * a == one || a == zero a * recip a == one || a == zero
class Field a => ExpField a where Source #
A hyperbolic field class
\a -> a < zero || (sqrt . (**2)) a == a
\a -> a < zero || (log . exp) a ~= a
\a b -> (b < zero) || a <= zero || a == 1 || abs (a ** logBase a b - b) < 10 * epsilon
logBase :: a -> a -> a Source #
log to the base of
>>>
logBase 2 8
2.9999999999999996
square root
>>>
sqrt 4
2.0
Instances
ExpField Double Source # | |
ExpField Float Source # | |
(Ord a, TrigField a, ExpField a) => ExpField (EuclideanPair a) Source # | |
Defined in NumHask.Algebra.Metric exp :: EuclideanPair a -> EuclideanPair a Source # log :: EuclideanPair a -> EuclideanPair a Source # (**) :: EuclideanPair a -> EuclideanPair a -> EuclideanPair a Source # logBase :: EuclideanPair a -> EuclideanPair a -> EuclideanPair a Source # sqrt :: EuclideanPair a -> EuclideanPair a Source # | |
(Ord a, TrigField a, ExpField a) => ExpField (Complex a) Source # | |
ExpField b => ExpField (a -> b) Source # | |
class Field a => QuotientField a where Source #
properFraction :: a -> (Whole a, a) Source #
round :: (Eq (Whole a), Ring (Whole a)) => a -> Whole a Source #
round to the nearest Int
Exact ties are managed by rounding down ties if the whole component is even.
>>>
round (1.5 :: Double)
2
>>>
round (2.5 :: Double)
2
ceiling :: Distributive (Whole a) => a -> Whole a Source #
supply the next upper whole component
>>>
ceiling (1.001 :: Double)
2
floor :: Ring (Whole a) => a -> Whole a Source #
supply the previous lower whole component
>>>
floor (1.001 :: Double)
1
truncate :: Ring (Whole a) => a -> Whole a Source #
supply the whole component closest to zero
>>>
floor (-1.001 :: Double)
-2
>>>
truncate (-1.001 :: Double)
-1
Instances
QuotientField Double Source # | |
QuotientField Float Source # | |
(Eq (Whole a), Ring (Whole a), QuotientField a) => QuotientField (EuclideanPair a) Source # | |
Defined in NumHask.Algebra.Metric type Whole (EuclideanPair a) Source # properFraction :: EuclideanPair a -> (Whole (EuclideanPair a), EuclideanPair a) Source # round :: EuclideanPair a -> Whole (EuclideanPair a) Source # ceiling :: EuclideanPair a -> Whole (EuclideanPair a) Source # floor :: EuclideanPair a -> Whole (EuclideanPair a) Source # truncate :: EuclideanPair a -> Whole (EuclideanPair a) Source # | |
(Eq (Whole a), Ring (Whole a), QuotientField a) => QuotientField (Complex a) Source # | |
Defined in NumHask.Data.Complex | |
(Ord a, EndoBased a, Absolute a, ToInt a, Integral a, Ring a) => QuotientField (Ratio a) Source # | |
Defined in NumHask.Data.Rational |
negInfinity :: Field a => a Source #
negative infinity
>>>
negInfinity + infinity
NaN
nan is defined as zero/zero
but note the (social) law:
>>>
nan == zero / zero
False
class Field a => TrigField a where Source #
Trigonometric Field
The list of laws is quite long: trigonometric identities