sympy.polys模块衍生出了很多函数,这里列举一些
1.gcd: 求公因式
f = 4*x**2 - 1
g = 8*x**3 + 1
gcd(f, g)
2.div: 代数式除法
eg.
5
x
2
+
10
x
+
3
=
(
2
x
+
1
)
(
5
x
2
+
5
2
)
−
2
5x^2+10x+3=(2x+1)\left(\dfrac{5x}{2}+\dfrac{5}{2}\right)-2
5x2+10x+3=(2x+1)(25x+25)−2
f = 5*x**2 + 10*x + 3
g = 2*x + 2
q, r = div(f, g)
3.degree: 求参数的最高次数
degree(x**2 + y*x + 1, gen=x)
如果要求所有参数的最高次数, degree_list
4.LC: 最高项系数
LC(4*x**2 + 2*x*y**2 + x*y + 3*y)
5.LM: Return the leading monomial of f.
LM(4*x**2 + 2*x*y**2 + x*y + 3*y)
6.LT: Return the leading term of f.
LT(4*x**2 + 2*x*y**2 + x*y + 3*y)
7.pdiv: 多项式除法
pdiv(x**2 + 1, 2*x - 4)
8.prem: 多项式相除的余数
prem(x**2 + 1, 2*x - 4)
9.pexquo: 多项式相除的商
pexquo(x**2 + 1, 2*x - 4)
10.lcm_list: 多项式的最小公倍数
lcm_list([x**3 - 1, x**2 - 1, x**2 - 3*x + 2])
11.factor: 因式分解。参数: extension,deep等等
12.Add.make_args:
Return a sequence of elements `args` such that cls(*args) == expr
同理,还有Mul.make_args