Recursive Rewriting of Expressions

Initializing live version
Download to Desktop

Requires a Wolfram Notebook System

Interact on desktop, mobile and cloud with the free Wolfram Player or other Wolfram Language products.

Often a large expression has many subexpressions in common. Recursive rewriting consists of replacing each common part of an expression with a symbol instead of writing out the part explicitly. This shows the overall structure at different levels.


Each such symbol is wrapped by a button; click one to see the level below it. Tooltips gives the subexpression with all constants replaced. Mouseover shows the ByteCount of the subexpression in red. Annotation shows the Leafcount, Length, and Depth of the argument. Finally, tree gives the TreeForm of the expression.


Contributed by: Enrique Zeleny (August 2015)
Open content licensed under CC BY-NC-SA



This example use a root of a fourth-degree polynomial. A possible application is to shorten large arithmetic expressions to speed up their numerical evaluation. Based on an idea in [1].


[1] M. Trott, The Mathematica GuideBook for Programming, New York: Springer-Verlag, 2004.

Feedback (field required)
Email (field required) Name
Occupation Organization
Note: Your message & contact information may be shared with the author of any specific Demonstration for which you give feedback.