Skip to main content

Python implementation of polynomials

Project description

pypolys package

Python implementation of polynomials is presented.

Installation

See doc/quickstart.txt

Usage

>>> from fractions import Fraction
>>> from pypolys.polys import Poly
>>> p = Poly(2, 3) + 4   # 2 * x ** 3 + 4
>>> p
Poly(4) + Poly(2, 3)
>>> p.is_zero()
False
>>> len(p)   # the number of terms
2
>>> p * Poly(3, 5)
Poly(12, 5) + Poly(6, 8)
>>> p ** 2
Poly(16) + Poly(16, 3) + Poly(4, 6)
>>> p.diff()
Poly(6, 2)                    # 6 * x ** 2
>>> p.integrate()
Poly(4, 1) + Poly(Fraction(1, 2), 4)   # 4 * x + x ** 4 / 2
>>> p.combine(Poly(5, 7))
Poly(4) + Poly(250, 21)
>>> p.eval(Fraction(3, 5))
Fraction(554, 125)
>>> p.eval(0.6)
4.432
>>> p.leading_term(key=Poly.key_deg)
Poly(2, 3)
>>> p.leading_monomial(key=Poly.key_deg)
Poly(1, 3)
>>> p.leading_coefficient(key=Poly.key_deg)
2
>>> Poly(6, 5) / Poly(3, 2)   # for monomials only
Poly(2, 3)
>>> Poly(6, 3).lcm(Poly(3, 2))
Poly(1, 3)
>>> list(p.iterterms())
[Poly(4), Poly(2, 3)]
>>> sorted(term.degree() for term in p.iterterms())
[0, 3]
>>> [p[i] for i in range(8)]  # coefficient list
[4, 0, 0, 2, 0, 0, 0, 0]

Contributors

Andrzej Kapanowski (project leader)

Adrian Szumski

EOF

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

pypolys-0.2.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pypolys-0.2.0-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file pypolys-0.2.0.tar.gz.

File metadata

  • Download URL: pypolys-0.2.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.3

File hashes

Hashes for pypolys-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2ed9f6bb4a8d6c2c7262057b262ae29c5277a732b178785c8273db5a0d0e1b25
MD5 9e39877e3ad24614de855799e51081d2
BLAKE2b-256 b47544b30c568d10481ad06f70b0eb2aa5fe8c8f32a98c61517778ff4a729486

See more details on using hashes here.

File details

Details for the file pypolys-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pypolys-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.3

File hashes

Hashes for pypolys-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db5e8751f378e82623be9bf6de20dbd95f2a0d089b250e6c52f925ec7922dca8
MD5 4465aa396c88daaf2e46da2a9c852d27
BLAKE2b-256 169d2ae06071be77c46ff31e96c59a5be6af67daa6c1d8d82060328e3951db72

See more details on using hashes here.

Supported by

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