Skip to main content

Low-level functions for evaluating and manipulating polynomials (Python bindings)

Project description

Low-level functions for evaluating and manipulating polynomials.

Examples

The vector of coefficients for the polynomial f(x, y) = 3 x y + x^2 is [0, 3, 0, 1, 0, 0].

With eval() we can evaluate this polynomial:

import nutils_poly
import numpy

coeffs = numpy.array([0, 3, 0, 1, 0, 0], dtype=float)
# array of three `x` and `y` pairs (last axis)
values = numpy.array([[1, 0], [1, 1], [2, 3]], dtype=float)
numpy.testing.assert_allclose(nutils_poly.eval(coeffs, values), [1, 4, 22])

PartialDerivPlan::apply() computes the coefficients for the partial derivative of a polynomial to one of the variables. The partial derivative of f to x, the first variable, is ∂_x f(x, y) = 3 y + 2 x (coefficients: [3, 2, 0]):

import nutils_poly
import numpy

coeffs = numpy.array([0, 3, 0, 1, 0, 0], dtype=float)
pd = nutils_poly.PartialDerivPlan(
    2, # number of variables
    2, # degree
    0, # variable to compute the partial derivative to
)
numpy.testing.assert_allclose(pd(coeffs), [3, 2, 0])

Further reading

This package is a Python interface for the Rust crate nutils-poly using PyO3.

This package is part of the Nutils project.

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

nutils_poly-1.0.0.tar.gz (15.7 kB view hashes)

Uploaded Source

Built Distributions

nutils_poly-1.0.0-cp37-abi3-win_amd64.whl (215.6 kB view hashes)

Uploaded CPython 3.7+ Windows x86-64

nutils_poly-1.0.0-cp37-abi3-win32.whl (204.7 kB view hashes)

Uploaded CPython 3.7+ Windows x86

nutils_poly-1.0.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ x86-64

nutils_poly-1.0.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARM64

nutils_poly-1.0.0-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (682.8 kB view hashes)

Uploaded CPython 3.7+ macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

nutils_poly-1.0.0-cp37-abi3-macosx_10_7_x86_64.whl (349.4 kB view hashes)

Uploaded CPython 3.7+ macOS 10.7+ x86-64

Supported by

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