Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #15538 > unrolled thread
| Started by | Francisco Javier García Capitán <garciacapitan@gmail.com> |
|---|---|
| First post | 2013-09-26 07:41 +0000 |
| Last post | 2013-09-27 06:28 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Cyclic generator of a cyclic expression Francisco Javier García Capitán <garciacapitan@gmail.com> - 2013-09-26 07:41 +0000
Re: Cyclic generator of a cyclic expression danl@wolfram.com - 2013-09-27 06:28 +0000
| From | Francisco Javier García Capitán <garciacapitan@gmail.com> |
|---|---|
| Date | 2013-09-26 07:41 +0000 |
| Subject | Cyclic generator of a cyclic expression |
| Message-ID | <l20of9$aqh$1@smc.vnet.net> |
Dear friends, Given a cyclic expression say in x,y,z like x^4 + y^4 + z^4 - y^2 z^2 - z^2 x^2 - x^2 y^2 what is your more or less elegant way to get a cyclic generator, like x^4 - y^2 z^2 ? Thank you very much. -- --- Francisco Javier Garc=EDa Capit=E1n http://garciacapitan.99on.com
[toc] | [next] | [standalone]
| From | danl@wolfram.com |
|---|---|
| Date | 2013-09-27 06:28 +0000 |
| Message-ID | <l238io$gu0$1@smc.vnet.net> |
| In reply to | #15538 |
On Thursday, September 26, 2013 2:41:29 AM UTC-5, Francisco Javier Garc=EDaCapit=E1n wrote:
> Dear friends,
>
> Given a cyclic expression say in x,y,z like
>
> x^4 + y^4 + z^4 - y^2 z^2 - z^2 x^2 - x^2 y^2
>
> what is your more or less elegant way to get a cyclic generator, like
>
> x^4 - y^2 z^2 ?
>
> Thank you very much.
>
> ---
>
> Francisco Javier Garc=EDa Capit=E1n
>
> http://garciacapitan.99on.com
This may seem slightly backwards but we'll first show code to do the reverse, that is, invariantize a given expression with respect to cyclic shifting of the vvariable list. Note that this is order-dependent so we must provide the explicit list.
cyclicInvariantize[expr_, vars_] :=
Sum[expr /. Thread[vars -> RotateRight[vars, j]], {j, Length[vars]}]
Example (reverse of what you want):
In[62]:= ci = cyclicInvariantize[x^4 - y^2 z^2, {x, y, z}]
Out[62]= x^4 - x^2 y^2 + y^4 - x^2 z^2 - y^2 z^2 + z^4
Now we use this as follows. For each monomial in a given input, invariantize it. Then for each first occurrence of an invariantized subexpression, choose the monomial that gave rise to it. Sum the chosen monomials.
In[80]:= cyclicGenerator[expr_Plus, vars_] := Module[
{mtab = List @@ expr, seen, reptab},
invars = cyclicInvariantize[#, vars] & /@ mtab;
reptab =
Table[If[TrueQ[seen[invar]], False, seen[invar] = True;
True], {invar, invars}];
Total[Pick[mtab, reptab]]
]
Your example:
In[81]:= cyclicGenerator[ci, {x, y, z}]
Out[81]= x^4 - x^2 y^2
Daniel Lichtblau
Wolfram Research
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web