numhask-0.11.1.0: A numeric class hierarchy.
Safe HaskellSafe-Inferred
LanguageGHC2021

NumHask.Algebra.Field

Description

Field classes

Synopsis

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

Minimal complete definition

exp, log

Methods

exp :: a -> a Source #

log :: a -> a Source #

(**) :: a -> a -> a Source #

logBase :: a -> a -> a Source #

log to the base of

>>> logBase 2 8
2.9999999999999996

sqrt :: a -> a Source #

square root

>>> sqrt 4
2.0

Instances

Instances details
ExpField Double Source # 
Instance details

Defined in NumHask.Algebra.Field

ExpField Float Source # 
Instance details

Defined in NumHask.Algebra.Field

(Ord a, TrigField a, ExpField a) => ExpField (EuclideanPair a) Source # 
Instance details

Defined in NumHask.Algebra.Metric

(Ord a, TrigField a, ExpField a) => ExpField (Complex a) Source # 
Instance details

Defined in NumHask.Data.Complex

ExpField b => ExpField (a -> b) Source # 
Instance details

Defined in NumHask.Algebra.Field

Methods

exp :: (a -> b) -> a -> b Source #

log :: (a -> b) -> a -> b Source #

(**) :: (a -> b) -> (a -> b) -> a -> b Source #

logBase :: (a -> b) -> (a -> b) -> a -> b Source #

sqrt :: (a -> b) -> a -> b Source #

class Field a => QuotientField a where Source #

Quotienting of a Field into a Ring

See Field of fractions

\a -> a - one < floor a <= a <= ceiling a < a + one

Minimal complete definition

properFraction

Associated Types

type Whole a :: Type Source #

Methods

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

default round :: (Integral (Whole a), Eq (Whole a), Ord a, Ring (Whole a)) => a -> Whole a Source #

ceiling :: Distributive (Whole a) => a -> Whole a Source #

supply the next upper whole component

>>> ceiling (1.001 :: Double)
2

default ceiling :: (Ord a, Distributive (Whole a)) => a -> Whole a Source #

floor :: Ring (Whole a) => a -> Whole a Source #

supply the previous lower whole component

>>> floor (1.001 :: Double)
1

default floor :: (Ord a, Ring (Whole a)) => a -> Whole a Source #

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

default truncate :: (Ord a, Ring (Whole a)) => a -> Whole a Source #

Instances

Instances details
QuotientField Double Source # 
Instance details

Defined in NumHask.Algebra.Field

Associated Types

type Whole Double Source #

QuotientField Float Source # 
Instance details

Defined in NumHask.Algebra.Field

Associated Types

type Whole Float Source #

(Eq (Whole a), Ring (Whole a), QuotientField a) => QuotientField (EuclideanPair a) Source # 
Instance details

Defined in NumHask.Algebra.Metric

Associated Types

type Whole (EuclideanPair a) Source #

(Eq (Whole a), Ring (Whole a), QuotientField a) => QuotientField (Complex a) Source # 
Instance details

Defined in NumHask.Data.Complex

Associated Types

type Whole (Complex a) Source #

(Ord a, EndoBased a, Absolute a, ToInt a, Integral a, Ring a) => QuotientField (Ratio a) Source # 
Instance details

Defined in NumHask.Data.Rational

Associated Types

type Whole (Ratio a) Source #

infinity :: Field a => a Source #

infinity is defined for any Field.

>>> one / zero + infinity
Infinity
>>> infinity + 1
Infinity

negInfinity :: Field a => a Source #

negative infinity

>>> negInfinity + infinity
NaN

nan :: Field a => a Source #

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

Minimal complete definition

pi, sin, cos, asin, acos, atan, atan2, sinh, cosh, asinh, acosh, atanh

Methods

pi :: a Source #

sin :: a -> a Source #

cos :: a -> a Source #

tan :: a -> a Source #

asin :: a -> a Source #

acos :: a -> a Source #

atan :: a -> a Source #

atan2 :: a -> a -> a Source #

sinh :: a -> a Source #

cosh :: a -> a Source #

tanh :: a -> a Source #

asinh :: a -> a Source #

acosh :: a -> a Source #

atanh :: a -> a Source #

Instances

Instances details
TrigField Double Source # 
Instance details

Defined in NumHask.Algebra.Field

TrigField Float Source # 
Instance details

Defined in NumHask.Algebra.Field

TrigField b => TrigField (a -> b) Source # 
Instance details

Defined in NumHask.Algebra.Field

Methods

pi :: a -> b Source #

sin :: (a -> b) -> a -> b Source #

cos :: (a -> b) -> a -> b Source #

tan :: (a -> b) -> a -> b Source #

asin :: (a -> b) -> a -> b Source #

acos :: (a -> b) -> a -> b Source #

atan :: (a -> b) -> a -> b Source #

atan2 :: (a -> b) -> (a -> b) -> a -> b Source #

sinh :: (a -> b) -> a -> b Source #

cosh :: (a -> b) -> a -> b Source #

tanh :: (a -> b) -> a -> b Source #

asinh :: (a -> b) -> a -> b Source #

acosh :: (a -> b) -> a -> b Source #

atanh :: (a -> b) -> a -> b Source #

half :: Field a => a Source #

A half is a Field because it requires addition, multiplication and division.

>>> half :: Double
0.5