Let's examine a simple case: fricas Dg := [p3 - 3*p2 + 3*p1 - p0,
Type: List(Polynomial(Integer))Now calculate coefficients in two ways: fricas map(coefficients,
Type: List(List(Integer))and fricas map(coefficients,
Type: List(List(Integer))As you see the list are all reversed, but... they were not padded with zeros. While in my opinion they should be - we have a given order of variables, and alone 1 in the last list suggests that this is a coefficient of p3 while it isn't. It is a coefficient of p0. According to the FriCAS book function fricas pol1 := first(Dg)
Type: Polynomial(Integer)fricas monomials(pol1)
Type: List(Polynomial(Integer))fricas coefficients(pol1)
Type: List(Integer)fricas map(degree,
Type: List(IndexedExponents?(Symbol))fricas pol2 := pol1::MPOLY([p0,
fricas monomials(pol2)
fricas coefficients(pol2)
Type: List(Integer)fricas map(degree,
Remember that there are also terms of degree higher than 1. In fact the two multivariate polynomials that you used above are formally identical fricas (Dg::List MPOLY([p0,
Type: BooleanTo produce a list of coefficients of the terms of degree 1,
including the zeros and in a specific order, use the function
fricas [[coefficient(p,
Type: List(List(Polynomial(Integer)))And of course you can use this to produce a matrix. fricas matrix %
Type: Matrix(Polynomial(Integer))Actually, unstated assumption in FriCAS is that multivariate
polynomials are sparse, so omiting zeros is desirable.
For univariate polynomials one can use fricas [vectorise(univariate(p,
Type: List(Vector(Polynomial(Integer))) |