Mathematica > Core Language > Rules & Patterns > Rules >

ReplaceRepeated (//.)

expr//.rules
repeatedly performs replacements until expr no longer changes.
  • expr//.rules effectively applies /. repeatedly, until the results it gets no longer change.
  • It performs one complete pass over the expression using /., then carries out the next pass.
  • You should be very careful to avoid infinite loops when you use the //. operator. The command x//.x->x+1 will, for example, lead to an infinite loop.
Apply rules for the power and product laws for logarithms of real numbers recursively:
In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=
ReplaceAll does just a single replacement:
In[3]:=
Click for copyable input
Out[3]=
New in 1
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team