Boundary Conditions

Boundary conditions (BCs) determine how spline interpolants behave at the domain endpoints. They are essential for quadratic and cubic splines, which require constraints to uniquely determine the spline coefficients.

Not Needed for All Methods
  • Constant and Linear interpolation do not require boundary conditions
  • Quadratic splines require one BC (single endpoint)
  • Cubic splines require two BCs (both endpoints)

Type Hierarchy

AbstractBC{T}
├── PointBC{T}              # Single-point BC (shared by quadratic & cubic)
│   ├── Deriv1{T}           # User-specified first derivative
│   ├── Deriv2{T}           # User-specified second derivative
│   ├── Deriv3{T}           # User-specified third derivative
│   └── PolyFit{D,T}        # D-degree polynomial fit (auto-estimated)
│       ├── LinearFit       # = PolyFit{1} (2 points, O(h))
│       ├── QuadraticFit     # = PolyFit{2} (3 points, O(h²))
│       └── CubicFit        # = PolyFit{3} (4 points, O(h³))
├── BCPair{T,L,R}           # Both endpoints (cubic only)
├── PeriodicBC{T}           # Periodic BC (cubic only)
├── NaturalBC{T}            # Zero curvature at both ends (cubic only)
├── ClampedBC{T}            # Zero slope at both ends (cubic only)
├── MinCurvFit{T}           # Minimum curvature (quadratic only)
├── Left{T,B}               # Wrapper: apply BC at left endpoint
└── Right{T,B}              # Wrapper: apply BC at right endpoint

BC Categories

1. PointBC (Shared)

PointBC types can be used with both quadratic and cubic splines. They specify a derivative condition at a single endpoint.

TypeMeaningUsage
Deriv1(v)S'(endpoint) = vKnown slope
Deriv2(v)S''(endpoint) = vKnown curvature
Deriv3(v)S'''(endpoint) = vKnown third derivative
PolyFit{D}()Estimate derivative from D+1 pointsAuto-fit from data

Convenience aliases for PolyFit:

AliasEquivalentPointsAccuracy
LinearFit()PolyFit{1}()2O(h)
QuadraticFit()PolyFit{2}()3O(h²)
CubicFit()PolyFit{3}()4O(h³)

👉 See PointBC Details for in-depth explanation and visualizations.

2. Quadratic-Specific BCs

Quadratic splines need exactly one endpoint constraint:

# Wrap PointBC with Left() or Right() to specify which endpoint
Left(QuadraticFit())     # Default: auto-fit at left endpoint
Right(Deriv1(0.5))      # Slope = 0.5 at right endpoint
Left(Deriv2(0.0))       # Zero curvature at left

# Special quadratic-only BC
MinCurvFit()            # Minimize total curvature (globally smooth)

3. Cubic-Specific BCs

Cubic splines need constraints at both endpoints:

# BCPair: independent constraints at each endpoint
BCPair(Deriv2(0), Deriv2(0))      # Natural BC
BCPair(Deriv1(0), Deriv1(0))      # Clamped BC
BCPair(Deriv1(1.0), Deriv2(0))    # Mixed

# Convenience shortcuts
NaturalBC()      # = BCPair(Deriv2(0), Deriv2(0))  [default]
ClampedBC()      # = BCPair(Deriv1(0), Deriv1(0))

# True periodicity (requires y[1] ≈ y[end])
PeriodicBC()     # S(x) = S(x + τ) with C² continuity

Quick Reference

Quadratic Splines

BCDescriptionBest For
Left(QuadraticFit())3-point fit at leftDefault - exact for quadratics
Right(QuadraticFit())3-point fit at rightRight-anchored data
Left(Deriv1(v))Known slope at leftPhysics constraints
MinCurvFit()Minimize curvatureGlobally smooth interpolation

Cubic Splines

BCDescriptionBest For
NaturalBC()S''=0 at both endsDefault - general data
ClampedBC()S'=0 at both endsFlat endpoints
BCPair(...)Custom at each endKnown derivatives
PeriodicBC()True periodicityCyclic data
CubicFit()4-point polynomial fitExact for cubic polynomials

See Also