Improve docs
Add images and stuff
This commit is contained in:
parent
414ec21041
commit
6d3c89c8a6
@ -40,26 +40,26 @@ toList (x:|xs) = x : toList xs
|
|||||||
|
|
||||||
-- | The infinite continued fraction whose terms are naturals numbers
|
-- | The infinite continued fraction whose terms are naturals numbers
|
||||||
--
|
--
|
||||||
-- \[0, 1, 2, 3, 4,...\] = 0.6977746...
|
-- <<https://i.imgur.com/wYz0tig.png>>
|
||||||
σ :: Number
|
σ :: Number
|
||||||
σ = σ' 0 where
|
σ = σ' 0 where
|
||||||
σ' n = n :| σ' (succ n)
|
σ' n = n :| σ' (succ n)
|
||||||
|
|
||||||
-- | The golden ratio
|
-- | The golden ratio
|
||||||
--
|
--
|
||||||
-- φ = (1 + √5)/2 = 1.6180339...
|
-- <<https://i.imgur.com/3Yb5bWc.png>>
|
||||||
φ :: Number
|
φ :: Number
|
||||||
φ = 1 :| φ
|
φ = 1 :| φ
|
||||||
|
|
||||||
-- | Pi: the ratio of a circle's circumference to its diameter
|
-- | Pi: the ratio of a circle's circumference to its diameter
|
||||||
--
|
--
|
||||||
-- π = 3.1415926...
|
-- <<https://i.imgur.com/S1F6UoI.png>>
|
||||||
π :: Number
|
π :: Number
|
||||||
π = toNumber pi
|
π = toNumber pi
|
||||||
|
|
||||||
-- | Euler's number: the base of the natural logarithm
|
-- | Euler's number: the base of the natural logarithm
|
||||||
--
|
--
|
||||||
-- e = 2.7182818...
|
-- <<https://i.imgur.com/q1SwKoy.png>>
|
||||||
e :: Number
|
e :: Number
|
||||||
e = fmap a σ where
|
e = fmap a σ where
|
||||||
a n | p == 0 = 2*q
|
a n | p == 0 = 2*q
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
-- | Data.Number internals
|
-- | Data.Number internals
|
||||||
module Data.Number.Internal
|
module Data.Number.Internal
|
||||||
( operator
|
( Matrix
|
||||||
|
, operator
|
||||||
, cut
|
, cut
|
||||||
, first
|
, first
|
||||||
, rest
|
, rest
|
||||||
@ -18,8 +19,12 @@ type Matrix = (Whole, Whole, Whole, Whole, Whole, Whole, Whole, Whole)
|
|||||||
-- | Continued fraction operator (implements Gosper's arithmetics)
|
-- | Continued fraction operator (implements Gosper's arithmetics)
|
||||||
--
|
--
|
||||||
-- Given two 'Number' @x@, @y@ and the operator matrix
|
-- Given two 'Number' @x@, @y@ and the operator matrix
|
||||||
-- @\<a, b, c, d, e, f, g, h\>@
|
--
|
||||||
-- calculates @z = (a + bx + cy + dxy) / (e + fx + gy + hxy)@
|
-- <<https://i.imgur.com/Hm7TiIH.png>>
|
||||||
|
--
|
||||||
|
-- calculates
|
||||||
|
--
|
||||||
|
-- <<https://i.imgur.com/IZvQmy9.png>>
|
||||||
--
|
--
|
||||||
-- See <http://perl.plover.com/yak/cftalk/INFO/gosper.txt> for a complete
|
-- See <http://perl.plover.com/yak/cftalk/INFO/gosper.txt> for a complete
|
||||||
-- explanation.
|
-- explanation.
|
||||||
|
@ -5,11 +5,21 @@ import Data.Number.Peano
|
|||||||
|
|
||||||
infixr 5 :|
|
infixr 5 :|
|
||||||
-- | ==Continued fraction type
|
-- | ==Continued fraction type
|
||||||
-- represents a simple continued fraction of the form:
|
-- Represents a simple continued fraction of the form:
|
||||||
-- @[a0, a1, a2,...] = a0 + 1\/(a1 + 1\/(a2 + 1\/...))@
|
|
||||||
--
|
--
|
||||||
-- == /Cons/ operator
|
-- <<https://i.imgur.com/RgNIDHQ.png>>
|
||||||
|
--
|
||||||
|
-- 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@
|
-- @n :| x @ equivalent to @n@ + 1/@x@
|
||||||
|
--
|
||||||
|
-- === Negate operator
|
||||||
|
-- @M x @ equivalent to @-x@
|
||||||
data Continued a =
|
data Continued a =
|
||||||
M (Continued a) -- ^Negative number
|
M (Continued a) -- ^Negative number
|
||||||
| a :| (Continued a) -- ^Positive number
|
| a :| (Continued a) -- ^Positive number
|
||||||
|
Loading…
Reference in New Issue
Block a user