Recursive Rewriting of Expressions

Requires a Wolfram Notebook System

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

Requires a Wolfram Notebook System

Edit on desktop, mobile and cloud with any Wolfram Language product.

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.

[more]

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.

[less]

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


Snapshots


Details

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

Reference

[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.
Send