cdar-mBound-0.1.0.4: Exact real arithmetic using Centred Dyadic Approximations
Safe HaskellNone
LanguageHaskell2010

Data.CDAR.Dyadic

Description

The Dyadic module provides dyadic numbers. Syntax for dyadic number 'a * 2 ^ s' is 'a :^ s'. The exponent s is an Int, but the a is an arbitrary Integer.

Synopsis

Documentation

data Dyadic Source #

The Dyadic data type.

Constructors

Integer :^ Int infix 8 

Instances

Instances details
Eq Dyadic Source # 
Instance details

Defined in Data.CDAR.Dyadic

Methods

(==) :: Dyadic -> Dyadic -> Bool #

(/=) :: Dyadic -> Dyadic -> Bool #

Num Dyadic Source # 
Instance details

Defined in Data.CDAR.Dyadic

Ord Dyadic Source # 
Instance details

Defined in Data.CDAR.Dyadic

Read Dyadic Source # 
Instance details

Defined in Data.CDAR.Dyadic

Real Dyadic Source # 
Instance details

Defined in Data.CDAR.Dyadic

Show Dyadic Source # 
Instance details

Defined in Data.CDAR.Dyadic

Scalable Dyadic Source # 
Instance details

Defined in Data.CDAR.Dyadic

Methods

scale :: Dyadic -> Int -> Dyadic Source #

shiftD :: Int -> Dyadic -> Dyadic Source #

Shift a dyadic number to a given base and round in case of right shifts.

sqrtD :: Int -> Dyadic -> Dyadic Source #

Computes the square root of a Dyadic number to the specified base. The Newton-Raphson method may overestimates the square root, but the overestimate is bounded by 1 ulp. For example, sqrtD 0 2 will give 2, whereas the closest integer to the square root is 1. Need double precision to guarantee correct rounding, which was not considered worthwhile.

This is actually Heron's method and is no longer used in Approx as it is faster to use sqrtRecD.

sqrtD' :: Int -> Dyadic -> Dyadic -> Dyadic Source #

Square root with initial approximation as third argument.

sqrtRecD :: Int -> Dyadic -> Dyadic Source #

Reciprocal of square root using Newton's iteration.

sqrtRecD' :: Int -> Dyadic -> Dyadic -> Dyadic Source #

Reciprocal of square root using Newton's iteration with inital value as third argument.

initSqrtRecD :: Dyadic -> Dyadic Source #

Gives initial values for the iteration. Based on the three most significant bits of the argument. Should consider to use machine floating point to give initial value.

piMachinD :: Int -> Dyadic Source #

Compute dyadic values close to pi by Machin's formula.

piBorweinD :: Int -> Dyadic Source #

Compute dyadic values close to pi by Borwein's formula.

ln2D :: Int -> Dyadic Source #

Compute dyadic values close to ln 2.