# Making some powers of variables inside the function : $X * \alpha^{m} *\beta^{n} f[A[x,y]] \Rightarrow X f[\alpha^{m}\beta^{n} A[x,y]]$

Suppose I have a function of the form $$a_1 a_2 \cdots a_n b_1 \cdots b_m \cdots f[L[x,y]]$$. I want to make some particular letters and their power inside the bracket.

i.e., I want the letter $$\alpha, \beta$$ be inside the bracket \begin{align} X * \alpha^{m} *\beta^{n} f[A[x,y]] \Rightarrow X f[\alpha^{m}\beta^{n} A[x,y]] \end{align} What I know for the include of function in general is the following :

 a*f[L[x, y]] /. {A_ f[x__] -> f[A*x]}


but this does not specify the certain conditions for my purpose. i.e., for Xaf[L[x,y]] it just gives f[a X L[x,y]]$. Specifically what I want to do is for some specific powers of letters $$X*\alpha^{m}*\beta^{n}*\gamma^{l}*\delta^{e} f[A[x,y]]$$ I want to pick some letter, i.e. ,$$\alpha, \beta$$, and include this the function $$f$$, i.e. ,I want my result be $$X \gamma^{l} \delta^{e} f[ \alpha^{m} \beta^{n} A[x,y]]$$ Without explicit substitution case by case, are there a nice way to implement this by mathematica? ## 1 Answer $Version

(* "13.3.1 for Mac OS X ARM (64-bit) (July 24, 2023)" *)

Clear["Global*"]

rule = {(A : _?(! FreeQ[#, a | b] &) : 1)*
(B : _?(FreeQ[#, a | b] &) : 1)*f[x__] -> B*f[A*x]};

test = {X f[L[x, y]], a*f[L[x, y]], a*X*f[L[x, y]], b^n*X*f[L[x, y]],
a^m*b*X*f[L[x, y]], a^m*b^n*X*f[L[x, y]]};

Transpose[{test, test /. rule}] // Column


• if I want to include $c$ or $d$ in the rule, what should I modify? Dec 5, 2023 at 7:03
• Look at the documentation for Alternatives`, it can take as many arguments as you want. Dec 5, 2023 at 7:58