I want to replace Θ[z + m τ] by a[m] Θ[z]. So I consider the pattern Θ[z_ + m_ τ]:> a[m] Θ[z]. It works for almost all value of m, however, it seems to fail for m = 1, namely,

Θ[z+τ]/.{Θ[z_ + m_ τ]:> a[m] Θ[z]}

only spits out Θ[z+τ] again.

I wonder why this happens, and how to make it work for all m?


1 Answer 1


You can let the pattern matcher know that it can use the default pattern for Times by putting a . at the end of the m pattern.

Θ[z + τ] /. {Θ[z_ + m_. τ] :> a[m] Θ[z]}

evalutes to a[1] Θ[z].

  • $\begingroup$ Works like a charm. Thanks! $\endgroup$
    – Lelouch
    Commented May 6, 2019 at 5:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.