cifl-math-library-1.1.1.0: Math libraries
Safe HaskellSafe
LanguageHaskell2010

Math.Number.R

Synopsis

Documentation

newtype R Source #

This real representation takes epsilon as input as in epsilon-delta proof.

Constructors

Limit (Endo Rational) 

Instances

Instances details
Bounded R Source # 
Instance details

Defined in Math.Number.R

Methods

minBound :: R #

maxBound :: R #

Floating R Source #

trigonometric functions inverse trigonometric functions hyperbolic function

Instance details

Defined in Math.Number.R

Methods

pi :: R #

exp :: R -> R #

log :: R -> R #

sqrt :: R -> R #

(**) :: R -> R -> R #

logBase :: R -> R -> R #

sin :: R -> R #

cos :: R -> R #

tan :: R -> R #

asin :: R -> R #

acos :: R -> R #

atan :: R -> R #

sinh :: R -> R #

cosh :: R -> R #

tanh :: R -> R #

asinh :: R -> R #

acosh :: R -> R #

atanh :: R -> R #

log1p :: R -> R #

expm1 :: R -> R #

log1pexp :: R -> R #

log1mexp :: R -> R #

Num R Source #

Note zero reals are special, we avoid divide by zero by implementing zero as epsilon.

Instance details

Defined in Math.Number.R

Methods

(+) :: R -> R -> R #

(-) :: R -> R -> R #

(*) :: R -> R -> R #

negate :: R -> R #

abs :: R -> R #

signum :: R -> R #

fromInteger :: Integer -> R #

Fractional R Source #

For division, if a rational approximation of the divisor is zero, we increase accuracy. Notice this makes a real number constructed from "real (const 0)" behave much worse (nontermination) than "epsilon" (which just increases accuracy) Using L'H�pital's rule for 0/0 https://en.wikipedia.org/wiki/L%27H%C3%B4pital%27s_rule

Instance details

Defined in Math.Number.R

Methods

(/) :: R -> R -> R #

recip :: R -> R #

fromRational :: Rational -> R #

Show R Source # 
Instance details

Defined in Math.Number.R

Methods

showsPrec :: Int -> R -> ShowS #

show :: R -> String #

showList :: [R] -> ShowS #

ConjugateSymmetric R Source # 
Instance details

Defined in Math.Number.R

Methods

conj :: R -> R Source #

VectorSpace R Source #

R as an infinite dimensional vector space over the rationals.

Instance details

Defined in Math.Number.R

Associated Types

type Scalar R Source #

Methods

vzero :: R Source #

vnegate :: R -> R Source #

(%+) :: R -> R -> R Source #

(%*) :: Scalar R -> R -> R Source #

DifferentiallyClosed R Source # 
Instance details

Defined in Math.Number.R

Methods

derivate :: (R -> R) -> R -> R Source #

integral :: (R, R) -> (R -> R) -> R Source #

Infinitary R Source # 
Instance details

Defined in Math.Number.R

Methods

infinite :: R Source #

Numerics R Source # 
Instance details

Defined in Math.Number.R

Methods

newtons_method :: (R -> R) -> R -> R Source #

Closed R Source # 
Instance details

Defined in Math.Number.R

PpShow R Source # 
Instance details

Defined in Math.Number.R

Methods

pp :: R -> Doc Source #

CompleteSpace R Source # 
Instance details

Defined in Math.Number.R

Approximations Stream R Source # 
Instance details

Defined in Math.Number.R

DedekindCut Rational R Source #

tricky stuff. We use the denominator from the rational to determine what accuracy to use for comparison, then use rational comparison. Notice that this doesn't really allow good control of precision of computation, since rational numbers are normalized by default.

Instance details

Defined in Math.Number.R

DedekindCut Integer R Source # 
Instance details

Defined in Math.Number.R

Methods

(%<) :: Integer -> R -> Bool Source #

(<%) :: R -> Integer -> Bool Source #

(%>) :: Integer -> R -> Bool Source #

(>%) :: R -> Integer -> Bool Source #

