Skip to content

HMath.Interpolation

Module index · Numerical conventions

Description

Checked reference interpolation and approximation. Samples are strictly increasing, finite, and unique; no silent sorting or duplicate averaging. Piecewise coefficients are ascending powers of (x-left knot), intervals are left closed/right open except the final endpoint. Error results are sampled estimates, not mathematical enclosures. Dense fitting is bounded to 1024 samples, degree 64, and 16 scattered dimensions.

On this page

API Purpose
Extrapolation Reject out-of-domain queries, clamp to an endpoint, or evaluate the endpoint polynomial beyond its interval.
Reject Declaration and type contract below.
Clamp Declaration and type contract below.
Extrapolate Declaration and type contract below.
InterpolationMethod Independent scalar nearest, linear, Lagrange, Newton divided-difference or barycentric formula.
Nearest Declaration and type contract below.
Linear Declaration and type contract below.
Lagrange Declaration and type contract below.
Newton Declaration and type contract below.
Barycentric Declaration and type contract below.
interpolate Interpolate ordered (x,y) samples using the selected formula and extrapolation policy; nearest ties choose the earlier node.
hermite Global confluent Hermite polynomial, distinct nodes and supplied first derivatives.
cubicHermite Piecewise cubic Hermite interpolation with supplied endpoint derivatives.
SplineBoundary Natural zero curvature, supplied clamped endpoint slopes, or periodic value/derivative matching.
Natural Declaration and type contract below.
Clamped Declaration and type contract below.
Periodic Declaration and type contract below.
PiecewisePolynomial Opaque ascending local polynomial coefficients and strictly increasing breakpoints.
piecewisePolynomial Validate breakpoints and nonempty coefficient rows.
piecewiseKnots Return the immutable piecewise breakpoints, including both outer endpoints.
evaluatePiecewise Evaluate by Horner rule in the containing interval; use the final interval at the right endpoint.
differentiatePiecewise Differentiate each local coefficient row without changing the breakpoints.
integratePiecewise Exact polynomial antiderivative across all crossed intervals; both limits must lie inside the domain.
cubicSpline Cubic C2 interpolation.
pchip Fritsch--Carlson/PCHIP weighted harmonic interior slopes and limited one- sided endpoints preserve monotonicity on monotone data.
akima Akima cubic interpolation using slope-difference weights and linearly extended endpoint secants; at least three samples.
smoothingSpline Natural cubic smoothing spline minimizing sum (y_i-s(x_i))² plus lambda times integral s''².
BSpline Opaque rational B-spline with positive weights and a validated full knot vector.
bSpline Nondecreasing full knot vector, degree 0..16, positive rational weights, control points of equal dimension.
evaluateBSpline Evaluate rational Cox--de Boor basis functions and divide homogeneous coordinates by their positive total weight.
derivativeBSpline Analytic first derivative of a rational B-spline using basis derivatives and the homogeneous quotient rule.
insertKnot One Boehm knot insertion in homogeneous coordinates; shape is preserved.
bezier Polynomial Bezier curve with unit weights; controls are vectors with 1..16 coordinates.
rationalBezier Positive-weight rational Bezier curve on [0,1], represented exactly as an open clamped B-spline (degree <=16).
cardinalSpline Kochanek--Bartels interpolation with zero continuity/bias and supplied tension in [-1,1].
catmullRom Cardinal cubic interpolation with zero tension and repeated endpoint secants.
kochanekBartels Interpolating cubic Hermite segment sequence with Kochanek--Bartels tension, continuity and bias in [-1,1]; endpoint secants are repeated.
curveIntegral Componentwise adaptive integral of a B-spline between in-domain limits, with estimated quadrature errors.
arcLength Adaptive integral of the Euclidean analytic derivative norm; limits must increase and remain in the spline domain.
gridInterpolate Rectilinear multilinear interpolation; values are row-major/last axis fast.
RadialKernel Radial interpolation kernels; the first three accept a positive inverse-length shape parameter.
Gaussian Declaration and type contract below.
Multiquadric Declaration and type contract below.
InverseMultiquadric Declaration and type contract below.
ThinPlate Declaration and type contract below.
Cubic Declaration and type contract below.
RBF Opaque fitted radial model with an affine polynomial tail.
fitRBF Solve the augmented radial/affine system with nonnegative diagonal smoothing; singular or affinely degenerate systems fail.
evaluateRBF Evaluate a fitted scattered model at one finite point with the original coordinate dimension.
inverseDistance Normalized inverse-distance interpolation with positive power; coincident queries return the exact observation.
shepard Classical inverse-square Shepard interpolation in the supplied Euclidean coordinates.
kriging Ordinary kriging with stationary exponential covariance exp(-distance/range), optional independent nugget, unbiased constant mean.
Approximation Coefficients or parameters, observed absolute residual, and iteration/evaluation count; error is an estimate.
Approximation Declaration and type contract below.
approximationCoefficients Fitted coefficients in the approximation routine's documented basis/order.
approximationError Reported approximation residual/error measure, not a general analytic bound.
approximationIterations Number of fitting/refinement iterations performed.
polynomialFit Full-column-rank polynomial least squares via pivoted QR, returning ascending coefficients and maximum observation error.
chebyshevApproximate Chebyshev-root interpolation on a finite interval; report maximum error on a separate 513-point uniform validation grid.
evaluateChebyshev Evaluate ascending Chebyshev coefficients after mapping the original interval to [-1,1].
pade Padé [m/n] from ascending Taylor coefficients, q_0=1.
rationalFit Linearized rational least squares y*q(x)-p(x)=0 with q_0=1; poles at observations are rejected.
remez Discrete Remez exchange on an explicit dense grid, 1..64 degree.
nonlinearFit Damped Gauss--Newton least squares with central-difference Jacobian, strict residual/step convergence and finite total callbacks; returns fitted parameters.
interpolationError Maximum absolute discrepancy at the supplied nonempty observations; nonfinite callback results fail.

