Basic Examples (4)
Non-convex subset. The ratio measures the missing fraction of the convex hull:
A convex set has ratio zero:
Maximum fragmentation. Only boundary points remain:
The empty set returns zero:
Scope (3)
Works with rational elements:
Works with strings under canonical (lexicographic) order:
A singleton always has ratio zero:
Options (2)
The default value of "ComparisonFunction" is LessEqual:
A custom comparison function can redefine the ordering. Under the standard order 1< 2<3<4<5, the subset {1, 4} has defect ratio 0.5 because the elements 2 and 3 lie between 1 and 4:
With the custom ordering , the element 4 is the immediate successor of 1, so the interval contains only , meaning that the defect vanishes:
Default ordering. Closure of is . Two gaps. Ratio .
Custom ordering. Closure of is . Ratio 0.
Te comparison function defines the interval.
Applications (2)
Convexity phase diagram of the logistic map
Measure the fragmentation of the logistic attractor as a function of the parameter :
For , the attractor is a fixed point and . Through the period-doubling cascade, the ratio increases as the orbit spreads into disjoint bands. The sharp dips correspond to periodic windows — intervals of stability where the orbit collapses onto a finite cycle, yielding only a few points within a wide convex hull. At , the map is conjugate to the full tent map and the orbit becomes dense in at the chosen resolution, driving .
Prime gap fragmentation
The primes become maximally non-convex as , reflecting the Prime Number Theorem ( since ):
The curve increases toward 1. By the Prime Number Theorem, , so the fraction of integers that are prime within the convex hull tends to zero. Accordingly, the defect ratio approaches unity, providing a quantitative expression of the increasing sparsity of primes among the integers.
Properties and Relations (5)
The ratio is zero if and only if OrderConvexQ returns True:
Equivalent to the fraction of elements in the induced interval that are not contained in the subset:
The ratio equals one minus the density of the subset within its induced interval:
Monotonicity. Adding elements to the subset can only decrease or preserve the ratio:
A subset containing all elements of its induced interval has ratio zero:
Possible Issues (1)
Numerical precision. The result is a machine-precision real. Small rounding differences may occur compared to exact rational arithmetic.
Invalid containment. If subset is not contained in parent set, the ratio may exceed 1.
The result is a machine-precision real, not an exact rational number:
Neat Examples (2)
Track the defect ratio of a random walk orbit on as it explores its range over time. The ratio starts at zero (a single visited point is trivially convex), spikes as gaps appear, and eventually decays back toward zero once the walk covers every site in its range. This is a discrete analogue of the cover time on a path graph:
Compare the defect ratio across three qualitatively different dynamical regimes of the logistic map: fixed point, period-doubling, and full chaos, evaluated at representative parameter values:
The table reveals the nonmonotonic signature of the route to chaos: increases through the period-doubling cascade (), peaks inside periodic windows (e.g. , where the orbit collapses onto a low-period cycle), and returns toward zero as the attractor becomes increasingly dense, approaching full support at . The small residual value at is a finite-orbit artifact: the invariant density

is minimal near , so this region is sampled least frequently, and the last grid points to be visited lie in that neighborhood.