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

Math.Number.Real

Synopsis

Documentation

newtype R Source #

Problem with this representation: real number ranges cannot be represented. given two rational numbers \(r_1 < r_2\), it should be there are infinitely many real numbers between \(r_1\) and \(r_2\), so support density of irrationals. https://en.wikipedia.org/wiki/Dense_order

In constructive mathematics, given two real numbers \(r_1' < r_2'\), there should exist a rational number r, such that \(r_1' < r\) and \(r < r_2'\). HOWEVER, these comparisons are a type error for Eq class. In particular this cannot be used to _define_ how to compare two real numbers.

what is meant is if \(r_1' < r_2'\) then there exists a rational r such that \(r_1' < {\mathbf{fromRational}}(r)\) and \({\mathbf{fromRational}}(r) < r_2'\)

In here properties of \({\mathbf{fromRational}}\) are important. Note that comparisons invoke the real comparison, so at most is a recursive definition of real comparison in terms of itself. But it doesn't include termination condition.

It should be so that _if_ two real numbers \(r_1\) and \(r_2\) are not the same real number, then \(r_1 < r_2\) makes sense. But comparing whether two real numbers are the same is undecidable (algorithm for this comparison will not halt if they are same). Would this mean that if \(r_1 < r_2\) is computable, wouldn't \(\neg(r_1 < r_2 \lor r_2 < r_1)\) be computable equality of reals; This is computable in the limit , but not computable? https://en.wikipedia.org/wiki/Computation_in_the_limit

So we are forced to consider only comparison between a rational and a real, but not between two reals. This is encapsulated in the Math.Tools.Interface.DedekindCut type class.

The solution is that when comparing a rational with a real, the rational's denominator determines the accuracy used. This additional information makes comparison between a rational and a real decidable, but doesn't help when comparing two reals.

Constructors

Limit (Stream Rational) 

Instances

Instances details
Bounded R Source # 
Instance details

Defined in Math.Number.Real

Methods

minBound :: R #

maxBound :: R #

Enum R Source #

Enum instance for reals is undecidable with respect to end of real intervals, since comparison of two real numbers is undecidable. Thus enumFromTo and enumFromThenTo produce errors indicating density problem.

Instance details

Defined in Math.Number.Real

Methods

succ :: R -> R #

pred :: R -> R #

toEnum :: Int -> R #

fromEnum :: R -> Int #

enumFrom :: R -> [R] #

enumFromThen :: R -> R -> [R] #

enumFromTo :: R -> R -> [R] #

enumFromThenTo :: R -> R -> R -> [R] #

Floating R Source #

Using Simon Plouffe's BPP digit extraction algorithm for computing pi. See https://secure.wikimedia.org/wikipedia/en/wiki/Pi for details. exp: Exponential function log: Logarithm trigonometric functions inverse trigonometric functions hyperbolic function

Instance details

Defined in Math.Number.Real

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 # 
Instance details

Defined in Math.Number.Real

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 # 
Instance details

Defined in Math.Number.Real

Methods

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

recip :: R -> R #

fromRational :: Rational -> R #

Show R Source # 
Instance details

Defined in Math.Number.Real

Methods

showsPrec :: Int -> R -> ShowS #

show :: R -> String #

showList :: [R] -> ShowS #

ConjugateSymmetric R Source # 
Instance details

Defined in Math.Number.Real

Methods

conj :: R -> R Source #

InnerProductSpace R Source # 
Instance details

Defined in Math.Number.Real

Methods

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

MetricSpace R Source # 
Instance details

Defined in Math.Number.Real

Methods

distance :: R -> R -> Scalar R Source #

NormedSpace R Source # 
Instance details

Defined in Math.Number.Real

VectorSpace R Source # 
Instance details

Defined in Math.Number.Real

Associated Types

type Scalar R Source #

Methods

vzero :: R Source #

vnegate :: R -> R Source #

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

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

LiteralUnit R Source # 
Instance details

Defined in Math.Number.Units

Unit R Source # 
Instance details

Defined in Math.Number.Units

DifferentiallyClosed R Source # 
Instance details

Defined in Math.Number.Real

Methods

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

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

Infinitary R Source # 
Instance details