Documentation

Extrapolation

data Extrapolation Source #

Reject out-of-domain queries, clamp to an endpoint, or evaluate the endpoint polynomial beyond its interval.

Constructors

Reject 
Clamp 
Extrapolate 

Instances

Instances details
Show Extrapolation Source # 
Instance details

Defined in HMath.Interpolation

Eq Extrapolation Source # 
Instance details

Defined in HMath.Interpolation

InterpolationMethod

data InterpolationMethod Source #

Independent scalar nearest, linear, Lagrange, Newton divided-difference or barycentric formula.

interpolate

interpolate :: InterpolationMethod -> Extrapolation -> [(Double, Double)] -> Double -> Either MathError Double Source #

Interpolate ordered (x,y) samples using the selected formula and extrapolation policy; nearest ties choose the earlier node.

hermite

hermite :: [(Double, Double, Double)] -> Double -> Either MathError Double Source #

Global confluent Hermite polynomial, distinct nodes and supplied first derivatives. Uses the squared Lagrange cardinal functions.

cubicHermite

cubicHermite :: [(Double, Double, Double)] -> Either MathError PiecewisePolynomial Source #

Piecewise cubic Hermite interpolation with supplied endpoint derivatives. Triples are (coordinate,value,slope); first derivatives are continuous at shared knots, while second derivatives need not agree.

SplineBoundary

data SplineBoundary Source #

Natural zero curvature, supplied clamped endpoint slopes, or periodic value/derivative matching.

Instances

Instances details
Show SplineBoundary Source # 
Instance details

Defined in HMath.Interpolation

Eq SplineBoundary Source # 
Instance details

Defined in HMath.Interpolation

PiecewisePolynomial

data PiecewisePolynomial Source #

Opaque ascending local polynomial coefficients and strictly increasing breakpoints.

piecewisePolynomial

piecewisePolynomial :: [Double] -> [[Double]] -> Either MathError PiecewisePolynomial Source #

Validate breakpoints and nonempty coefficient rows. Each row uses ascending powers of displacement from its left knot.

piecewiseKnots

piecewiseKnots :: PiecewisePolynomial -> [Double] Source #

Return the immutable piecewise breakpoints, including both outer endpoints.

evaluatePiecewise

evaluatePiecewise :: Extrapolation -> PiecewisePolynomial -> Double -> Either MathError Double Source #

Evaluate by Horner rule in the containing interval; use the final interval at the right endpoint.

differentiatePiecewise

differentiatePiecewise :: PiecewisePolynomial -> Either MathError PiecewisePolynomial Source #

