math-functions-0.3.1.0: Collection of tools for numeric computations

Numeric.Series

Description

Functions for working with infinite sequences. In particular summation of series and evaluation of continued fractions.

Synopsis

# Data type for infinite sequences.

data Sequence a #

Infinite series. It's represented as opaque state and step function.

Constructors

 Sequence s (s -> (a, s))
Instances
 # Instance detailsDefined in Numeric.Series Methodsfmap :: (a -> b) -> Sequence a -> Sequence b #(<\$) :: a -> Sequence b -> Sequence a # # Instance detailsDefined in Numeric.Series Methodspure :: a -> Sequence a #(<*>) :: Sequence (a -> b) -> Sequence a -> Sequence b #liftA2 :: (a -> b -> c) -> Sequence a -> Sequence b -> Sequence c #(*>) :: Sequence a -> Sequence b -> Sequence b #(<*) :: Sequence a -> Sequence b -> Sequence a # Fractional a => Fractional (Sequence a) # Elementwise operations with sequences Instance detailsDefined in Numeric.Series Methods(/) :: Sequence a -> Sequence a -> Sequence a #recip :: Sequence a -> Sequence a # Num a => Num (Sequence a) # Elementwise operations with sequences Instance detailsDefined in Numeric.Series Methods(+) :: Sequence a -> Sequence a -> Sequence a #(-) :: Sequence a -> Sequence a -> Sequence a #(*) :: Sequence a -> Sequence a -> Sequence a #negate :: Sequence a -> Sequence a #abs :: Sequence a -> Sequence a #signum :: Sequence a -> Sequence a #

# Constructors

enumSequenceFrom :: Num a => a -> Sequence a #

enumSequenceFrom x generate sequence:

$a_n = x + n$

enumSequenceFromStep :: Num a => a -> a -> Sequence a #

enumSequenceFromStep x d generate sequence:

$a_n = x + nd$

scanSequence :: (b -> a -> b) -> b -> Sequence a -> Sequence b #

Analog of scanl for sequence.

# Summation of series

Calculate sum of series

$\sum_{i=0}^\infty a_i$

Summation is stopped when

$a_{n+1} < \varepsilon\sum_{i=0}^n a_i$

where ε is machine precision (m_epsilon)

Calculate sum of series

$\sum_{i=0}^\infty x^ia_i$

Calculation is stopped when next value in series is less than ε·sum.

sequenceToList :: Sequence a -> [a] #

Convert series to infinite list

# Evaluation of continued fractions

Evaluate continued fraction using modified Lentz algorithm. Sequence contain pairs (a[i],b[i]) which form following expression:

$b_0 + \frac{a_1}{b_1+\frac{a_2}{b_2+\frac{a_3}{b_3 + \cdots}}}$

Modified Lentz algorithm is described in Numerical recipes 5.2 "Evaluation of Continued Fractions"