arithmoi-0.13.0.0: Efficient basic number-theoretic functions.

Copyright | (c) 2018 Alexandre Rodrigues Baldé Andrew Lelechenko
License | MIT
Maintainer | Andrew Lelechenko <andrew.lelechenko@gmail.com>
Safe Haskell | Safe-Inferred
Language | Haskell2010

Math.NumberTheory.Zeta

Contents

- Riemann zeta-function
- Dirichlet beta-function
- Hurwitz zeta-functions

Description

Numeric evaluation of various zeta-functions.

Synopsis

- zetas :: (Floating a, Ord a) => a -> Infinite a
- zetasEven :: Infinite ExactPi
- betas :: (Floating a, Ord a) => a -> Infinite a
- betasOdd :: Infinite ExactPi
- zetaHurwitz :: forall a. (Floating a, Ord a) => a -> a -> Infinite a

# Riemann zeta-function

zetas :: (Floating a, Ord a) => a -> Infinite a Source #

Infinite sequence of approximate (up to given precision) values of Riemann zeta-function at integer arguments, starting with `ζ(0)`.

    >>> take 5 (zetas 1e-14) :: [Double]
    [-0.5,Infinity,1.6449340668482264,1.2020569031595942,1.0823232337111381]

Beware to force evaluation of `zetas !! 1` if the type `a` does not support infinite values (for instance, `Fixed`).

zetasEven :: Infinite ExactPi Source #

Infinite sequence of exact values of Riemann zeta-function at even arguments, starting with `ζ(0)`. Note that due to numerical errors conversion to `Double` may return values below 1:

    >>> approximateValue (zetasEven !! 25) :: Double
    0.9999999999999996

Use your favorite type for long-precision arithmetic. For instance, `Fixed` works fine:

    >>> import Data.Number.Fixed
    >>> approximateValue (zetasEven !! 25) :: Fixed Prec50
    1.00000000000000088817842111574532859293035196051773

# Dirichlet beta-function

betas :: (Floating a, Ord a) => a -> Infinite a Source #

Infinite sequence of approximate (up to given precision) values of Dirichlet beta-function at integer arguments, starting with `β(0)`.

    >>> take 5 (betas 1e-14) :: [Double]
    [0.5,0.7853981633974483,0.9159655941772189,0.9689461462593694,0.9889445517411051]

betasOdd :: Infinite ExactPi Source #

Infinite sequence of exact values of Dirichlet beta-function at odd arguments, starting with `β(1)`.

    >>> import Data.ExactPi
    >>> approximateValue (betasOdd !! 25) :: Double
    0.9999999999999987
    >>> import Data.Number.Fixed
    >>> approximateValue (betasOdd !! 25) :: Fixed Prec50
    0.99999999999999999999999960726927497384196726751694

# Hurwitz zeta-functions

zetaHurwitz :: forall a. (Floating a, Ord a) => a -> a -> Infinite a Source #

Values of Hurwitz zeta function evaluated at `ζ(s, a)` for `s ∈ [0, 1 ..]`.

The algorithm used was based on the Euler-Maclaurin formula and was derived from Fast and Rigorous Computation of Special Functions to High Precision by F. Johansson, chapter 4.8, formula 4.8.5. The error for each value in this recurrence is given in formula 4.8.9 as an indefinite integral, and in formula 4.8.12 as a closed form formula.

It is the user's responsibility to provide an appropriate precision for the type chosen.

For instance, when using `Double`s, it does not make sense to provide a number `ε < 1e-53` as the desired precision. For `Float`s, providing an `ε < 1e-24` also does not make sense. Example of how to call the function:

    >>> zetaHurwitz 1e-15 0.25 !! 5
    1024.3489745265808