2
$\begingroup$

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?

$\endgroup$

closed as off-topic by Daniel Lichtblau, Bob Hanlon, m_goldberg, Carl Lange, LCarvalho May 13 at 11:19

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Daniel Lichtblau, Bob Hanlon, m_goldberg, Carl Lange, LCarvalho
If this question can be reworded to fit the rules in the help center, please edit the question.

5
$\begingroup$

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].

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

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