Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a question related to working with symmetric polynomials in some variables. Let us say, I have an expression

expr = x^2 + y^2 + 2*x^3 + 2*y^3 + 3 x^2 y + 3 y^2 x

this is symmetric as x <-> y

I want to express this as expr1 + expr2 where

expr1 = x^2 + 2 x^3 + 3 x^2 y

and

expr2 = expr1/.{x -> y, y-> x}

How to use Mathematica to achieve this?

share|improve this question
    
Perhaps I'm missing something in the question, but Together[expr] gives what you want. –  rasher Mar 4 at 8:07
    
What distinguishes your target expressions from, say, expr1=expr2=expr/2? The two add up to your original expression and can be obtained from each other by doing x$\leftrightarrow$y. The class of functions that does that is rather broad! How do you pick your target from within that? –  episanty Mar 4 at 12:51

4 Answers 4

The original question is not clear. There is a wide range of functionality to work with polynomials symbolically e.g. PolynomialReduce, SymmetricReduction, etc. however it is not clear why one just assumes that expr1 and expr2 are as given above and if they are unique representants of possible reductions in terms of third order polynomials of two variables, most likely they are not.
So I find that this question is asking: how can I find appropriate coefficients {a, b, c} such that expr == p[x,y] + p[y,x] where:

p[x_, y_] := a x^3 + b x^2 + c x y^2

There is SolveAlways which helps in such cases:

{p[x, y], p[y, x]} /. SolveAlways[ expr == p[x, y] + p[y, x], {x, y}]
 {{x^2 + 2 x^3 + 3 x y^2, 3 x^2 y + y^2 + 2 y^3}}

PolynomialReduce demonstrates that expr1 and expr2 can express the original polynomial expr

PolynomialReduce[ expr, {expr1, expr2}, {x, y}]
{{1, 1}, 0}

SymmetricReduction serves a different purpose, see e.g.

SymmetricReduction[expr, {x, y}, {expr1, expr2}]
share|improve this answer

The usual way is to make a Groebner basis from the polynomials that define the relationships you intend to apply ("reduce with", if you will), and then do that with PolynomialReduce.

poly = x^2 + 2 x^3 + 3 x^2 y;
polys = {poly - e1, (poly /. {x -> y, y -> x}) - e2};
gb = GroebnerBasis[polys, {x, y}];

Now for the example in question.

expr = x^2 + y^2 + 2*x^3 + 2*y^3 + 3 x^2 y + 3 y^2 x;
PolynomialReduce[expr, gb, {x, y}][[2]]

(* e1 + e2 *)
share|improve this answer

Using knowledge from CoefficientList docs (Properties and Relations section) of how to recreate multivariate polynomial from coefficient list:

coe = CoefficientList[expr, {x, y}][[ All , ;; 2]];

expr1 = Fold[FromDigits[Reverse[#1], #2] &, coe, {x, y}] // Expand

expr2 = expr1 /. {x -> y, y -> x}
x^2 + 2 x^3 + 3 x^2 y
y^2 + 3 x y^2 + 2 y^3
share|improve this answer

One way to do that is :

expr = x^2 + y^2 + 2*x^3 + 2*y^3 + 3 x^2 y + 3 y^2 x;

expr1 = x^2 + 2 x^3 + 3 x^2 y;

expr2 = expr1 /. {x -> y, y -> x}

expr1 + expr2 == expr

Another way is to define functions :

expr1[x_,y_]:=x^2 + 2 x^3 + 3 x^2 y;
expr2[x_,y_]:=expr1[y,x];
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.