factory-0.2.1.1: Rational arithmetic in an irrational world.

Safe HaskellSafe-Inferred
LanguageHaskell98

Factory.Math.Pi

Contents

Description

AUTHOR
Dr. Alistair Ward
DESCRIPTION
Defines the classes of Pi-algorithm which have been implemented.

Synopsis

Type-classes

class Algorithmic algorithm where Source

  • Defines the methods expected of a Pi-algorithm.
  • Most of the implementations naturally return a Rational, but the spigot-algorithms naturally produce a [Int]; though representing Pi as a big integer with the decimal point removed is clearly incorrect.
  • Since representing Pi as either a Rational or promoted to an Integer, is inconvenient, an alternative decimal String-representation is provided.

Minimal complete definition

openR

Methods

openR Source

Arguments

:: algorithm 
-> DecimalDigits 
-> Rational

Returns the value of Pi as a Rational.

openI Source

Arguments

:: algorithm 
-> DecimalDigits 
-> Integer

Returns the value of Pi, promoted by the required precision to form an integer.

openS Source

Arguments

:: algorithm 
-> DecimalDigits 
-> String

Returns the value of Pi as a decimal String.

Instances

Algorithmic Algorithm 
Algorithmic Algorithm 
Algorithmic squareRootAlgorithm => Algorithmic (Algorithm squareRootAlgorithm) 
(Algorithmic squareRootAlgorithm, Algorithmic factorialAlgorithm) => Algorithmic (Algorithm squareRootAlgorithm factorialAlgorithm) 
(Algorithmic squareRootAlgorithm, Algorithmic factorialAlgorithm) => Algorithmic (Algorithm squareRootAlgorithm factorialAlgorithm) 
(Algorithmic agm, Algorithmic bbp, Algorithmic borwein, Algorithmic ramanujan, Algorithmic spigot) => Algorithmic (Category agm bbp borwein ramanujan spigot) 

Types

Data-types

data Category agm bbp borwein ramanujan spigot Source

Categorises the various algorithms.

Constructors

AGM agm

Algorithms based on the Arithmetic-geometric Mean.

BBP bbp

http://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80%93Plouffe_formula.

Borwein borwein

http://en.wikipedia.org/wiki/Borwein%27s_algorithm.

Ramanujan ramanujan

http://www.pi314.net/eng/ramanujan.php.

Spigot spigot

Algorithms from which the digits of Pi slowly drip, one by one.

Instances

(Eq agm, Eq bbp, Eq borwein, Eq ramanujan, Eq spigot) => Eq (Category agm bbp borwein ramanujan spigot) 
(Read agm, Read bbp, Read borwein, Read ramanujan, Read spigot) => Read (Category agm bbp borwein ramanujan spigot) 
(Show agm, Show bbp, Show borwein, Show ramanujan, Show spigot) => Show (Category agm bbp borwein ramanujan spigot) 
(Defaultable agm, Defaultable bbp, Defaultable borwein, Defaultable ramanujan, Defaultable spigot) => Defaultable (Category agm bbp borwein ramanujan spigot) 
(Algorithmic agm, Algorithmic bbp, Algorithmic borwein, Algorithmic ramanujan, Algorithmic spigot) => Algorithmic (Category agm bbp borwein ramanujan spigot)