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: [mg126062] Re: Replace each f in f^n to different variables
  • From: Yi Wang <tririverwangyi at gmail.com>
  • Date: Sat, 14 Apr 2012 03:10:28 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <7BB0E96E72E84E41B24A1FF8ED13F5E629998E33CD@IE2RD2XVS581.red002.local>

Thanks a lot, Bob and Alexei! Yes, those methods work very well.

Best,
Yi

On Fri, Apr 13, 2012 at 3:18 AM, Alexei Boulbitch
<Alexei.Boulbitch at iee.lu> 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 be=
haviour.
>
> 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 k=
inds of terms, instead of a single term. This method quickly becomes very c=
omplicated.
>
> (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 momen=
tum space.
>
>
> Hi, Yi,
>
> Is this:
>
> replaceFun[g_] := If[MatchQ[g, Power[_, _]],
>   If[IntegerQ[g[[2]]],
>
>    Times @@ Table[ToExpression["var" <> ToString[i]], {i, 1, g[[2]]}]=
,
>         Print[
>     Style["Error: the function \!\(\*SuperscriptBox[\(f\), \(n\)]\) \
> has a non-integer exponent n", Red]]
>       ],
>   Print[Style[
>     "Error: the function does not have the form \
> \!\(\*SuperscriptBox[\(f\), \(n\)]\)", Red]]
>   ];
>
>
> replaceFun[f[x]^4.1]
> replaceFun[Sin[x]^6]
>
> Error: the function f^n has a non-integer exponent n
>
> var1 var2 var3 var4 var5 var6
>
> what you are looking for?
>
> Have fun, Alexei
>
>
> Alexei BOULBITCH, Dr., habil.
> IEE S.A.
> ZAE Weiergewan,
> 11, rue Edmond Reuter,
> L-5326 Contern, LUXEMBOURG
>
> Office phone :  +352-2454-2566
> Office fax:       +352-2454-3566
> mobile phone:  +49 151 52 40 66 44
>
> e-mail: alexei.boulbitch at iee.lu
>
>
>
>



  • Prev by Date: Re: fyi, small note on using Mathematica for object based programming
  • Next by Date: Re: Replace each f in f^n to different variables
  • Previous by thread: Re: Replace each f in f^n to different variables
  • Next by thread: Re: Replace each f in f^n to different variables