Max*_*tor 5 degrees maxima polynomials coefficients
在maxima中是否有一个内置函数可以从多项式函数得到一个带有系数的列表?并获得多项式的次数?
我发现的函数最相似args,但它也将变量与系数一起返回.我本来可以接受这个,当length与一起使用时还会更多地args返回学位.问题是args无法使用零度多项式.
是否有其他功能可以更好地适应这些目的?提前致谢.
要计算一个变量中多项式的次数,可以使用该hipow函数.
(%i) p1 : 3*x^5 + x^2 + 1$
(%i) hipow(p1,x);
(%o) 5
Run Code Online (Sandbox Code Playgroud)
对于具有多个变量的多项式,可以映射函数hipow返回的变量listofvars,然后获取结果列表的最大值.
(%i) p2 : 4*y^8 - 3*x^5 + x^2 + 1$
(%i) degree(p) := if integerp(p) then 0 else
lmax(map (lambda([u], hipow(p,u)),listofvars(p)))$
(%i) degree(p1);
(%o) 5
(%i) degree(p2);
(%o) 8
(%i) degree(1);
(%o) 0
Run Code Online (Sandbox Code Playgroud)
该coeff函数返回的系数x^n,给定的coeff(p,x,n),所以要产生一个变量多项式的系数的列表,我们可以通过x的权力迭代,保存系数的列表.
(%i) coeffs1(p,x) := block([l], l : [],
for i from 0 thru hipow(p,x)
do (l : cons(coeff(p,x,i),l)), l)$
(%i) coeffs1(p1,x);
(%o) [3, 0, 0, 1, 0, 1]
Run Code Online (Sandbox Code Playgroud)
并且为了在多个变量中生成多项式的系数列表,将其映射coeffs1到listofvars.
(%i) coeffs(p) := map(lambda([u], coeffs1(p, u)), listofvars(p))$
(%i) coeffs(p2);
(%o) [[- 3, 0, 0, 1, 0, 4 y^8 + 1],
[4, 0, 0, 0, 0, 0, 0, 0, - 3 x^5 + x^2 + 1]]
Run Code Online (Sandbox Code Playgroud)