Polynomial and rational function library
Project description
PolyRat: Polynomial and Rational Function Library
PolyRat is a library for polynomial and rational approximation. Formally we can think of polynomials as a sum of powers of :
A rational function is a ratio of two polynomial functions
The goal of this library is to construct polynomial and rational approximations given a collection of point data consisting of pairs of inputs and outputs that minimizes (for example)
The ultimate goal of this library is to provide algorithms to construct these approximations in a variety of norms with a variety of constraints on the approximants.
The polynomial approximation problem is relatively straightfoward as it is a convex problem for any p-norm with p≥1. However, there is still a need to be careful in the construction of the polynomial basis for high-degree polynomials to avoid ill-conditioning. Here we provide access to a number of polynomial bases:
- tensor-product polynomials based on Numpy (e.g., Monomial, Legendre, etc.);
- Vandermonde with Arnoldi polynomial basis;
- barycentric Lagrange polynomial bases.
The rational approximation problem is still an open research problem. This library provides a variety of algorithms for constructing rational approximations including:
- Adaptive Anderson Antoulas
- Sanathanan Koerner iteration
- Stabilized Sanathanan Koerner iteration
- Vector Fitting
Installation
> pip install --upgrade polyrat
Documentation
Full documentation is hosted on Read the Docs.
Usage
Using PolyRat follows the general pattern of scikit-learn. For example, to construct a rational approximation of the tangent function
import numpy as np
import polyrat
x = np.linspace(-1,1, 1000).reshape(-1,1) # Input data 🚨 must be 2-dimensional
y = np.tan(2*np.pi*x.flatten()) # Output data
num_degree, denom_degree = 10, 10 # numerator and denominator degrees
rat = polyrat.StabilizedSKRationalApproximation(num_degree, denom_degree)
rat.fit(x, y)
After constructing this approximation, we can then evaluate the resulting approximation by calling the class-instance
y_approx = rat(x) # Evaluate the rational approximation on X
Comparing this to training data, we note that this degree-(10,10) approximation is highly accurate
Reproducibility
This repository contains the code to reproduce the figures in the associated papers
- Multivariate Rational Approximation Using a Stabilized Sanathanan-Koerner Iteration in Reproducibility/Stabilized_SK
Related Projects
- baryrat: Pure python implementation of the AAA algorithm
- Block-AAA: Matlab implementation of a matrix-valued AAA variant
- RationalApproximations: Julia implementation AAA variants
- RatRemez Rational Remez algorithm (Silviu-Ioan Filip)
- BarycentricDC Barycentric Differential Correction (see SISC paper)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file polyrat-0.2.2.tar.gz
.
File metadata
- Download URL: polyrat-0.2.2.tar.gz
- Upload date:
- Size: 32.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | db8844edede4524c59089757bb8fcc9d313e87dad38a19ed87cfb252dc073eec |
|
MD5 | c801a1c3fc74de977bf8da7fc0035935 |
|
BLAKE2b-256 | 6f4252b44a501d6e8b06b3c454a0904c097752e5db84a953991b4ce118a3d22f |
File details
Details for the file polyrat-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: polyrat-0.2.2-py3-none-any.whl
- Upload date:
- Size: 50.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7993e21d7ef62e2f5292e03245e2064a1484131257726e72b169a9444bc32793 |
|
MD5 | f762adee0633ae2ab78f619f142b9a11 |
|
BLAKE2b-256 | 1c1043584e29529684dde0b28ea7a25ebf04ecd3e355f0fac2906cad4ecaa22d |