Skip to main content

Python polynomial C extension.

Project description

A Python extension written in C, implementing the Polynomial type.

Installation

Installation from source:

$ python setup.py install

Or, using pip:

$ pip install PyPolynomial

Usage

Instanciating a polynomial:

>>> from pypoly import Polynomial
>>> P = Polynomial(-1, 0, complex(1, 3))
>>> P
-1 + (1+3j) * X**2
>>> P.degree
2

Or:

>>> from pypoly import X
>>> P = (X - 1) * (X**2 + 2)
>>> P
-2 + 2 * X - X**2 + X**3

Operations on polynomials:

>>> Polynomial(-1, -1) * Polynomial(2, -3)
-2 + X + 3 * X**2
>>> P = Polynomial(1, 2, 3)
>>> P(13)
534.0
>>> (1 + X + X**2) // (1 + X)
X
>>> (2 * X + 3 * X**2 + X**5 + X**7) % (X**2 + 1)
-3 + 2 * X

Even more:

>>> (1 + X**3 - 2 * X**5) >> 2      # Second derivative
6 * X - 40 * X**3
>>> (1 + 2 * X) << 1                # Primitive integral
X + X**2
>>> from pypoly import gcd
>>> gcd(X**6 - 1, X**12 - 1, X**9 - 1)
-1 + X**3

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

PyPolynomial-0.4.1.tar.gz (14.3 kB view details)

Uploaded Source

File details

Details for the file PyPolynomial-0.4.1.tar.gz.

File metadata

  • Download URL: PyPolynomial-0.4.1.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for PyPolynomial-0.4.1.tar.gz
Algorithm Hash digest
SHA256 24f32eab165003a798d83434b45fd2240223d633a90c8396e514c0588a66c5c7
MD5 cc0b59178f5df6085b1f3e4f85e3a022
BLAKE2b-256 8cbeef61da0d4fa19cb3beb1d1b2533af73c05626ff803b24345480585eb3267

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page