skillfed

piecewise-rational

Shape-preserving piecewise rational cubic interpolation (Delbourgo-Gregory algorithm)

piecewise-rational v1.0.0 158.1K downloads/30d#10,734 on PyPI0
Permissive license MIT AGING released

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

uv

uv add piecewise-rational

poetry

poetry add piecewise-rational

Installing 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

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9

Tags

rational cubic interpolationshape preserving interpolationmonotonic interpolationpiecewise rational curvesDelbourgo-Gregory algorithmconvex interpolationcubic spline alternative
numerical-methodsinterpolationscientific-computing

More Mathematics packages