Previous Up Next

6.27.6  Transforming a polynomial in internal format into a list, and conversely: convert

The convert command does many conversions (see Section 6.23.26). Among other things, it can convert between a polynomial in internal sparse multivariate format and a list representing the polynomial.

To convert from a polynomial in internal sparse multivariate format to a list:


Example.
Input:

p:= symb2poly(x^2 - x*y + 2y, [x,y])

Output:

%%%{1,[2,0]%%%}+%%%{-1,[1,1]%%%}+%%%{2,[0,1]%%%}

Input:

l:= convert(p,list)

or:

l:= convert(p)

Output:







1

2,0
−1

1,1
2

0,1






which is a list of the coefficients followed by a list of the variable powers.

To convert from a list representing a polynomial to the polynomial in internal sparse multivariate format:


Example.
Input (l from above):

l:=[[1,[2,0]],[-1,[1,1]],[2,[0,1]]]

Output:







1

2,0
−1

1,1
2

0,1






Input:

convert(l,polynom)

Output:

%%%{1,[2,0]%%%}+%%%{-1,[1,1]%%%}+%%%{2,[0,1]%%%}

Previous Up Next