piecewise-rational
Shape-preserving piecewise rational cubic interpolation (Delbourgo-Gregory algorithm)
What it is and what it does
piecewise-rational implements the Delbourgo-Gregory algorithm for rational cubic interpolation, a method that constructs smooth curves through data points while preserving shape properties like monotonicity and convexity. Unlike standard polynomial splines, rational cubic interpolation uses rational functions (ratios of polynomials) within each interval, offering better control over curve behavior and the ability to fit second derivatives through a control parameter.
The package provides a single core function, rational_cubic_interpolation, that takes an x-coordinate to evaluate, the interval endpoints, endpoint values, endpoint derivatives, and a control parameter, returning the interpolated y-value. It has no external runtime dependencies and installs as a pure Python wheel, making it lightweight for integration into numerical or scientific workflows where shape preservation matters more than standard smoothing.
Use it for:
- Interpolating financial time-series data while preserving monotonicity in yield curves or volatility surfaces.
- Reconstructing smooth curves from scattered measurements in engineering or physics where convexity must be maintained.
- Building smooth interpolants for optimization problems where derivative information is available at sample points.
- Fitting curves through data with known monotonicity constraints, such as cumulative distributions or calibration curves.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Performs shape-preserving piecewise rational cubic interpolation using the Delbourgo-Gregory algorithm, maintaining monotonicity and convexity of interpolated curves.
Yes, if you need shape-preserving rational cubic interpolation and have endpoint derivatives available. The package is lightweight, permissively licensed, and implements a well-established algorithm. However, it is aging (no updates since initial release) and has minimal adoption; consider it only if standard cubic splines or other interpolation libraries do not meet your shape-preservation requirements.
Install
piecewise-rational on PyPI
pip
pip install piecewise-rationaluv
uv add piecewise-rationalpoetry
poetry add piecewise-rationalInstalling piecewise-rational
Before you install
Low install friction; pure Python wheel with no runtime dependencies. Package is aging (213 days since release) with no recent commits beyond initial publication, though the repository remains active and unarchived.
License in practice
MIT license permits commercial and private use with minimal restrictions; you must include a copy of the license and retain copyright notices in distributions.
Quickstart
from piecewise_rational import rational_cubic_interpolation
# Interpolate at x=0.5 given interval [0.0, 1.0], endpoint values, derivatives, and control parameter
y = rational_cubic_interpolation(0.5, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0)
Requires Python 3.9 or later (supports 3.9, 3.10, 3.11, 3.12, 3.13).
Verify before relying
- Practical performance characteristics and numerical stability compared to standard cubic spline methods.
- Whether the control parameter r has documented guidance for typical use cases.
- Real-world accuracy and speed on large datasets or high-dimensional problems.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 213 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 158,134/month — #10,734 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: piecewise_rational-1.0.0-py3-none-any.whl
Keywords: interpolation, rational cubic, shape preserving, monotonic, convex
Tags
More Mathematics packages
NetworkX provides data structures and…
permissive · top 1,000 on PyPI
kiwisolverkiwisolver is a Python binding to a fast C++…
permissive · top 1,000 on PyPI
sympySymPy is a Python library for symbolic…
permissive · top 1,000 on PyPI
contourpyContourPy calculates contours of 2D…
permissive · top 1,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
onnxruntimeonnxruntime loads and executes Open Neural…
permissive · top 1,000 on PyPI
py-lets-be-rationalComputes implied volatility from option prices…
permissive · top 15,000 on PyPI
ropwrRoPWR computes optimal piecewise polynomial…
permissive · top 15,000 on PyPI
cu2quConverts cubic Bézier curves to quadratic…
permissive · top 15,000 on PyPI
pytweeningPyTweening provides a collection of easing…
permissive · top 5,000 on PyPI
piecewise-regressionFits piecewise linear regression models to data…
permissive · top 15,000 on PyPI
quadprogSolves strictly convex quadratic programming…
copyleft · top 15,000 on PyPI
pwlfFits continuous piecewise linear functions to…
permissive · top 15,000 on PyPI
scsscs is a Python interface to the Splitting…
permissive · top 5,000 on PyPI
pyclothoidsPyclothoids provides a Python interface to…
unclear · top 15,000 on PyPI