Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: Replace each f in f^n to different variables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg126012] Re: Replace each f in f^n to different variables
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Fri, 13 Apr 2012 04:45:02 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201204120633.CAA05368@smc.vnet.net>

Provided n has a specific value

g = a + b*f + c*f^2 + d*f^3;

g /. f^(n_Integer: 1) :> Times @@ Table[Unique[f], {n}]

a + b f$721 + c f$722 f$723 + d f$724 f$725 f$726

g /. f^(n_Integer: 1) :> Product[Unique[f], {i, n}]

a + b f$727 + c f$728 f$729 + d f$730 f$731 f$732


Bob Hanlon


On Thu, Apr 12, 2012 at 2:33 AM, Yi Wang <tririverwangyi at gmail.com> wrote:
> Hi, all,
>
> I want to replace *each* f in f^n to a different variable, say
>
> f^n -> var1 * var2 * ... * varn
>
> Naively, if I try
>
> f^n /. f:>Unique[],
>
> Mathematica simply returns (a unique variable)^n, instead of the above behaviour.
>
> Is there a simple way to get the f's into different variables?
>
> Thanks!
> Yi
>
> PS:
>
> (1) I know there are ways to transform Power to a list by hand, and then do something in it. For example,
>
> Times[((f^3)[[1]]*Table[1, {(f^3)[[2]]}]) /. f :> Unique[]]
>
> However, eventually I will be dealing with a large expression, with all kinds of terms, instead of a single term. This method quickly becomes very complicated.
>
> (2) I want to do such "strange" things, because a product of functions in position space f(x)^n becomes F(k1)F(k2)...F(k_{n-1})F(-k1-k2...) in momentum space.
>



  • Prev by Date: Re: Replace a vertical line in ListPlot
  • Next by Date: Re: What characters are allowed in mathematica variable names? i.e. how
  • Previous by thread: Replace each f in f^n to different variables
  • Next by thread: Re: Replace each f in f^n to different variables