Efficient way to multilinearize in Maple

57 Views Asked by At

I wish to use Maple to multilinearize polynomials. For example, given $xy^2z^4+x^3$ as input, I want $xyz+x$ as output. Is there a specific command for this?

2

There are 2 best solutions below

0
On BEST ANSWER

The very best way to do this in Maple is probably the evalindets command which lets you apply a transformation to type-selected subexpressions:

poly := x*y^2*z^4+x^3;  
linearpoly := evalindets(poly, 'name^posint', v->op(1,v));

The op command takes the operands of an expression, the first operand of an expression like x^n is the base of the power: x.

So the above code walks the expression tree and replaces every x^n term with x.

1
On

If you simply want to eliminate the powers, I suppose you could do this with a regular expression. In Maple this is done with the StringTools package.

with(StringTools):
have := x*y^2*z^4+x^3;                                ## Input

have_string := convert(have,string);                  ## Make it a string
want_string := RegSubs("\\^[0-9]" = "",have_string);  ## Remove "raised to number"
want := parse(want_string);                           ## Back to equation