manifolds-0.1.6.2: Coordinate-free hypersurfaces

Copyright(c) Justus Sagemüller 2015
LicenseGPL v3
Maintainer(@) sagemueller $ geo.uni-koeln.de
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Data.Function.Differentiable

Contents

Description

 

Synopsis

Regions within a manifold

data Region s m Source

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₀ + xf'ₓ₀)| < ε for all |xx₀| < δ.

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

Instances

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.

Instances

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 AgentValues, 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) )

Instances

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

discretisePathIn Source

Arguments

:: 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 ε.

discretisePathSegs Source

Arguments

:: 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

continuityRanges Source

Arguments

:: WithField Manifold y 
=> Int

Max number of exploration steps per region

-> RieMetric

Needed resolution of boundaries

-> ℝInterval

Interval to explore

-> RWDiffable y

Function to investigate

-> ([ℝInterval], [ℝInterval])

Subintervals on which the function is guaranteed continuous.

analyseLocalBehaviour Source

Arguments

:: RWDiffable  
->

x₀ value.

-> Option ((, ), -> Option )

f x₀, derivative (i.e. Taylor-1-coefficient), and reverse propagation of O (δ²) bound.