 Local Names - Maple Help

Reclaiming the use of the names 'I', 'D', 'gamma', and more

Maple's long history and extensive math library have invariably claimed some names that you may want to use for something else. For example, the capital letter 'I' in Maple means the imaginary unit, but why not the identity matrix instead?  Similarly, after defining variables, A, B, and C, why can't you continue the pattern and use D? In Maple 17 you can.

 > local D := 5:
 > D+D;
 ${10}$ (1)

By declaring 'D' local at the top-level, a new local variable has been created with the name 'D' and made the default in the current name-space in a way similar to that of using the short-name to access package exports after using the "with" command to load a package. The global version of this name, the differential operator, is still available by prefixing the name with colon-dash.

 > :-D(f)(0);
 ${}{:-}{\mathrm{D}}{}\left({f}\right){}\left({0}\right)$ (2)
 > convert(:-D(f)(0), 'diff');
 $\genfrac{}{}{0}{}{\frac{{ⅆ}}{{ⅆ}{\mathrm{t1}}}{}{f}{}\left({\mathrm{t1}}\right)}{\phantom{{\mathrm{t1}}{=}{0}}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{|}\phantom{\rule[-0.0ex]{0.1em}{0.0ex}}\genfrac{}{}{0}{}{\phantom{\frac{{ⅆ}}{{ⅆ}{\mathrm{t1}}}{}{f}{}\left({\mathrm{t1}}\right)}}{{\mathrm{t1}}{=}{0}}$ (3)



Any variable can be declared local, even ones that are not protected.

 > local x, y, min:
 > x := 4.4; y := 320.1; min := 0.001;
 ${x}{:=}{4.4}$
 ${y}{:=}{320.1}$
 ${\mathrm{min}}{:=}{0.001}$ (4)

The global versions remain available via :-.

 > :-x, :-y, :-min(x,y);
 ${}{:-}{x}{,}{}{:-}{y}{,}{4.4}$ (5)

The imaginary unit, I, also obeys a local declaration even though it is a special alias governed by interface(imaginaryunit). In this case the name of the global version becomes _I instead of :-I.

 > local I:
 > I := <1, 0, 0; 0, 1, 0; 0, 0, 1>;
 ${I}{:=}\left[\begin{array}{rrr}{1}& {0}& {0}\\ {0}& {1}& {0}\\ {0}& {0}& {1}\end{array}\right]$ (6)
 > I^2;
 $\left[\begin{array}{rrr}{1}& {0}& {0}\\ {0}& {1}& {0}\\ {0}& {0}& {1}\end{array}\right]$ (7)
 > _I^2;
 ${-}{1}$ (8) See Also