Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- newtype R = Limit (Stream Rational)
- data Modulus = Modulus {
- modulus_value :: R
- modulus :: Rational -> Integer
- d :: Infinitesimal Stream a => (a -> a) -> a -> Closure Stream a
- liftReal :: (Rational -> Rational) -> R -> R
- convergence_ratio_test :: (Fractional a, Ord a, Closed a) => Stream a -> Bool
- average_convergence_ratio :: (MetricSpace a, Fractional (Scalar a)) => Stream a -> Stream (Scalar a)
- list_average :: Fractional a => [a] -> a
- cauchy :: MetricSpace a => Stream a -> Stream [Scalar a]
- cseq_difference_matrix :: (Functor m, Functor n, Diagonalizable m a, LinearTransform m n a, Num a) => m a -> n a -> (m :*: n) a
- cauchy_sequence_equivalence :: (ConjugateSymmetric a, Closed a, Num a) => Stream a -> Stream a -> Stream a
- cseq_equivalence_matrix :: (Num a, ConjugateSymmetric a, Closed a, Infinitesimal Stream eps) => (eps -> Integer) -> Stream a -> Stream a -> (Stream :*: Stream) a
- cseq_convergence :: (ConjugateSymmetric a, Closed a, Num a) => Stream a -> Stream a -> Stream [a]
- cseq_equivalence_list :: (Closed a, ConjugateSymmetric a, Num a, Infinitesimal Stream eps) => (eps -> Integer) -> Stream a -> Stream a -> Stream [a]
- converges :: MetricSpace a => Stream a -> a -> Stream [Scalar a]
- increase_accuracy_by :: Limiting Stream a => Integer -> Closure Stream a -> Closure Stream a
- partial_derive :: (Closed a, Infinitesimal Stream a, Fractional a) => (a -> a -> a) -> (a -> a) -> a -> a
- partial_derivate_closure :: (Limiting str a, Fractional a) => (a -> b -> b) -> (b -> a) -> b -> Endo (Closure str a)
- partial_derivate :: (Closed eps, Fractional eps) => (eps -> a -> a) -> (a -> eps) -> a -> eps
- partial_derivate_endo :: (Limiting str a, Fractional a) => (a -> Endo b) -> (b -> a) -> b -> Endo (Closure str a)
- complex_derivate :: (RealFloat r, Closed r) => (Complex r -> Complex r) -> Complex r -> Complex r
- average :: R -> R -> R
- completenessOfReals :: Closure Stream R :==: R
- liftRClosure :: (R -> R) -> Closure Stream R -> Closure Stream R
- limit_real :: Stream R -> R
- lift_real :: (Rational -> Rational) -> R -> R
- series :: (Integer -> R) -> R
- supremum_gen :: (Fractional a, Ord a, Limiting Stream a) => [Closure Stream a] -> Closure Stream a
- negate_limit :: (Limiting str a, Num a) => Closure str a -> Closure str a
- infimum_gen :: (Fractional a, Ord a, Limiting Stream a) => [Closure Stream a] -> Closure Stream a
- infinity :: R
- infinity_gen :: (Fractional a, Limiting Stream a) => Closure Stream a
- negative_infinity_gen :: (Fractional a, Limiting Stream a) => Closure Stream a
- limit_below :: R -> (R -> R) -> Closure Stream R
- limit_above :: R -> (R -> R) -> Closure Stream R
- limit_both :: R -> (R -> R) -> Closure Stream R
- negative_infinity :: R
- epsilon_linear :: R
- increase_accuracy :: R -> R
- lessthan_precision :: R -> R -> Integer -> Bool
- limiting_distance :: (Num a, Limiting str a) => Closure str a -> Closure str a -> Closure str a
- distance_matrix :: R -> R -> (Stream :*: Stream) Rational
- at_precision_rational :: R -> Rational -> Rational
- at_precision :: R -> Integer -> R
- precision_rational :: R -> Integer -> Rational
- real_derivate :: (R -> R) -> R -> R
- real_exp :: R -> R
- derivate_closed :: Infinitesimal str a => (a -> a) -> a -> Closure str a
- vector_derivate :: (Infinitesimal str (Scalar a), VectorSpace a, Limiting str a) => (Scalar a -> a) -> Scalar a -> Closure str a
- pseudo_derivate :: (Fractional r, Limiting str r, Infinitesimal str a) => (a -> r) -> a -> Closure str r
- derivates_at :: DifferentiallyClosed a => (a -> a) -> Stream a -> Stream a
- derivate_around :: Infinitesimal str a => (a -> a) -> a -> Closure str a
- partial_derivate1_2 :: Infinitesimal str a => (a -> b -> a) -> a -> b -> Closure str a
- partial_derivate2_2 :: Infinitesimal str a => (b -> a -> a) -> b -> a -> Closure str a
- partial_derivate1_3 :: Infinitesimal str a => (a -> b -> c -> a) -> a -> b -> c -> Closure str a
- partial_derivate2_3 :: Infinitesimal str a => (b -> a -> c -> a) -> b -> a -> c -> Closure str a
- partial_derivate3_3 :: Infinitesimal str a => (b -> c -> a -> a) -> b -> c -> a -> Closure str a
- agm :: (Floating a, Limiting str a) => a -> a -> Closure str a
- expo :: R -> R
- newtons_method :: Numerics a => (a -> a) -> a -> a
- eigenvalue :: (Closed a, LinearTraceable LinearMap m a, Linearizable LinearMap (:*:) m m a, Applicative m, a ~ Scalar (m a), VectorSpace (m a), LinearTransform m m a) => (m a :-> m a) -> Closure Stream a
- 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
- integrate :: (Enum a, Num a, Limiting str a) => (a -> a) -> Closure str a -> (a, a) -> Closure str a
- integral_real :: (R, R) -> (R -> R) -> R
- integral_rational :: (R, R) -> (Rational -> Rational) -> R
- 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
- gamma_via_integral :: R -> Closure Stream R
- approximately_equal :: R -> R -> Bool
- approximately_eq :: R -> R -> Bool
- constructively_less :: Rational -> R -> R -> Closure Stream Bool
- equality :: Infinitesimal str R => Closure str R -> Closure str R -> Closure str Bool
- signum_real :: R -> Int -> Int
- show_at_precision_real :: R -> Integer -> String
- properFraction_real :: Num a => R -> (a, R)
- enumFromThenToReal :: Enum e => (e -> R) -> e -> e -> e -> [R]
- fromThenTo :: Rational -> Rational -> Rational -> [R]
- fromTo :: Rational -> Rational -> [R]
- enumFromToReal :: Enum e => (e -> R) -> e -> e -> [R]
- realEnumFromThenTo :: R -> R -> R -> Stream [Rational]
- strEnumFromThenTo :: Stream Rational -> Stream Rational -> Stream Rational -> Stream [Rational]
- toReal :: Rational -> R
- logarithm :: R -> R
- euler_constant :: R
- napiers_constant :: R
- logarithm_by_newton :: R -> Closure Stream R
- invert_by_newton :: Closed a => (a -> a) -> a -> Closure Stream a
- exp_by_powers :: (Fractional r, Limiting Stream r) => r -> Closure Stream r
- exp_by_powers_real :: R -> R
- sum_generating_function :: Stream Rational -> R -> R
- riemann_zeta :: Floating a => a -> Stream a
- riemann_zeta_real :: Integral a => a -> R
- riemann_zeta_complex :: RealFloat a => Complex a -> Stream (Complex a)
- encodeInBase :: Integer -> Integer -> Int -> R
- fromFloat :: RealFloat a => a -> R
- golden_ratio :: R
- slow_golden_ratio :: R
- logistic :: Floating a => a -> a
- floating_approximations :: Approximations str a => a -> str Double
- logarithm_by_power :: (Floating a, Limiting Stream a) => a -> Closure Stream a
- tetrate :: (Eq b, Num b, Floating a) => b -> a -> a
- tetrate2 :: Floating a => a -> a
- log_newton :: (Floating a, Closed a) => a -> a
- exp_by_series2 :: R -> R
- exp_by_series :: R -> R
- sin_by_series :: R -> R
- cos_by_series :: R -> R
- approximate_sums_modulus :: Modulus -> Modulus -> Modulus
- withInverseModulus :: (Fractional r, Real u) => (R -> R) -> (r -> u) -> Modulus -> Modulus
- 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
Documentation
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.
Instances
convergence_ratio_test :: (Fractional a, Ord a, Closed a) => Stream a -> Bool Source #
average_convergence_ratio :: (MetricSpace a, Fractional (Scalar a)) => Stream a -> Stream (Scalar a) Source #
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.
cseq_equivalence_list :: (Closed a, ConjugateSymmetric a, Num a, Infinitesimal Stream eps) => (eps -> Integer) -> Stream a -> Stream a -> Stream [a] Source #
increase_accuracy_by :: Limiting Stream a => Integer -> Closure Stream a -> Closure Stream a Source #
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 #
complex_derivate :: (RealFloat r, Closed r) => (Complex r -> Complex r) -> Complex r -> Complex 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.
infimum_gen :: (Fractional a, Ord a, Limiting Stream a) => [Closure Stream a] -> Closure Stream a Source #
infinity_gen :: (Fractional a, Limiting Stream a) => Closure Stream a Source #
negative_infinity_gen :: (Fractional a, Limiting Stream a) => Closure Stream a Source #
epsilon_linear :: R Source #
increase_accuracy :: R -> R 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
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 #
pseudo_derivate :: (Fractional r, Limiting str r, Infinitesimal str a) => (a -> r) -> a -> Closure str r 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}}\]
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 #
eigenvalue :: (Closed a, LinearTraceable LinearMap m a, Linearizable LinearMap (:*:) m m a, Applicative m, a ~ Scalar (m a), VectorSpace (m a), LinearTransform m m a) => (m a :-> m a) -> Closure Stream 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 #
integrate :: (Enum a, Num a, Limiting str a) => (a -> a) -> Closure str a -> (a, a) -> Closure str a 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\)
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.
strEnumFromThenTo :: Stream Rational -> Stream Rational -> Stream Rational -> Stream [Rational] Source #
euler_constant :: R Source #
napiers_constant :: R Source #
exp_by_powers :: (Fractional r, Limiting Stream r) => r -> Closure Stream r Source #
exp_by_powers_real :: R -> R Source #
riemann_zeta :: Floating a => a -> Stream a Source #
riemann_zeta_real :: Integral a => a -> R Source #
floating_approximations :: Approximations str a => a -> str Double Source #
log_newton :: (Floating a, Closed a) => a -> a Source #
exp_by_series2 :: R -> R Source #
exp_by_series :: R -> R Source #
sin_by_series :: R -> R Source #
cos_by_series :: R -> R 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
MetricSpace Integer Source # | |
MetricSpace Int Source # | |
Infinitesimal Stream Rational Source # | |
(Monad str, StreamObserver str, StreamBuilder str) => Limiting str Bool Source # | |
MetricSpace (Ratio Integer) Source # | |