ireal-0.2.3: Real numbers and intervals with relatively efficient exact arithmetic.

Safe HaskellSafe
LanguageHaskell98

Data.Number.IReal.FAD

Description

Simple forward automatic differentiation. The main reason for supplying this module rather than using one of several similar alternatives available on Hackage is that they all seem to use the following implementation of differentiation of products (in our notation):

x * y = mkDif (val x * val y) (df 1 x * y + x * df 1 y)

This is elegant but exponential in the order of differentiation, and hence unsuitable for much of validated numerics, which often uses moderately high order derivatives.

In our implementation, high order derivatives are still slow, but not as bad. Derivatives of order several hundred can be handled, but in type Double this is often useless; rounding errors dominate the result. In type IReal, results are reliable, but the deep nesting of the resulting expressions may lead to excessive precision requirements. Often Rounded is preferrable from an efficiency point of view.

No attempt is made to handle functions of several variables or perturbation confusion.

Synopsis

Documentation

newtype Dif a Source

A Dif value is an infinite list consisting of the values of an infinitely differentiable function and all its derivatives, all evaluated at a common point. Polynomials are represented by finite lists, omitting zero derivatives.

Constructors

D [a] 

Instances

(Num a, Eq a) => Eq (Dif a) Source 
(Floating a, Powers a) => Floating (Dif a) Source 
(Fractional a, Powers a) => Fractional (Dif a) Source 
Num a => Num (Dif a) Source 
(Num a, Ord a) => Ord (Dif a) Source 
Real a => Real (Dif a) Source 
(Powers a, RealFloat a) => RealFloat (Dif a) Source 
(Powers a, RealFrac a) => RealFrac (Dif a) Source 
Show a => Show (Dif a) Source 
(Num a, Powers a) => Powers (Dif a) Source 
VarPrec a => VarPrec (Dif a) Source 

con :: Num a => a -> Dif a Source

var :: Num a => a -> Dif a Source

mkDif :: a -> Dif a -> Dif a Source

val :: Num a => Dif a -> a Source

fromDif :: Num a => Dif a -> [a] Source

unDif :: (Num a, Num b) => (Dif a -> Dif b) -> a -> b Source

df :: Int -> Dif a -> Dif a Source

deriv :: (Num a, Num b) => Int -> (Dif a -> Dif b) -> a -> b Source

deriv n f is the n'th derivative of f (with derivative information omitted)

derivs :: (Num a, Num b) => (Dif a -> Dif b) -> a -> [b] Source

derivs f a is the list of allderivatives of f, evaluated at a.

chain :: Num a => (a -> a) -> (Dif a -> Dif a) -> Dif a -> Dif a Source

rchain :: Num a => (a -> a) -> (Dif a -> Dif a) -> Dif a -> Dif a Source

r2chain :: Num a => (a -> a) -> (a -> a) -> (Dif a -> Dif a) -> (Dif a -> Dif a) -> Dif a -> Dif a Source

convs :: Num t => [t] -> [t] -> [t] Source