is_apart :: R -> Integer -> R -> Bool Source #

DedekindCut Double R Source # 
Instance details

Defined in Math.Number.R

Methods

(%<) :: Double -> R -> Bool Source #

(<%) :: R -> Double -> Bool Source #

(%>) :: Double -> R -> Bool Source #

(>%) :: R -> Double -> Bool Source #

is_apart :: R -> Double -> R -> Bool Source #

DedekindCut Float R Source # 
Instance details

Defined in Math.Number.R

Methods

(%<) :: Float -> R -> Bool Source #

(<%) :: R -> Float -> Bool Source #

(%>) :: Float -> R -> Bool Source #

(>%) :: R -> Float -> Bool Source #

is_apart :: R -> Float -> R -> Bool Source #

DedekindCut Int R Source # 
Instance details

Defined in Math.Number.R

Methods

(%<) :: Int -> R -> Bool Source #

(<%) :: R -> Int -> Bool Source #

(%>) :: Int -> R -> Bool Source #

(>%) :: R -> Int -> Bool Source #

is_apart :: R -> Int -> R -> Bool Source #

DedekindCut Word R Source # 
Instance details

Defined in Math.Number.R

Methods

(%<) :: Word -> R -> Bool Source #

(<%) :: R -> Word -> Bool Source #

(%>) :: Word -> R -> Bool Source #

(>%) :: R -> Word -> Bool Source #

is_apart :: R -> Word -> R -> Bool Source #

Infinitesimal Stream R Source # 
Instance details

Defined in Math.Number.R

Limiting Stream R Source # 
Instance details

Defined in Math.Number.R

Associated Types

data Closure Stream R Source #

Floating (Closure Stream R) Source # 
Instance details

Defined in Math.Number.R

Num (Closure Stream R) Source # 
Instance details

Defined in Math.Number.R

Fractional (Closure Stream R) Source # 
Instance details

Defined in Math.Number.R

ConjugateSymmetric (Closure Stream R) Source # 
Instance details

Defined in Math.Number.R

Infinitary (Closure Stream R) Source # 
Instance details

Defined in Math.Number.R

type Scalar R Source # 
Instance details

Defined in Math.Number.R

data Closure Stream R Source # 
Instance details

Defined in Math.Number.R

approximate :: R -> Rational -> Rational Source #

approximate takes a real \(r\), and a rational \(q\) and produces a rational \(q_2\) such that \(|r - q_2| \le q\)

\(r_1 (r_2 q) = (r_1 r_2) q\), where \(r_1,r_2 \in {\mathbf{R}}\), \(q \in {\mathbf{Q}}\).

that is, \[{\mathbf{approximate}}(r_1) \circ {\mathbf{approximate}}(r_2) = {\mathbf{approximate}}(r_1 r_2)\] that is, \[{\mathbf{approximate}}(r_1,{\mathbf{approximate}}(r_2,q)) = {\mathbf{approximate}}(r_1 r_2, q)\] that is \[{\mathbf{approximate}}(r_1,q_3)=q_2 \Leftrightarrow |r_1 - q_2| \le q_3\] \[{\mathbf{approximate}}(r_2,q) =q_3 \Leftrightarrow |r_2 - q_3| \le q\] \[{\mathbf{approximate}}(r_1 r_2, q)=q_2 \Leftrightarrow |r_1 r_2 - q_2| \le q\] \[{\mathbf{approximate}}(r_1 r_2, q)={\mathbf{approximate}}(r_1,q_3)={\mathbf{approximate}}(r_1,{\mathbf{approximate}}(r_2,q))\] \[\Leftrightarrow |r_1 - q_2| \le q_3 \land |r_2 - q_3| \le q\]

average :: R -> R -> R Source #

liftR :: (Rational -> Rational) -> R -> R Source #

this propagates accuracy without changing it.

liftR2 :: (Rational -> Rational -> Rational) -> R -> R -> R Source #

this propagates accuracy without changing it

inverseImage :: (Rational -> Rational) -> R -> R Source #

