 environment variables - Maple Help

Environment Variables Description

 • An environment variable is similar to a global variable, except that any assignments made to it during the execution of a procedure are only in effect during the execution of that procedure, and any procedures called from it (to any depth) during the execution. When the procedure that assigned the environment variable exits, the assignment is undone, restoring any value the variable may have had previously.
 • Maple has several built-in environment variables, with initial values as shown:

 Name Default Value %, %%, %%% The previous three results. _ans Equivalent to % Digits 10 Normalizer The built-in normal procedure. NumericEventHandlers [default,default,default,default,default,default] Order 6 Rounding nearest Testzero proc(x) evalb(Normalizer(x) = 0) end proc UseHardwareFloats deduced index/newtable unassigned mod The built-in modp procedure. printlevel 1

 • A variable with a name beginning with "_Env" defines a non-built-in environment variable. Such names are not active environment variables, in the sense that no space is reserved to save and restore their values, until they are assigned within a procedure.
 • %, %%, and %%% are the results of the last, second last, and third last computation in the current environment. _ans is a synonym for %.
 • Digits is the number of significant digits used for floating-point operations, and is set to 10 initially.
 • Normalizer is set to normal initially, and is used by the kernel in series to normalize leading terms of divisors.
 • NumericEventHandlers controls how numeric events such as numeric overflow are handled. See NumericEventHandler for details.
 • Order represents the order of series calculations performed by Maple. It does not represent the order of the series output. Order is set to 6 initially.
 • Rounding controls the rounding of floating-point results. See Rounding for more details.
 • Testzero is initialized with proc(x) evalb(Normalizer(x) = 0) end proc, which is a relatively trivial test for zero. Testzero is used in the kernel by series, when it needs to determine whether a leading coefficient is zero for division. It is also used by many symbolic commands in the LinearAlgebra package, for example, to determine if a potential pivot is zero.
 • UseHardwareFloats controls whether Maple's hardware or software floating-point computation environment is used to perform floating-point operations when hardware floating-point values are present in an expression. See UseHardwareFloats for more information.
 • index/newtable is used as a validation function during the implicit creation of a new table via an assignment such as T[a] := b where T does not yet refer to a table.
 • mod can be set to modp or mods, and controls which function is called to evaluate the mod operator. It is set to modp initially. See mod for more information.
 • The setting of printlevel causes the display of the results of all statements executed up to the level indicated by printlevel. Initially, printlevel is set to 1. See printlevel for more information.
 • The call anames('environment') returns a sequence of all active environment variables (as listed in the table above), and all global names beginning with _Env, whether or not they are active environment variables yet.
 • The call anames('environment','active') returns a sequence of only active environment variables. Global names beginning with _Env are included only if they are active in the environment of some active procedure. Thus, this call will never return _Env variables unless invoked from within a procedure that has assigned to such a variable, or a procedure called directly or indirectly by such a procedure. Examples

 > t := proc() Digits := Digits + 4; end proc:

During the execution of "t", Digits is increased by 4, and automatically reset on exit from "t".

 > $\mathrm{Digits}$
 ${10}$ (1)
 > $t\left(\right)$
 ${14}$ (2)
 > $\mathrm{Digits}$
 ${10}$ (3)

The following are examples of user-defined environment variables.

 > $\mathrm{_EnvX}≔1$
 ${\mathrm{_EnvX}}{≔}{1}$ (4)
 > $\mathrm{_EnvY}≔2$
 ${\mathrm{_EnvY}}{≔}{2}$ (5)
 > p := proc() _EnvY := 3 end proc:
 > $p\left(\right)$
 ${3}$ (6)
 > $\mathrm{_EnvY}$
 ${2}$ (7)

The first call below returns the _Env names, but the second does not because they are not currently active.

 > $\mathrm{anames}\left('\mathrm{environment}'\right)$
 ${%}{,}{\mathrm{%%}}{,}{\mathrm{%%%}}{,}{\mathrm{Digits}}{,}{\mathrm{Order}}{,}{\mathrm{_EnvX}}{,}{\mathrm{_EnvY}}{,}{\mathrm{_ans}}{,}{\mathrm{mod}}{,}{\mathrm{Normalizer}}{,}{\mathrm{Rounding}}{,}{\mathrm{Testzero}}{,}{\mathrm{index/newtable}}{,}{\mathrm{printlevel}}{,}{\mathrm{NumericEventHandlers}}{,}{\mathrm{UseHardwareFloats}}$ (8)
 > $\mathrm{anames}\left('\mathrm{environment}','\mathrm{active}'\right)$
 ${%}{,}{\mathrm{%%}}{,}{\mathrm{%%%}}{,}{\mathrm{Digits}}{,}{\mathrm{Order}}{,}{\mathrm{_ans}}{,}{\mathrm{mod}}{,}{\mathrm{Normalizer}}{,}{\mathrm{Rounding}}{,}{\mathrm{Testzero}}{,}{\mathrm{index/newtable}}{,}{\mathrm{printlevel}}{,}{\mathrm{NumericEventHandlers}}{,}{\mathrm{UseHardwareFloats}}$ (9)

If called from a procedure, the _Env names that have become active are also returned.

 > p := proc() _EnvY := 4; anames('environment','active') end proc:
 > $p\left(\right)$
 ${%}{,}{\mathrm{%%}}{,}{\mathrm{%%%}}{,}{\mathrm{Digits}}{,}{\mathrm{Order}}{,}{\mathrm{_EnvY}}{,}{\mathrm{_ans}}{,}{\mathrm{mod}}{,}{\mathrm{Normalizer}}{,}{\mathrm{Rounding}}{,}{\mathrm{Testzero}}{,}{\mathrm{index/newtable}}{,}{\mathrm{printlevel}}{,}{\mathrm{NumericEventHandlers}}{,}{\mathrm{UseHardwareFloats}}$ (10)
 > $\mathrm{_EnvY}$
 ${2}$ (11)
 >