When it's not more complicated than your example, I do the replacement in the form
c1 C1 c2 C2 c3 C3 c4 C4 /. {C1 -> F1 / c1, C2 -> F2 / c2, C3 -> F3 / c3, C4 -> F4 / c4}
with simplified patterns that avoid tricky issues of pattern-matching.
The trouble is that the FullForm
of c1 C1
is Times[c1, C1]
which on the face of it doesn't exactly match the FullForm
of c1 C1 c2 C2 c3 C3 c4 C4
, which is
Times[c1, C1, c2, C2, c3, C3, c4, C4]
But the pattern-matcher does match them and replaces only a subsequence of the arguments of Times
. But since the Times
expression has matched already, further rules are not applied. We're lucky (as users) that it matches once, but unlucky that it doesn't match repeatedly. That's why ReplaceRepeated
(//.
) works: it keeps applying the rules until there are no more matches. First rule will be applied the first time but not on subsequent tries since it will no longer match; and second on the second try, etc.
//.
instead of/.
$\endgroup$ReplaceAll
andReplaceRepeated
$\endgroup$Plus
andTimes
are discussed. $\endgroup$