I have some issues with expressions like the following
A^3B^4/b + A^3B^4C/d
in that I want to substitute A^3B^4
and A^3 B^4C
with γ
andδ
, respectively. However, if I am going to use ReplaceAll
, then I need to take care of the order, i.e.,
/.{A^3B^4C -> δ, A^3B^4 -> γ}
gives the right output, whereas
/. {A^3B^4 -> γ, A^3B^4C -> δ}
does not. I have tried to use Replace
, but to use it I need to specify the coefficients attached to each term in the expression. Regrettably this is not feasible as the expressions I need to handle are way more complex and lengthy that the one above. Any ideas?
I'll give you a simple example. With
A^2*B^4*C + A^2*B^4 /. {A^2*B^4*C -> gamma, A^2*B^4 -> delta}
I get
gamma + delta
the answer I want. But with
A^2*B^4*C + A^2*B^4 /. {A^2*B^4 -> delta, A^2*B^4*C -> gamma}
I get
delta + C delta
gamma/b+delta/d
which appears to be correct. $\endgroup$