Previous Up Next

5.29.5  Transform a polynomial in internal format into a list, and conversely: convert

The convert command can take a polynomial in the internal format as a first argument and the list option as the second argument. Here, the list option can be omitted.
In this case, convert returns a list representing the polynomial.
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.

The convert command can also take a list as the first argument and the polynom option as the second argument.
In this case, convert returns the corresponding polynomial in internal format.
Input (l from above):

l

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