My question is quite a simple one, but I have not been able to find a solution yet. Say I have terms of the form e.g
1/n1/n2/n3/n4
and
n5/n1/n2/n3/n4
where the ni are just symbols. I want to replace these two terms as follows.
/.{1/n1/n2/n3/n4->a, n5/n1/n2/n3/n4->b}
I find that in some cases Mathematica will do it, but in some cases it will give me expressions like replacing the latter term as n5*a, etc. rather than just b as indicated. The replacement works how I like it to if I order the replacements in the right way within the brackets. Is there a way to make this automatic? I am dealing with many of these terms so to order appropriately would be tiresome.
FullForm
you'll see something like this:Times[Power[n1,-1]...]
. The difference between the two expressions is that the later one has aFullForm
ofTimes[Power[n1,-1]..., n5]
. Pattern matching will work differently depending on which rule you place first after/.
the way you define your patterns. $\endgroup$