Differentiate each local coefficient row without changing the breakpoints.

integratePiecewise

integratePiecewise :: PiecewisePolynomial -> Double -> Double -> Either MathError Double Source #

Exact polynomial antiderivative across all crossed intervals; both limits must lie inside the domain.

cubicSpline

cubicSpline :: SplineBoundary -> [(Double, Double)] -> Either MathError PiecewisePolynomial Source #

Cubic C2 interpolation. Periodic requires equal endpoint values and at least three intervals; endpoint first and second derivatives agree.

pchip

pchip :: [(Double, Double)] -> Either MathError PiecewisePolynomial Source #

Fritsch--Carlson/PCHIP weighted harmonic interior slopes and limited one- sided endpoints preserve monotonicity on monotone data.

akima

akima :: [(Double, Double)] -> Either MathError PiecewisePolynomial Source #

Akima cubic interpolation using slope-difference weights and linearly extended endpoint secants; at least three samples.

smoothingSpline

smoothingSpline :: Double -> [(Double, Double)] -> Either MathError PiecewisePolynomial Source #

Natural cubic smoothing spline minimizing sum (y_i-s(x_i))² plus lambda times integral s''². Reinsch Q/R formulation, unit observation weights.

BSpline

data BSpline Source #

Opaque rational B-spline with positive weights and a validated full knot vector.

Instances

Instances details
Show BSpline Source # 
Instance details

Defined in HMath.Interpolation

Eq BSpline Source # 
Instance details

Defined in HMath.Interpolation

Methods

(==) :: BSpline -> BSpline -> Bool #

(/=) :: BSpline -> BSpline -> Bool #

bSpline

bSpline :: Int -> [Double] -> [[Double]] -> [Double] -> Either MathError BSpline Source #

Nondecreasing full knot vector, degree 0..16, positive rational weights, control points of equal dimension. Evaluation domain [k_p,k_n].

evaluateBSpline

evaluateBSpline :: BSpline -> Double -> Either MathError [Double] Source #

Evaluate rational Cox--de Boor basis functions and divide homogeneous coordinates by their positive total weight.

derivativeBSpline

derivativeBSpline :: BSpline -> Double -> Either MathError [Double] Source #

Analytic first derivative of a rational B-spline using basis derivatives and the homogeneous quotient rule.

insertKnot

insertKnot :: BSpline -> Double -> Either MathError BSpline Source #

One Boehm knot insertion in homogeneous coordinates; shape is preserved.

bezier

bezier :: [[Double]] -> Double -> Either MathError [Double] Source #

Polynomial Bezier curve with unit weights; controls are vectors with 1..16 coordinates.

rationalBezier

rationalBezier :: [[Double]] -> [Double] -> Double -> Either MathError [Double] Source #

Positive-weight rational Bezier curve on [0,1], represented exactly as an open clamped B-spline (degree <=16).

cardinalSpline

cardinalSpline :: Double -> [(Double, Double)] -> Either MathError PiecewisePolynomial Source #

Kochanek--Bartels interpolation with zero continuity/bias and supplied tension in [-1,1].

catmullRom

catmullRom :: [(Double, Double)] -> Either MathError PiecewisePolynomial Source #

Cardinal cubic interpolation with zero tension and repeated endpoint secants.

kochanekBartels

kochanekBartels :: Double -> Double -> Double -> [(Double, Double)] -> Either MathError PiecewisePolynomial Source #

Interpolating cubic Hermite segment sequence with Kochanek--Bartels tension, continuity and bias in [-1,1]; endpoint secants are repeated.

curveIntegral

curveIntegral :: Tolerance -> BSpline -> Double -> Double -> Either MathError [Estimate Double] Source #

Componentwise adaptive integral of a B-spline between in-domain limits, with estimated quadrature errors.

arcLength

arcLength :: Tolerance -> BSpline -> Double -> Double -> Either MathError (Estimate Double) Source #

Adaptive integral of the Euclidean analytic derivative norm; limits must increase and remain in the spline domain.

gridInterpolate

gridInterpolate :: InterpolationMethod -> Extrapolation -> [[Double]] -> [Double] -> [Double] -> Either MathError Double Source #

