Copyright | (c) Justus Sagemüller 2015 |
---|---|
License | GPL v3 |
Maintainer | (@) sagemueller $ geo.uni-koeln.de |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
- data Region s m
- smoothIndicator :: LocallyScalable ℝ q => Region ℝ q -> Differentiable ℝ q ℝ
- data Differentiable s d c
- data PWDiffable s d c
- data RWDiffable s d c
- discretisePathIn :: WithField ℝ Manifold y => Int -> ℝInterval -> (RieMetric ℝ, RieMetric y) -> Differentiable ℝ ℝ y -> [(ℝ, y)]
- discretisePathSegs :: WithField ℝ Manifold y => Int -> (RieMetric ℝ, RieMetric y) -> ℝInterval -> RWDiffable ℝ ℝ y -> ([[(ℝ, y)]], [[(ℝ, y)]])
- continuityRanges :: WithField ℝ Manifold y => Int -> RieMetric ℝ -> ℝInterval -> RWDiffable ℝ ℝ y -> ([ℝInterval], [ℝInterval])
- regionOfContinuityAround :: RWDiffable ℝ q x -> q -> Region ℝ q
- analyseLocalBehaviour :: RWDiffable ℝ ℝ ℝ -> ℝ -> Option ((ℝ, ℝ), ℝ -> Option ℝ)
Regions within a manifold
A pathwise connected subset of a manifold m
, whose tangent space has scalar s
.
smoothIndicator :: LocallyScalable ℝ q => Region ℝ q -> Differentiable ℝ q ℝ Source
Represent a Region
by a smooth function which is positive within the region,
and crosses zero at the boundary.
Hierarchy of manifold-categories
Everywhere differentiable functions
data Differentiable s d c Source
The category of differentiable functions between manifolds over scalar s
.
As you might guess, these offer automatic differentiation of sorts (basically, simple forward AD), but that's in itself is not really the killer feature here. More interestingly, we actually have the (à la Curry-Howard) proof built in: the function f has at x₀ derivative f'ₓ₀, if, for¹ ε>0, there exists δ such that |f x − (f x₀ + x⋅f'ₓ₀)| < ε for all |x − x₀| < δ.
Observe that, though this looks quite similar to the standard definition of differentiability, it is not equivalent thereto – in fact it does not prove any analytic properties at all. To make it equivalent, we need a lower bound on δ: simply δ gives us continuity, and for continuous differentiability, δ must grow at least like √ε for small ε. Neither of these conditions are enforced by the type system, but we do require them for any allowed values because these proofs are obviously tremendously useful – for instance, you can have a root-finding algorithm and actually be sure you get all solutions correctly, not just some that are (hopefully) the closest to some reference point you'd need to laborously define!
Unfortunately however, this also prevents doing any serious algebra etc. with the
category, because even something as simple as division necessary introduces singularities
where the derivatives must diverge.
Not to speak of many trigonometric e.g. trigonometric functions that
are undefined on whole regions. The PWDiffable
and RWDiffable
categories have explicit
handling for those issues built in; you may simply use these categories even when
you know the result will be smooth in your relevant domain (or must be, for e.g.
physics reasons).
¹(The implementation does not deal with ε and δ as difference-bounding reals, but rather as metric tensors that define a boundary by prohibiting the overlap from exceeding one; this makes the concept actually work on general manifolds.)
RealDimension s => EnhancedCat (->) (Differentiable s) Source | |
MetricScalar s => HasAgent (Differentiable s) Source | |
MetricScalar s => Category (Differentiable s) Source | |
MetricScalar s => Cartesian (Differentiable s) Source | |
MetricScalar s => WellPointed (Differentiable s) Source | |
MetricScalar s => PreArrow (Differentiable s) Source | |
MetricScalar s => Morphism (Differentiable s) Source | |
MetricScalar s => CartesianAgent (Differentiable s) Source | |
RealDimension s => EnhancedCat (RWDiffable s) (Differentiable s) Source | |
RealDimension s => EnhancedCat (PWDiffable s) (Differentiable s) Source | |
type UnitObject (Differentiable s) = ZeroDim s Source | |
type Object (Differentiable s) o = LocallyScalable s o Source | |
type PointObject (Differentiable s) x = () | |
type AgentVal (Differentiable s) a v = GenericAgent (Differentiable s) a v | |
type PairObjects (Differentiable s) a b = () |
Almost everywhere diff'able funcs
data PWDiffable s d c Source
Category of functions that almost everywhere have an open region in which they are continuously differentiable, i.e. PieceWiseDiff'able.
RealDimension s => EnhancedCat (->) (PWDiffable s) Source | |
RealDimension s => HasAgent (PWDiffable s) Source | |
RealDimension s => Category (PWDiffable s) Source | |
RealDimension s => Cartesian (PWDiffable s) Source | |
RealDimension s => WellPointed (PWDiffable s) Source | |
RealDimension s => PreArrow (PWDiffable s) Source | |
RealDimension s => Morphism (PWDiffable s) Source | |
RealDimension s => CartesianAgent (PWDiffable s) Source | |
RealDimension s => EnhancedCat (RWDiffable s) (PWDiffable s) Source | |
RealDimension s => EnhancedCat (PWDiffable s) (Differentiable s) Source | |
type UnitObject (PWDiffable s) = ZeroDim s Source | |
type Object (PWDiffable s) o = LocallyScalable s o Source | |
type PointObject (PWDiffable s) x = () | |
type AgentVal (PWDiffable s) a v = GenericAgent (PWDiffable s) a v | |
type PairObjects (PWDiffable s) a b = () |
Region-wise defined diff'able funcs
data RWDiffable s d c Source
Category of functions that, where defined, have an open region in
which they are continuously differentiable. Hence RegionWiseDiff'able.
Basically these are the partial version of PWDiffable
.
Though the possibility of undefined regions is of course not too nice
(we don't need Java to demonstrate this with its everywhere-looming null
values...),
this category will propably be the “workhorse” for most serious
calculus applications, because it contains all the usual trig etc. functions
and of course everything algebraic you can do in the reals.
The easiest way to define ordinary functions in this category is hence
with its AgentVal
ues, which have instances of the standard classes Num
through Floating
. For instance, the following defines the binary entropy
as a differentiable function on the interval ]0,1[
: (it will
actually know where it's defined and where not! – and I don't mean you
need to exhaustively isNaN
-check all results...)
hb :: RWDiffable ℝ ℝ ℝ hb = alg (\p -> - p * logBase 2 p - (1-p) * logBase 2 (1-p) )
RealDimension s => HasAgent (RWDiffable s) Source | |
RealDimension s => Category (RWDiffable s) Source | |
RealDimension s => Cartesian (RWDiffable s) Source | |
RealDimension s => WellPointed (RWDiffable s) Source | |
RealDimension s => PreArrow (RWDiffable s) Source | |
RealDimension s => Morphism (RWDiffable s) Source | |
RealDimension s => CartesianAgent (RWDiffable s) Source | |
RealDimension s => EnhancedCat (RWDiffable s) (PWDiffable s) Source | |
RealDimension s => EnhancedCat (RWDiffable s) (Differentiable s) Source | |
type UnitObject (RWDiffable s) = ZeroDim s Source | |
type Object (RWDiffable s) o = LocallyScalable s o Source | |
type PointObject (RWDiffable s) x = () | |
type AgentVal (RWDiffable s) d c Source | |
type PairObjects (RWDiffable s) a b = () |
Misc
:: WithField ℝ Manifold y | |
=> Int | Limit the number of steps taken in either direction. Note this will not cap the resolution but length of the discretised path. |
-> ℝInterval | Parameter interval of interest. |
-> (RieMetric ℝ, RieMetric y) | Inaccuracy allowance ε. |
-> Differentiable ℝ ℝ y | Path specification. |
-> [(ℝ, y)] | Trail of points along the path, such that a linear interpolation deviates nowhere by more as ε. |
:: WithField ℝ Manifold y | |
=> Int | Maximum number of path segments and/or points per segment. |
-> (RieMetric ℝ, RieMetric y) | Inaccuracy allowance δ for arguments (mostly relevant for resolution of discontinuity boundaries – consider it a “safety margin from singularities”), and ε for results in the target space. |
-> ℝInterval | Interval of interest. You can make this “infinitely large”. |
-> RWDiffable ℝ ℝ y | Path specification. |
-> ([[(ℝ, y)]], [[(ℝ, y)]]) | Discretised paths: continuous segments in either direction |
regionOfContinuityAround :: RWDiffable ℝ q x -> q -> Region ℝ q Source