Skip to main content

Polynomial and rational function library

Project description

PolyRat: Polynomial and Rational Function Library

PyPI version CI Coverage Status Documentation Status

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:

The rational approximation problem is still an open research problem. This library provides a variety of algorithms for constructing rational approximations including:

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

A rational approximation of the tangent function

Reproducibility

This repository contains the code to reproduce the figures in the associated papers

Related Projects

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for polyrat, version 0.2.2
Filename, size File type Python version Upload date Hashes
Filename, size polyrat-0.2.2-py3-none-any.whl (50.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size polyrat-0.2.2.tar.gz (32.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page