Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2013

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Cyclic generator of a cyclic expression

  • To: mathgroup at smc.vnet.net
  • Subject: [mg131745] Re: Cyclic generator of a cyclic expression
  • From: danl at wolfram.com
  • Date: Fri, 27 Sep 2013 02:28:52 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net
  • References: <l20of9$aqh$1@smc.vnet.net>

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



  • Prev by Date: Aspect ratio of bounding box
  • Next by Date: Re: BitAnd[True,False]
  • Previous by thread: Re: Cyclic generator of a cyclic expression
  • Next by thread: Re: Creating a PDF graphic with Mathematica