Polynomials (polynomial) ======================== .. currentmodule:: numpycore.polynomial The ``polynomial`` module provides classes and functions for polynomial operations. Example ------- .. code-block:: python import numpycore as np # Create polynomial: 1 + 2x + 3x^2 p = np.polynomial.Polynomial([1, 2, 3]) # Evaluate at x = 2 print(p(2)) # 17.0 # Polynomial arithmetic q = np.polynomial.Polynomial([1, 1]) print(p + q) # Add polynomials print(p * q) # Multiply polynomials # Polynomial fitting x = np.array([0, 1, 2, 3, 4]) y = np.array([0, 1, 4, 9, 16]) coeffs = np.polyfit(x, y, 2) Polynomial Class ---------------- .. list-table:: :widths: 30 70 :header-rows: 1 * - Method - Description * - Polynomial(coef) - Create polynomial from coefficients * - __call__(x) - Evaluate polynomial at x * - deriv(m=1) - Derivative of polynomial * - integ(m=1) - Indefinite integral * - roots() - Polynomial roots * - fit(x, y, deg) - Least squares fit Polynomial Functions -------------------- .. list-table:: :widths: 25 75 :header-rows: 1 * - Function - Description * - polyval(x, c) - Evaluate polynomial at points x * - polyfit(x, y, deg) - Least squares polynomial fit * - polyadd(c1, c2) - Add two polynomials * - polysub(c1, c2) - Subtract two polynomials * - polymul(c1, c2) - Multiply two polynomials * - polydiv(c1, c2) - Divide two polynomials * - polyder(c) - Polynomial derivative * - polyint(c) - Polynomial integral * - polyroots(c) - Roots of polynomial Special Polynomials ------------------- .. list-table:: :widths: 25 75 :header-rows: 1 * - Class - Description * - Chebyshev - Chebyshev polynomials * - Legendre - Legendre polynomials * - Hermite - Hermite polynomials (physicist's) * - HermiteE - Hermite polynomials (probabilist's) * - Laguerre - Laguerre polynomials