Rectilinear multilinear interpolation; values are row-major/last axis fast. Nearest uses Euclidean distance to grid nodes; extrapolation policy per axis.

RadialKernel

data RadialKernel Source #

Radial interpolation kernels; the first three accept a positive inverse-length shape parameter.

Instances

Instances details
Show RadialKernel Source # 
Instance details

Defined in HMath.Interpolation

Eq RadialKernel Source # 
Instance details

Defined in HMath.Interpolation

RBF

data RBF Source #

Opaque fitted radial model with an affine polynomial tail.

Instances

Instances details
Show RBF Source # 
Instance details

Defined in HMath.Interpolation

Methods

showsPrec :: Int -> RBF -> ShowS #

show :: RBF -> String #

showList :: [RBF] -> ShowS #

Eq RBF Source # 
Instance details

Defined in HMath.Interpolation

Methods

(==) :: RBF -> RBF -> Bool #

(/=) :: RBF -> RBF -> Bool #

fitRBF

fitRBF :: RadialKernel -> Double -> [[Double]] -> [Double] -> Either MathError RBF Source #

Solve the augmented radial/affine system with nonnegative diagonal smoothing; singular or affinely degenerate systems fail.

evaluateRBF

evaluateRBF :: RBF -> [Double] -> Either MathError Double Source #

Evaluate a fitted scattered model at one finite point with the original coordinate dimension.

inverseDistance

inverseDistance :: Double -> [[Double]] -> [Double] -> [Double] -> Either MathError Double Source #

Normalized inverse-distance interpolation with positive power; coincident queries return the exact observation.

shepard

shepard :: [[Double]] -> [Double] -> [Double] -> Either MathError Double Source #

Classical inverse-square Shepard interpolation in the supplied Euclidean coordinates.

kriging

kriging :: Double -> Double -> [[Double]] -> [Double] -> [Double] -> Either MathError (Double, Double) Source #

Ordinary kriging with stationary exponential covariance exp(-distance/range), optional independent nugget, unbiased constant mean. Returns mean and variance.

Approximation

data Approximation Source #

Coefficients or parameters, observed absolute residual, and iteration/evaluation count; error is an estimate.

Constructors

Approximation 

Fields

Instances

Instances details
Show Approximation Source # 
Instance details

Defined in HMath.Interpolation

Eq Approximation Source # 
Instance details

Defined in HMath.Interpolation

polynomialFit

polynomialFit :: Int -> [(Double, Double)] -> Either MathError Approximation Source #

Full-column-rank polynomial least squares via pivoted QR, returning ascending coefficients and maximum observation error.

chebyshevApproximate

chebyshevApproximate :: Int -> (Double -> Double) -> Double -> Double -> Either MathError Approximation Source #

Chebyshev-root interpolation on a finite interval; report maximum error on a separate 513-point uniform validation grid.

evaluateChebyshev

evaluateChebyshev :: [Double] -> Double -> Double -> Double -> Either MathError Double Source #

Evaluate ascending Chebyshev coefficients after mapping the original interval to [-1,1].

pade

pade :: Int -> Int -> [Double] -> Either MathError ([Double], [Double]) Source #

Padé [m/n] from ascending Taylor coefficients, q_0=1.

rationalFit

rationalFit :: Int -> Int -> [(Double, Double)] -> Either MathError ([Double], [Double], Double) Source #

Linearized rational least squares y*q(x)-p(x)=0 with q_0=1; poles at observations are rejected. Error is the actual rational residual.

remez

remez :: Int -> Int -> Double -> Int -> (Double -> Double) -> Double -> Double -> Either MathError Approximation Source #

Discrete Remez exchange on an explicit dense grid, 1..64 degree. Success requires alternating extrema and stable equioscillation; returned error is the maximum on this grid only, not a certified continuous minimax bound.

nonlinearFit

nonlinearFit :: Int -> Double -> (Double -> [Double] -> Double) -> [(Double, Double)] -> [Double] -> Either MathError Approximation Source #

Damped Gauss--Newton least squares with central-difference Jacobian, strict residual/step convergence and finite total callbacks; returns fitted parameters.

interpolationError

interpolationError :: (Double -> Double) -> [(Double, Double)] -> Either MathError Double Source #

Maximum absolute discrepancy at the supplied nonempty observations; nonfinite callback results fail.