Defined in Math.Number.Real

Methods

infinite :: R Source #

Numerics R Source # 
Instance details

Defined in Math.Number.Real

Methods

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

ShowPrecision R Source # 
Instance details

Defined in Math.Number.Real

Closed R Source # 
Instance details

Defined in Math.Number.Real

PpShow R Source # 
Instance details

Defined in Math.Number.Real

Methods

pp :: R -> Doc Source #

(TypeError ('Text "Equality of constructive reals is undecidable." ':$$: 'Text "Please use (<%) and (%<) from Math.Number.Interface.DedekindCut class") :: Constraint) => Eq R Source # 
Instance details

Defined in Math.Number.Real

Methods

(==) :: R -> R -> Bool #

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

Approximations Stream R Source # 
Instance details

Defined in Math.Number.Real

DedekindCut Rational R Source # 
Instance details

Defined in Math.Number.Real

DedekindCut Integer R Source # 
Instance details

Defined in Math.Number.Real

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 Int R Source # 
Instance details

Defined in Math.Number.Real

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.Real

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 #

epsilon is a real that converges to zero.

Instance details

Defined in Math.Number.Real

Limiting Stream R Source #

The following instance declaration represents the completeness of the real number system.

Instance details

Defined in Math.Number.Real

Associated Types

data Closure Stream R Source #

MetricSpace (Stream R) Source # 
Instance details

Defined in Math.Number.Real

Floating (Closure Stream R) Source # 
Instance details

Defined in Math.Number.Real

Num (Closure Stream R) Source # 
Instance details

Defined in Math.Number.Real

Fractional (Closure Stream R) Source # 
Instance details

Defined in Math.Number.Real

Show (Closure Stream R) Source # 
Instance details

Defined in Math.Number.Real

MetricSpace (Closure Stream R) Source # 
Instance details

Defined in Math.Number.Real

VectorSpace (Closure Stream R) Source # 
Instance details

Defined in Math.Number.Real

Associated Types

type Scalar (Closure Stream R) Source #

DifferentiallyClosed (Closure Stream R) Source # 
Instance details

Defined in Math.Number.Real

Infinitary (Closure Stream R) Source # 
Instance details

Defined in Math.Number.Real

type Scalar R Source # 
Instance details

Defined in Math.Number.Real

type Scalar R = R
data Closure Stream R Source # 
Instance details

Defined in Math.Number.Real

type Scalar (Closure Stream R) Source # 
Instance details

Defined in Math.Number.Real

data Modulus Source #

Constructors

Modulus 

d :: Infinitesimal Stream a => (a -> a) -> a -> Closure Stream a Source #

d x = partial_derivate x

list_average :: Fractional a => [a] -> a Source #

cseq_difference_matrix :: (Functor m, Functor n, Diagonalizable m a, LinearTransform m n a, Num a) => m a -> n a -> (m :*: n) a Source #

cauchy_sequence_equivalence :: (ConjugateSymmetric a, Closed a, Num a) => Stream a -> Stream a -> Stream a Source #

See Suppes: Axiomatic Set Theory. Note that we would like to check that \[\forall \epsilon > 0. \exists n. \forall k > n. |s_k - t_k| < \epsilon \]. However, this is undecidable in particular with respect to what to choose for n. We can nonetheless compute the stream of distances.

cseq_equivalence_matrix :: (Num a, ConjugateSymmetric a, Closed a, Infinitesimal Stream eps) => (eps -> Integer) -> Stream a -> Stream a -> (Stream :*: Stream) a Source #

cseq_equivalence_matrix computes equivalence of cauchy sequences. However, the modulus argument is undecidable. But if you produce a modulus, this chooses the part of the cauchy sequence differences that should converge according to the convergence ratio of the epsilon from the infinitesimal instance. Thus if you can prove that the matrix elements converge to zero when elements of increasing index are chosen, you would have proven equality of the two cauchy sequences. This could be possible in special cases, even if it's undecidable in general. Note that it suffices to consider the convergence of the first column, because you could move any part to the first column by choosing reasonable values of the modulus. The other differences are included so computations and analysis of the situation can be easier to perform.

cseq_convergence :: (ConjugateSymmetric a, Closed a, Num a) => Stream a -> Stream a -> Stream [a] Source #

This version of cauchy sequence equality convergence check produces a stream of lists, where each list contains those elements which are close to each other in terms of choice of indices, e.g. \[C(s,t)_i = [ \lvert s_j - t_k \rvert | j \leftarrow naturals, k \leftarrow naturals, i = j + k]\] thus the complexity of the stream element lists of the result should increase in the same way than the complexity of the input stream elements. The lists in the result stream have monotonically increasing length. thus to compute results for particular level of approximation, it should suffice to choose a list from the result stream, and perform the equivalence check using the values in the list. To do this, it would be necessary to be able to determine how close to zero the elements in the list should be. the middle element (if any) of the list is probably the most interesting, because that would mean \(j == k\), therefore the computation result would be \(\lvert s_j - t_j \rvert\), but due to different rate of convergence of the input sequences, it can happen that the elementwise differences are not really representative of the stream convergence behaviour at the diagonal. however, analyzing these numbers should produce useful results about convergence of the input stream element differences. e.g choosing minimum and maximum element from each list determines best and worst approximation in the same depth of approximations. for the equality of the cauchy sequences to hold, the best approximation should stay close to zero and better so when further elements of the stream are obtained.

partial_derive :: (Closed a, Infinitesimal Stream a, Fractional a) => (a -> a -> a) -> (a -> a) -> a -> a Source #

\[ {\rm{partial\_derive}}(\Delta, f, x) = \lim_{\epsilon \rightarrow 0}{{f(\Delta_{\epsilon}(x)) - f(x)}\over{\Delta_{\epsilon}(x) - x}} \]

partial_derivate_closure :: (Limiting str a, Fractional a) => (a -> b -> b) -> (b -> a) -> b -> Endo (Closure str a) Source #

partial_derivate :: (Closed eps, Fractional eps) => (eps -> a -> a) -> (a -> eps) -> a -> eps Source #

\[ {\rm{partial\_derivate}}(\Delta, f, x) = \lim_{\epsilon \rightarrow 0}{{f(\Delta_{\epsilon}(x)) - f(x)}\over{\Delta_{\epsilon}(x) - x}} \]

partial_derivate_endo :: (Limiting str a, Fractional a) => (a -> Endo b) -> (b -> a) -> b -> Endo (Closure str a) Source #

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

completenessOfReals :: Closure Stream R :==: R Source #

An isomorphism \(Cl(R) \cong R\).

series :: (Integer -> R) -> R Source #

supremum_gen :: (Fractional a, Ord a, Limiting Stream a) => [Closure Stream a] -> Closure Stream a Source #

Least upper bound property | note this is really undecidable.

negate_limit :: (Limiting str a, Num a) => Closure str a -> Closure str a Source #

limiting_distance :: (Num a, Limiting str a) => Closure str a -> Closure str a -> Closure str a Source #

at_precision_rational :: R -> Rational -> Rational Source #

compute rational approximation more precise than the given rational the precision is expressed as rational number close to zero, the result will be within range \([r-p,r+p]\), in the sense that in the sequence of rational approximations \(r = (r_i | i \in {\mathbf N})\) we have \(\lvert r_{i+1} - r_i \rvert \leq p\). Note that we do _not_ attempt to prove that all successive approximations have this same property, we need the differences to be monotonically decreasing for this to represent correct precision.

at_precision :: R -> Integer -> R Source #

here precision is expresses as integer power of 10, e.g. \(1 == 10^{-1}\), \(2 == 10^{-2}\), \(3 == 10^{-3}\) and so on. so how many digits after the decimal point are required.

precision_rational :: R -> Integer -> Rational Source #

rational precision expressed as integer power of 10

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

derivate_closed :: Infinitesimal str a => (a -> a) -> a -> Closure str a Source #

vector_derivate :: (Infinitesimal str (Scalar a), VectorSpace a, Limiting str a) => (Scalar a -> a) -> Scalar a -> Closure str a Source #

derivates_at :: DifferentiallyClosed a => (a -> a) -> Stream a -> Stream a Source #

i'th element of derivates_at(f,s) is \(D^i[f](s_i)\)

derivate_around :: Infinitesimal str a => (a -> a) -> a -> Closure str a Source #

derivate_around doesn't require f to be defined at x, but requires limits from both sides of x to exist [it never evaluates f at x]. \[ \lim_{\epsilon \rightarrow 0} {{f(x+\epsilon)-f(x-\epsilon)}\over{2\epsilon}} \]

partial_derivate1_2 :: Infinitesimal str a => (a -> b -> a) -> a -> b -> Closure str a Source #

\[\lim_{\epsilon\rightarrow 0}{{f(a+\epsilon,b)-f(a,b)}\over{\epsilon}}\]

partial_derivate2_2 :: Infinitesimal str a => (b -> a -> a) -> b -> a -> Closure str a Source #

\[\lim_{\epsilon\rightarrow 0}{{f(a,b+\epsilon)-f(a,b)}\over{\epsilon}}\]

partial_derivate1_3 :: Infinitesimal str a => (a -> b -> c -> a) -> a -> b -> c -> Closure str a Source #

\[\lim_{\epsilon\rightarrow 0}{{f(a+\epsilon,b,c)-f(a,b,c)}\over{\epsilon}}\]

partial_derivate2_3 :: Infinitesimal str a => (b -> a -> c -> a) -> b -> a -> c -> Closure str a Source #

\[\lim_{\epsilon\rightarrow 0}{{f(a,b+\epsilon,c)-f(a,b,c)}\over{\epsilon}}\]

partial_derivate3_3 :: Infinitesimal str a => (b -> c -> a -> a) -> b -> c -> a -> Closure str a Source #

\[\lim_{\epsilon\rightarrow 0}{{f(a,b,c+\epsilon)-f(a,b,c)}\over{\epsilon}}\]

expo :: R -> R Source #

Exponential function using limit definition \(\exp(x) = \lim_{n\rightarrow\infty}(1+{{x}\over{n}})^n\).

newtons_method :: Numerics a => (a -> a) -> a -> a Source #

integrate_vector :: (Enum (Scalar a), VectorSpace a, Limiting str a, Limiting str (Scalar a)) => (Scalar a -> a) -> Closure str (Scalar a) -> (Scalar a, Scalar a) -> Closure str a Source #

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

integrate_curve :: (Enum a, Num a, Num r, Limiting str a, Limiting str r) => (a, a) -> (a -> r) -> (r -> r) -> Closure str a -> Closure str r Source #

for integrate_curve (xa,ya) curve f dx, Requires: \(\lim_{x \rightarrow 0}curve(x) = 0 \land \lim_{i\rightarrow \infty} dx_i = 0\)

gamma_via_integral :: R -> Closure Stream R Source #

Integral This doesn't converge well.

equality :: Infinitesimal str R => Closure str R -> Closure str R -> Closure str Bool Source #

properFraction_real :: Num a => R -> (a, R) Source #

enumFromThenToReal :: Enum e => (e -> R) -> e -> e -> e -> [R] Source #

This attempts to work around the density problem by computing range | in some type which does have enum instance, | then using the given function to map to reals.

enumFromToReal :: Enum e => (e -> R) -> e -> e -> [R] Source #

This attempts to work around the density problem by computing range | in some type which does have enum instance, | then using the given function to map to reals.

logarithm :: R -> R Source #

Natural logarithm log(1+z) = z - z^22 + z^33 - ...

invert_by_newton :: Closed a => (a -> a) -> a -> Closure Stream a Source #

tetrate :: (Eq b, Num b, Floating a) => b -> a -> a Source #

tetrate2 :: Floating a => a -> a Source #

log_newton :: (Floating a, Closed a) => a -> a Source #

withInverseModulus :: (Fractional r, Real u) => (R -> R) -> (r -> u) -> Modulus -> Modulus Source #

partial_derivate_linear :: (LinearTransform f f a, VectorSpace (f a), Closed a, Closed (f a), Fractional a, Scalar (f a) ~ a, Linearizable LinearMap (:*:) f f a, Diagonalizable f a) => (a -> f a :-> f a) -> (f a :-> f a) -> f a :-> f a Source #

Orphan instances