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?
Asked
Active
Viewed 56 times
0
-
I am probably treading in deep water here, but does global linearization make sense? Do you mean that the outputted linearization is around a point? If so, which? And is the output linear? Please excuse my possible ignorance. – Therkel Apr 07 '17 at 08:19
-
I want a procedure that replaces any term of the form $x_1^{n_1}\cdots x_k^{n_k}$ with $x_1\cdots x_k$. – TorsionSquid Apr 07 '17 at 12:12
2 Answers
2
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.
JP May
- 270
0
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
Therkel
- 1,332
-
You're almost always going to be better off operating directly on the Maple expressions rather than converting to a string. – JP May Apr 07 '17 at 20:16