The `a r` (`calc-rewrite`

) [`rewrite`

] command makes
substitutions in a formula according to a specified pattern or patterns
known as *rewrite rules*. Whereas `a b` (`calc-substitute`

)
matches literally, so that substituting ‘`sin(x)`’ with ‘`cos(x)`’
matches only the `sin`

function applied to the variable `x`

,
rewrite rules match general kinds of formulas; rewriting using the rule
‘`sin(x) := cos(x)`’ matches `sin`

of any argument and replaces
it with `cos`

of that same argument. The only significance of the
name `x`

is that the same name is used on both sides of the rule.

Rewrite rules rearrange formulas already in Calc’s memory.
See Syntax Tables, to read about *syntax rules*, which are
similar to algebraic rewrite rules but operate when new algebraic
entries are being parsed, converting strings of characters into
Calc formulas.

- Entering Rewrite Rules
- Basic Rewrite Rules
- Conditional Rewrite Rules
- Algebraic Properties of Rewrite Rules
- Other Features of Rewrite Rules
- Composing Patterns in Rewrite Rules
- Nested Formulas with Rewrite Rules
- Multi-Phase Rewrite Rules
- Selections with Rewrite Rules
- Matching Commands
- Automatic Rewrites
- Debugging Rewrites
- Examples of Rewrite Rules