I need to represent polynomials of several variables, i.e.

x^3 + xy^4 + xz^2w + uq^2we^3

I've looked at the scipy package and it appears it only handles polynomial up to 3 variables. The main operation I would like to perform with these polynomials are

1) Multiplication of polynomials

2) Integration against a single variable of the polynomial (definite intergral)

3) Curve fitting the polynomial (of fixed variables and degrees) to data points

Any lead will be helpful. it would be nice if someone already done a good job before I have to implement them.

Also as a side note, I've never touched tensors but I suspect these operations is natural to express as a tensor of some sort? Is there any good tensor libraries instead that I could use and try to figure out how to express these operations as a tensor? Again I have not touched tensors at all but I can definitely learn it easy.

有帮助吗?

解决方案

1),2) Use sympy

from sympy import *

x = Symbol('x')
y = Symbol('y')
z = Symbol('z')
w = Symbol('w')
u = Symbol('u')
q = Symbol('q')
e = Symbol('e')

f = x**3 + x*y**4 + x*z**2*w + u*q**2*w*e**3

f2 = (f*f)

F = integrate(f, x) 
G = integrate(f, y)

3) Curve fitting is a different problem. I suggest you look at scipy.optimize module.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top