How to | Use a Rule with an Expression More Than Once

You may find it useful to use one or more rules with an expression several times. The Wolfram Language provides functions that let you iterate when using rules with expressions. In cases where a rule can be used in several ways with an expression, the Wolfram Language also allows you to view all possible results.

While /. (the short form for ReplaceAll) applies rules to an expression only once, you may find it useful to repeatedly apply rules to an expression until it no longer changes. You can do this by using //. (the short form for ReplaceRepeated).

Use /. to apply a rule or list of rules to each part of an expression only once:

Use //. to apply the rules repeatedly until the expression no longer changes:


You should use caution when using //. with a circular set of rules. Use the MaxIterations option to set the maximum number of iterations for //.:

You can use ReplaceList to transform an entire expression by applying a rule or list of rules in all possible ways. Use Column to display the results for easier viewing: