Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #15548

Re: Cyclic generator of a cyclic expression

From danl@wolfram.com
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Cyclic generator of a cyclic expression
Date 2013-09-27 06:28 +0000
Message-ID <l238io$gu0$1@smc.vnet.net> (permalink)
References <l20of9$aqh$1@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


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

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

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

csiph-web