문제

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