inverseImage transforms accuracy computation of the real.

liftWithAccuracy :: (Rational -> Rational) -> (Rational -> Rational) -> R -> R Source #

The first argument is the function lifted. The second argument describes change in accuracy by the function.

approximate_as :: R -> R -> R Source #

approx_compose will use the second real as the level of approximation to compute the first.

differentialLiftR :: (Rational -> Rational) -> R -> R Source #

This lifts a rational function to a real function. This computes accuracy using the formula \(dx = df / f'(x)\). The accuracy behaves badly when \(f'(x) = 0\) due to divide-by-zero.

derivate_rational :: Rational -> (Rational -> Rational) -> Rational -> Rational Source #

derivate for rational functions. The first argument is epsilon.

derivate_r :: (R -> R) -> R -> R Source #

computes derivate. \[{{df}\over{dt}} = \lim_{\epsilon\rightarrow 0}{{f(t+\epsilon)-f(t)}\over{\epsilon}}\]

newtons_method_r :: (R -> R) -> R -> R Source #

newton's method for finding root of function. \[x_{i+1} = x_i - {{f(x_i)}\over{f'(x_i)}}\]

sqrt_r :: R -> R Source #

square root of a real number \(x\), computed with newton's method as root of \(t \mapsto t^2 - x\).

log_by_newton :: R -> R Source #

logarithm of a real number \(x\), computed with newton's method as root of \(t \mapsto e^t - x\).

exp_r :: R -> R Source #

pi_r :: R Source #

Using Simon Plouffe's BPP digit extraction algorithm for computing pi. See https://plouffe.fr/Simon%20Plouffe.htm See Pi for details. \[\pi = \sum_{k=0}^{\infty}{16^{-k}}({{4}\over{8k+1}}-{{2}\over{8k+4}}-{1\over{8k+5}}-{1\over{8k+6}})\]

log_r :: R -> R Source #

integral_r :: (R, R) -> (R -> R) -> R Source #

foldable_integral :: (Foldable t, Functor t) => (Rational -> t b) -> (b -> R) -> R Source #

foldable_simple_integral :: (Num a, Foldable t, Functor t) => (a -> t b) -> (b -> a) -> a -> a Source #

integral_accuracy :: Fractional t => (t -> R) -> R -> R -> Rational -> [Rational] Source #

sin_by_series :: R -> R Source #

trigonometric functions Computed using taylor series expansion of sin function. \[\sin(x) = \sum_{k=0}^{\infty}{{{(-1)^k}\over{(2k+1)!}}{x^{2k+1}}}\]

inverse_of_r :: (R -> R) -> R -> R Source #

cos_by_series :: R -> R Source #

trigonometric functions Computed using taylor series expansion of cos function. \[\cos(x) = \sum_{k=0}^{\infty}{{{(-1)^k}\over{(2k)!}}{x^{2k}}}\]

lub_r :: [R] -> Maybe R Source #

glb_r :: [R] -> Maybe R Source #

computable_r :: (Rational -> Rational -> Rational) -> R Source #

For \(a,b \in {\mathbb Q}\) and \(0 \in (a,b) \) the invocation \(f(a)(b)\) of \(f\) in \(computable\_r(f)\) must produce approximation \(q\) of another real \(r\) as rational number, such that \( r - q \in (a,b) \).

unsafe_real_to_rational :: R -> Rational Source #

this real_to_rational operation sets precision \(\epsilon\) to 0 and produces corresponding rational number. Many algorithms for reals will go to infinite loop, if this is used, or produce divide-by-zero. In particular, this is expected for irrationals. if rational number is produced, it's exact. However, computations on rational numbers, where real number was created using fromRational, will produce that rational. It also allows operations lifted from rationals to work, producing the result you'd obtain from rational numbers.

floor_r :: Integral b => R -> b Source #

ceiling_r :: Integral b => R -> b Source #

round_r :: Integral b => R -> b Source #

max_r :: R -> R -> R Source #

min_r :: R -> R -> R Source #