I use Maple primarily in a Unix text window (TTY or "command-line" Maple), so I am used to seeing common subexpression labeling in the output of my computations. However, in Maple 11, GUI users don't see subexpression labeling by default. I'll begin by talking about subexpression labeling as it appears in TTY Maple, then I'll talk about it in the GUI.
For starters lets look at an example in which a single subexpression is labeled:
f:=-62*x^3+97*x^2-73*x-4;
sol:=[solve](f,x,Explicit); #Explicit tells solve not to return RootOfs
--output--
1/3
%1 4169 97
sol := [- ----- + --------- + ---,
186 1/3 186
186 %1
1/3 / 1/3 \
%1 4169 97 1/2 | %1 4169 |
----- - --------- + --- + 1/2 I 3 |- ----- - ---------|,
372 1/3 186 | 186 1/3|
372 %1 \ 186 %1 /
1/3 / 1/3 \
%1 4169 97 1/2 | %1 4169 |
----- - --------- + --- - 1/2 I 3 |- ----- - ---------|]
372 1/3 186 | 186 1/3|
372 %1 \ 186 %1 /
1/2
%1 := 1270502 + 279 21667693
In the output here, the expression labeled as %1 is pulled out to make the display compact. This is relatively easy for the Maple kernel to do since in the internal representation of the list sol, every occurrence of %1 is just a pointer to the same expression.
Recently, I noticed something very cool (and obvious?) about these labels: Maple really means that "%1 :=". That is, when sol was printed %1 was assigned and can be used like the ditto operators (%, %%, and %%%).
Here is an examplet that generates two labels:
f:=(31*y-53)^2*(-62*x^3+97*x^2-73*x-4)-1;
sol:=[solve](f,x,Explicit);
In fact, the subexpression %1 occurs inside the subexpression %2:
1/3
%2 4169 %1 97
sol := [------ - --------- + ---,
186 %1 1/3 186
186 %2
1/3 / 1/3 \
%2 4169 %1 97 1/2 |%2 4169 %1 |
- ------ + --------- + --- + 1/2 I 3 |------ + ---------|,
372 %1 1/3 186 |186 %1 1/3|
372 %2 \ 186 %2 /
1/3 / 1/3 \
%2 4169 %1 97 1/2 |%2 4169 %1 |
- ------ + --------- + --- - 1/2 I 3 |------ + ---------|]
372 %1 1/3 186 |186 %1 1/3|
372 %2 \ 186 %2 /
2
%1 := 961 y - 3286 y + 2809
2 1/2 4
%2 := (-1220952422 y + 4174869572 y - 3568892012 + 93 3 (60031708521159 y
3 2
- 410539426015668 y + 1052839863430514 y - 1200022160121380 y
1/2 2
+ 512919835255259) ) %1
Other interesting things about labels:
So, how do you use subexpression labeling in the GUI? If you are using the classic worksheet interface, the answer is that you just have to change your renderer with interface(prettyprint=2): (the default is =3: editable math -- I am not sure what functionality this has over 2 in the classic interface). Labeling should work as it does in TTY Maple after doing this.
If you are using the Standard interface, you can also use interface(prettyprint=2): (again, I am not sure what the difference is between this and =3, but I would guess there is some functionality being lost by setting it to 2) to turn labeling on, but, unfortunately, the labels do not get assigned. You can still do some of the cool things mentioned above, but you have to cut and paste your subexpressions (of course, this will only sometimes work). I also noticed that labeling is more "aggressive" in the standard interface (a lot more labels are generated for the two examples above). I am guessing that the standard interface is calling a different internal routine to do the labeling.
Comments
those labels are not names
I'd like to add that those "percent" labels do not behave like names, in the sense that %1 is not the same as the name `%1` . It's not clear that any Maple name has actually been assigned, in Maple's usual sense, the expression which such a label represents. The labels appear to be accessible only at the interface level, and not directly from within the kernel. That's how it seems, at least, which goes along with their being next to impossible to procedurally manipulate.
acer