Dieses Modul stellt numerische Hilfsfunktionen bereit.
- type NonnegativeRational = Rational
- unsafeFromRational ∷ Rational → Integer
- roundDownToRecipN ∷ Rational → PositiveNat
- roundUp ∷ Rational → Integer
- ilogb ∷ PositiveNat → Nat → Integer
- ilogbUp ∷ PositiveNat → Nat → Integer
- squareRoot ∷ Nat → Nat
- squareRootBounds ∷ NonnegativeRational → (NonnegativeRational, NonnegativeRational)
- primeFactors ∷ Integer → [(Integer, Integer)]
- positiveDivisors ∷ Integer → [Integer]
- sqrt2Seq ∷ PositiveNat → Rational
- goldenRatioSeq ∷ PositiveNat → Rational
- check_NumericHelper ∷ IO ()
Documentation
type NonnegativeRational = Rational
Approximation an den Typ nichtnegativer rationaler Zahlen.
unsafeFromRational ∷ Rational → Integer
Ist eine rationale Zahl x sogar eine ganze Zahl, so liefert unsafeFromRational x diese ganze Zahl. Sonst wirft sie eine Laufzeitausnahme.
roundDownToRecipN ∷ Rational → PositiveNat
Findet zu einer gegebenen rationalen Zahl x > 0 die kleinste positive Zahl n mit n^(-1) < x.
roundUp ∷ Rational → Integer
Rundet eine gegebene rationale Zahl x zur naechsten ganzen Zahl auf (also Richtung +).
ilogb ∷ PositiveNat → Nat → Integer
ilog b n == Abrundung von log_b n.
Quelle: http://www.haskell.org/pipermail/haskell-cafe/2009-August/065845.html
ilogbUp ∷ PositiveNat → Nat → Integer
squareRoot ∷ Nat → Nat
Bestimmt zu einer gegebenen nichtnegativen ganzen Zahl n die Abrundung ihrer nichtnegativen Quadratwurzel.
Quelle: http://www.haskell.org/haskellwiki/Generic_number_type#squareRoot
squareRootBounds ∷ NonnegativeRational → (NonnegativeRational, NonnegativeRational)
Bestimmt zu einer gegebenen nichtnegativen rationalen Zahl untere und obere Schranken fuer ihre Quadratwurzel.
primeFactors ∷ Integer → [(Integer, Integer)]
Bestimmt zu einer gegebenen ganzen Zahl n 0 ihre Primfaktorzerlegung (in positive Primzahlen). Die Vielfachheiten sind jeweils die zweiten Komponenten der Paare. Jeder Primfaktor kommt genau einmal in der Rueckgabeliste vor.
positiveDivisors ∷ Integer → [Integer]
Liefert alle positiven Teiler einer gegebenen ganzen Zahl n 0, auch 1 und den (Betrag der) Zahl selbst. Erfuellt folgende Spezifikation:
positiveDivisors n = [x | x <- [1..abs n], n `mod` x == 0]
sqrt2Seq ∷ PositiveNat → Rational
Liefert Approximationen an 2. Erfuellt folgende Spezifikation:
|sqrt2Seq n - 2| < 1/n fuer alle n >= 1.
goldenRatioSeq ∷ PositiveNat → Rational
Liefert Approximationen an den goldenen Schnitt. Erfuellt folgende Spezifikation:
|goldenRatioSeq n - | < 1/n fuer alle n >= 1.
check_NumericHelper ∷ IO ()