--- id: piecewise-rational version: "1.0.0" license: MIT license_treatment: permissive maintenance: aging --- # piecewise-rational — Shape-preserving piecewise rational cubic interpolation (Delbourgo-Gregory algorithm) License: permissive · Maintenance: aging · Downloads: 158.1K/mo ## 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 above — 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 pip install piecewise-rational uv add piecewise-rational 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_current - Install friction: low - Maintenance: aging - Downloads: 158.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags rational cubic interpolation, shape preserving interpolation, monotonic interpolation, piecewise rational curves, Delbourgo-Gregory algorithm, convex interpolation, cubic spline alternative, numerical-methods, interpolation, scientific-computing [View on SkillFed](https://skillfed.io/packages/piecewise-rational) · [View on PyPI](https://pypi.org/project/piecewise-rational/)