Transforming a polynomial in internal format into a list and back

### 11.1.6 Transforming a polynomial in internal format into a list and back

The convert command does many conversions (see Section 10.1.10). 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, convert takes one mandatory argument and one optional argument:
  - P, a polynomial written in internal sparse multivariate format (see Section 11.1.2).
  - Optionally, list.
- convert(P ⟨, list⟩) returns a list representing the polynomial.
- To convert from a list representing a polynomial to the polynomial in internal sparse multivariate formatconvert takes two arguments:
  - L, a list representing a polynomial.
  - polynom.
- convert(L,polynom) returns the polynomial in internal sparse multivariate format (see Section 11.1.2).

#### Examples

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

%%%{1,[2,0]%%%}+%%%{−1,[1,1]%%%}+%%%{2,[0,1]%%%} |  |  |  |  |  |  |  |  |  |

l:=convert(p,list)

or:

l:=convert(p)

⎡ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ |
1 |
⎡ ⎣ | 2,0 | ⎤ ⎦
−1 |
⎡ ⎣ | 1,1 | ⎤ ⎦
2 |
⎡ ⎣ | 0,1 | ⎤ ⎦
| ⎤ ⎥ ⎥ ⎥ ⎥ ⎥ ⎦

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

convert(l,polynom)

%%%{1,[2,0]%%%}+%%%{−1,[1,1]%%%}+%%%{2,[0,1]%%%} |  |  |  |  |  |  |  |  |  |