polynomial-math

Integral of a Polynomial in Python

Integral of a Polynomial in Python Question: How would we write a function in python that returns the definite integral of a polynomial between two points (X_1 and X_2)? The function takes 3 arguments: a list A of polynomial coefficients (i.e. for polynomial f(x)=5x^4−2x+1, this list becomes A=[5,0,0,−2,1]) a real number X_1 a real number …

Total answers: 3

Interpolate polynomial over a finite field

Interpolate polynomial over a finite field Question: I want to use python interpolate polynomial on points from a finite-field and get a polynomial with coefficients in that field. Currently I’m trying to use SymPy and specifically interpolate (from sympy.polys.polyfuncs), but I don’t know how to force the interpolation to happen in a specific gf. If …

Total answers: 2

fft division for fast polynomial division

fft division for fast polynomial division Question: I’m trying to implement fast polynomial division using Fast Fourier Transform (fft). Here is what I have got so far: from numpy.fft import fft, ifft def fft_div(C1, C2): # fft expects right-most for significant coefficients C1 = C1[::-1] C2 = C2[::-1] d = len(C1)+len(C2)-1 c1 = fft(list(C1) + …

Total answers: 1

Equivalent of `polyfit` for a 2D polynomial in Python

Equivalent of `polyfit` for a 2D polynomial in Python Question: I’d like to find a least-squares solution for the a coefficients in z = (a0 + a1*x + a2*y + a3*x**2 + a4*x**2*y + a5*x**2*y**2 + a6*y**2 + a7*x*y**2 + a8*x*y) given arrays x, y, and z of length 20. Basically I’m looking for the …

Total answers: 5

A faster numpy.polynomial?

A faster numpy.polynomial? Question: I have a very simple problem: in my python toolbox, I have to compute the values of polynomials (usually degree 3 or 2, seldom others, always integer degree) from a large vector (size >> 10^6). Storing the result in a buffer is not an option because I have several of these …

Total answers: 2