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

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

The convert command does many conversions (see Section 5.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:

- convert takes one mandatory argument and one optional argument:
  - P, a polynomial written in internal sparse multivariate format (see Section 5.27.2).
  - Optionally, list.
- convert(P ⟨, list⟩) returns a list representing the polynomial.

#### 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:

- convert takes two arguments:
  - L, a list representing a polynomial.
  - polynom.
- convert(L,polynom) returns the polynomial in internal sparse multivariate format (see Section 5.27.2).

#### 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]%%%}