Symmetrize a polynomial forgetting the commutativity property of multiplication
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I need a script to authomatically symmetrize a given polynomial.
For example, if the input is
xy
the output should be
(xy+yx)/2
The same principle should work also for higher order polynomial. For example, if the input is
xyz
the output should be
(xyz+xzy+yxz+yzx+zxy+zyx)/6
The input is, in general, a polynomial. If the input is
xy+wz
the output should be
(xy+yx+wz+zw)/2
It may happen that some terms come with some powers. If the input is
x^2 z
the output should be either
(xxz + xxz +xzx+ xzx + zxx + zxx)/6
or
(2x^2z+2xzx+2zx^2)/6
Both these ouputs are good.
Thanks in advance for the help.
polynomials algebraic-manipulation algebra
add a comment |Â
up vote
1
down vote
favorite
I need a script to authomatically symmetrize a given polynomial.
For example, if the input is
xy
the output should be
(xy+yx)/2
The same principle should work also for higher order polynomial. For example, if the input is
xyz
the output should be
(xyz+xzy+yxz+yzx+zxy+zyx)/6
The input is, in general, a polynomial. If the input is
xy+wz
the output should be
(xy+yx+wz+zw)/2
It may happen that some terms come with some powers. If the input is
x^2 z
the output should be either
(xxz + xxz +xzx+ xzx + zxx + zxx)/6
or
(2x^2z+2xzx+2zx^2)/6
Both these ouputs are good.
Thanks in advance for the help.
polynomials algebraic-manipulation algebra
Are you always dealing with monomials, or should a solution expect things likex y + w z
?
â J. M. is computer-lessâ¦
2 hours ago
The input could be a polynomial as well. For example, if the input is $xy+wz$, the output should be $(xy+yx+wz+zw)/2$, but I know a priori what are the variables that come into play. Moreover, of course, it may appen to have things like $x^2y$ as input. In this case, the output should be either $(xxz+xzx+xxz+xzx+zxx+zxx)/6$ or $(2x^2z + 2xzx+ 2zx^2)/6$. Both outputs are ok for me.
â AndreaPaco
2 hours ago
@J.M.iscomputer-less, I've edited the question in order to meke my question more precise.
â AndreaPaco
1 hour ago
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I need a script to authomatically symmetrize a given polynomial.
For example, if the input is
xy
the output should be
(xy+yx)/2
The same principle should work also for higher order polynomial. For example, if the input is
xyz
the output should be
(xyz+xzy+yxz+yzx+zxy+zyx)/6
The input is, in general, a polynomial. If the input is
xy+wz
the output should be
(xy+yx+wz+zw)/2
It may happen that some terms come with some powers. If the input is
x^2 z
the output should be either
(xxz + xxz +xzx+ xzx + zxx + zxx)/6
or
(2x^2z+2xzx+2zx^2)/6
Both these ouputs are good.
Thanks in advance for the help.
polynomials algebraic-manipulation algebra
I need a script to authomatically symmetrize a given polynomial.
For example, if the input is
xy
the output should be
(xy+yx)/2
The same principle should work also for higher order polynomial. For example, if the input is
xyz
the output should be
(xyz+xzy+yxz+yzx+zxy+zyx)/6
The input is, in general, a polynomial. If the input is
xy+wz
the output should be
(xy+yx+wz+zw)/2
It may happen that some terms come with some powers. If the input is
x^2 z
the output should be either
(xxz + xxz +xzx+ xzx + zxx + zxx)/6
or
(2x^2z+2xzx+2zx^2)/6
Both these ouputs are good.
Thanks in advance for the help.
polynomials algebraic-manipulation algebra
polynomials algebraic-manipulation algebra
edited 1 hour ago
asked 2 hours ago
AndreaPaco
1324
1324
Are you always dealing with monomials, or should a solution expect things likex y + w z
?
â J. M. is computer-lessâ¦
2 hours ago
The input could be a polynomial as well. For example, if the input is $xy+wz$, the output should be $(xy+yx+wz+zw)/2$, but I know a priori what are the variables that come into play. Moreover, of course, it may appen to have things like $x^2y$ as input. In this case, the output should be either $(xxz+xzx+xxz+xzx+zxx+zxx)/6$ or $(2x^2z + 2xzx+ 2zx^2)/6$. Both outputs are ok for me.
â AndreaPaco
2 hours ago
@J.M.iscomputer-less, I've edited the question in order to meke my question more precise.
â AndreaPaco
1 hour ago
add a comment |Â
Are you always dealing with monomials, or should a solution expect things likex y + w z
?
â J. M. is computer-lessâ¦
2 hours ago
The input could be a polynomial as well. For example, if the input is $xy+wz$, the output should be $(xy+yx+wz+zw)/2$, but I know a priori what are the variables that come into play. Moreover, of course, it may appen to have things like $x^2y$ as input. In this case, the output should be either $(xxz+xzx+xxz+xzx+zxx+zxx)/6$ or $(2x^2z + 2xzx+ 2zx^2)/6$. Both outputs are ok for me.
â AndreaPaco
2 hours ago
@J.M.iscomputer-less, I've edited the question in order to meke my question more precise.
â AndreaPaco
1 hour ago
Are you always dealing with monomials, or should a solution expect things like
x y + w z
?â J. M. is computer-lessâ¦
2 hours ago
Are you always dealing with monomials, or should a solution expect things like
x y + w z
?â J. M. is computer-lessâ¦
2 hours ago
The input could be a polynomial as well. For example, if the input is $xy+wz$, the output should be $(xy+yx+wz+zw)/2$, but I know a priori what are the variables that come into play. Moreover, of course, it may appen to have things like $x^2y$ as input. In this case, the output should be either $(xxz+xzx+xxz+xzx+zxx+zxx)/6$ or $(2x^2z + 2xzx+ 2zx^2)/6$. Both outputs are ok for me.
â AndreaPaco
2 hours ago
The input could be a polynomial as well. For example, if the input is $xy+wz$, the output should be $(xy+yx+wz+zw)/2$, but I know a priori what are the variables that come into play. Moreover, of course, it may appen to have things like $x^2y$ as input. In this case, the output should be either $(xxz+xzx+xxz+xzx+zxx+zxx)/6$ or $(2x^2z + 2xzx+ 2zx^2)/6$. Both outputs are ok for me.
â AndreaPaco
2 hours ago
@J.M.iscomputer-less, I've edited the question in order to meke my question more precise.
â AndreaPaco
1 hour ago
@J.M.iscomputer-less, I've edited the question in order to meke my question more precise.
â AndreaPaco
1 hour ago
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
What about this?
f[NonCommutativeMultiply[x__]] := Mean[Permutations[NonCommutativeMultiply[x]]]
f[x ** y ** z]
1/6 (x ** y ** z + x ** z ** y + y ** x ** z + y ** z ** x +
z ** x ** y + z ** y ** x)
Adding
f[x_Times] := f /@ x
f[x_Plus] := f /@ x
f[x_?NumericQ] := x
allows us to treat also polynomials:
f[3 x ** x ** y + y ** y ** y + 54 x ** z ** y]
x ** x ** y + x ** y ** x + y ** x ** x + y ** y ** y +
9 (x ** y ** z + x ** z ** y + y ** x ** z + y ** z ** x +
z ** x ** y + z ** y ** x)
Thanks for your help. Can it handle a generic polynomial $P(x,y,z)$ such as $P(x,y,z)=3x^2y+y^3+54xzy$?
â AndreaPaco
1 hour ago
Thanks a lot for the update. You gave me a huge help. Just a curiosity more. In the input the non-commutative multiplication $**$ is already made explicit. Is there a way to authomatically turn a traditional multiplication (such as $x*y$) into a non-commutative one, (such as $x**y$)?
â AndreaPaco
1 hour ago
1
Yes, you can always tuse replacement rules, e.g.x x y //. Power[a_, k_Integer?Positive] :> NonCommutativeMultiply @@ ConstantArray[a, k], Times -> NonCommutativeMultiply
(however this won't work out with the coefficients).
â Henrik Schumacher
1 hour ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
What about this?
f[NonCommutativeMultiply[x__]] := Mean[Permutations[NonCommutativeMultiply[x]]]
f[x ** y ** z]
1/6 (x ** y ** z + x ** z ** y + y ** x ** z + y ** z ** x +
z ** x ** y + z ** y ** x)
Adding
f[x_Times] := f /@ x
f[x_Plus] := f /@ x
f[x_?NumericQ] := x
allows us to treat also polynomials:
f[3 x ** x ** y + y ** y ** y + 54 x ** z ** y]
x ** x ** y + x ** y ** x + y ** x ** x + y ** y ** y +
9 (x ** y ** z + x ** z ** y + y ** x ** z + y ** z ** x +
z ** x ** y + z ** y ** x)
Thanks for your help. Can it handle a generic polynomial $P(x,y,z)$ such as $P(x,y,z)=3x^2y+y^3+54xzy$?
â AndreaPaco
1 hour ago
Thanks a lot for the update. You gave me a huge help. Just a curiosity more. In the input the non-commutative multiplication $**$ is already made explicit. Is there a way to authomatically turn a traditional multiplication (such as $x*y$) into a non-commutative one, (such as $x**y$)?
â AndreaPaco
1 hour ago
1
Yes, you can always tuse replacement rules, e.g.x x y //. Power[a_, k_Integer?Positive] :> NonCommutativeMultiply @@ ConstantArray[a, k], Times -> NonCommutativeMultiply
(however this won't work out with the coefficients).
â Henrik Schumacher
1 hour ago
add a comment |Â
up vote
2
down vote
accepted
What about this?
f[NonCommutativeMultiply[x__]] := Mean[Permutations[NonCommutativeMultiply[x]]]
f[x ** y ** z]
1/6 (x ** y ** z + x ** z ** y + y ** x ** z + y ** z ** x +
z ** x ** y + z ** y ** x)
Adding
f[x_Times] := f /@ x
f[x_Plus] := f /@ x
f[x_?NumericQ] := x
allows us to treat also polynomials:
f[3 x ** x ** y + y ** y ** y + 54 x ** z ** y]
x ** x ** y + x ** y ** x + y ** x ** x + y ** y ** y +
9 (x ** y ** z + x ** z ** y + y ** x ** z + y ** z ** x +
z ** x ** y + z ** y ** x)
Thanks for your help. Can it handle a generic polynomial $P(x,y,z)$ such as $P(x,y,z)=3x^2y+y^3+54xzy$?
â AndreaPaco
1 hour ago
Thanks a lot for the update. You gave me a huge help. Just a curiosity more. In the input the non-commutative multiplication $**$ is already made explicit. Is there a way to authomatically turn a traditional multiplication (such as $x*y$) into a non-commutative one, (such as $x**y$)?
â AndreaPaco
1 hour ago
1
Yes, you can always tuse replacement rules, e.g.x x y //. Power[a_, k_Integer?Positive] :> NonCommutativeMultiply @@ ConstantArray[a, k], Times -> NonCommutativeMultiply
(however this won't work out with the coefficients).
â Henrik Schumacher
1 hour ago
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
What about this?
f[NonCommutativeMultiply[x__]] := Mean[Permutations[NonCommutativeMultiply[x]]]
f[x ** y ** z]
1/6 (x ** y ** z + x ** z ** y + y ** x ** z + y ** z ** x +
z ** x ** y + z ** y ** x)
Adding
f[x_Times] := f /@ x
f[x_Plus] := f /@ x
f[x_?NumericQ] := x
allows us to treat also polynomials:
f[3 x ** x ** y + y ** y ** y + 54 x ** z ** y]
x ** x ** y + x ** y ** x + y ** x ** x + y ** y ** y +
9 (x ** y ** z + x ** z ** y + y ** x ** z + y ** z ** x +
z ** x ** y + z ** y ** x)
What about this?
f[NonCommutativeMultiply[x__]] := Mean[Permutations[NonCommutativeMultiply[x]]]
f[x ** y ** z]
1/6 (x ** y ** z + x ** z ** y + y ** x ** z + y ** z ** x +
z ** x ** y + z ** y ** x)
Adding
f[x_Times] := f /@ x
f[x_Plus] := f /@ x
f[x_?NumericQ] := x
allows us to treat also polynomials:
f[3 x ** x ** y + y ** y ** y + 54 x ** z ** y]
x ** x ** y + x ** y ** x + y ** x ** x + y ** y ** y +
9 (x ** y ** z + x ** z ** y + y ** x ** z + y ** z ** x +
z ** x ** y + z ** y ** x)
edited 1 hour ago
answered 1 hour ago
Henrik Schumacher
41.8k260125
41.8k260125
Thanks for your help. Can it handle a generic polynomial $P(x,y,z)$ such as $P(x,y,z)=3x^2y+y^3+54xzy$?
â AndreaPaco
1 hour ago
Thanks a lot for the update. You gave me a huge help. Just a curiosity more. In the input the non-commutative multiplication $**$ is already made explicit. Is there a way to authomatically turn a traditional multiplication (such as $x*y$) into a non-commutative one, (such as $x**y$)?
â AndreaPaco
1 hour ago
1
Yes, you can always tuse replacement rules, e.g.x x y //. Power[a_, k_Integer?Positive] :> NonCommutativeMultiply @@ ConstantArray[a, k], Times -> NonCommutativeMultiply
(however this won't work out with the coefficients).
â Henrik Schumacher
1 hour ago
add a comment |Â
Thanks for your help. Can it handle a generic polynomial $P(x,y,z)$ such as $P(x,y,z)=3x^2y+y^3+54xzy$?
â AndreaPaco
1 hour ago
Thanks a lot for the update. You gave me a huge help. Just a curiosity more. In the input the non-commutative multiplication $**$ is already made explicit. Is there a way to authomatically turn a traditional multiplication (such as $x*y$) into a non-commutative one, (such as $x**y$)?
â AndreaPaco
1 hour ago
1
Yes, you can always tuse replacement rules, e.g.x x y //. Power[a_, k_Integer?Positive] :> NonCommutativeMultiply @@ ConstantArray[a, k], Times -> NonCommutativeMultiply
(however this won't work out with the coefficients).
â Henrik Schumacher
1 hour ago
Thanks for your help. Can it handle a generic polynomial $P(x,y,z)$ such as $P(x,y,z)=3x^2y+y^3+54xzy$?
â AndreaPaco
1 hour ago
Thanks for your help. Can it handle a generic polynomial $P(x,y,z)$ such as $P(x,y,z)=3x^2y+y^3+54xzy$?
â AndreaPaco
1 hour ago
Thanks a lot for the update. You gave me a huge help. Just a curiosity more. In the input the non-commutative multiplication $**$ is already made explicit. Is there a way to authomatically turn a traditional multiplication (such as $x*y$) into a non-commutative one, (such as $x**y$)?
â AndreaPaco
1 hour ago
Thanks a lot for the update. You gave me a huge help. Just a curiosity more. In the input the non-commutative multiplication $**$ is already made explicit. Is there a way to authomatically turn a traditional multiplication (such as $x*y$) into a non-commutative one, (such as $x**y$)?
â AndreaPaco
1 hour ago
1
1
Yes, you can always tuse replacement rules, e.g.
x x y //. Power[a_, k_Integer?Positive] :> NonCommutativeMultiply @@ ConstantArray[a, k], Times -> NonCommutativeMultiply
(however this won't work out with the coefficients).â Henrik Schumacher
1 hour ago
Yes, you can always tuse replacement rules, e.g.
x x y //. Power[a_, k_Integer?Positive] :> NonCommutativeMultiply @@ ConstantArray[a, k], Times -> NonCommutativeMultiply
(however this won't work out with the coefficients).â Henrik Schumacher
1 hour ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183830%2fsymmetrize-a-polynomial-forgetting-the-commutativity-property-of-multiplication%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Are you always dealing with monomials, or should a solution expect things like
x y + w z
?â J. M. is computer-lessâ¦
2 hours ago
The input could be a polynomial as well. For example, if the input is $xy+wz$, the output should be $(xy+yx+wz+zw)/2$, but I know a priori what are the variables that come into play. Moreover, of course, it may appen to have things like $x^2y$ as input. In this case, the output should be either $(xxz+xzx+xxz+xzx+zxx+zxx)/6$ or $(2x^2z + 2xzx+ 2zx^2)/6$. Both outputs are ok for me.
â AndreaPaco
2 hours ago
@J.M.iscomputer-less, I've edited the question in order to meke my question more precise.
â AndreaPaco
1 hour ago