Format for Differences

Neil Soiffer
Wolfram Research

Mathematica presents a difference of two terms in standard order:


Standard order puts variables in alphabetical order, with lower powers first. Therefore, the -d appears before y, which many would find unappealing. You can get the nicer result by using [Graphics:../Images/tricks_gr_68.gif].


You can also get the nicer result by writing your own format using [Graphics:../Images/tricks_gr_71.gif], the built-in function that converts an expression into boxes.


[Graphics:../Images/tricks_gr_75.gif] will produce an output that is editable and can be used as input without hidden meaning. There are two important things to notice. First, you need to apply [Graphics:../Images/tricks_gr_76.gif] recursively to its arguments. Second, [Graphics:../Images/tricks_gr_77.gif] is [Graphics:../Images/tricks_gr_78.gif]. This means you need to use [Graphics:../Images/tricks_gr_79.gif] instead of the simpler [Graphics:../Images/tricks_gr_80.gif] so that the [Graphics:../Images/tricks_gr_81.gif] evaluates.

If you put this format definition in your init.m file, it will take effect whenever you start the kernel.

Document converted by Mathematica of Wolfram Research