Recently I was presented with some code that had a seq command that used i as the index variable. While this code had been used in a number of applicaitons, it was now giving trouble.

seq( i^2, i=1..10 );
Error, illegal use of an object as a name

After a stroke of fortune it was discovered that the problem was that Maple's imaginary unit had been changed from I to i. Given that this change was made, the error message now made sense.

interface(imaginaryunit);

                               I

But, why, when, how, and by whom had imaginaryunit been changed?

There was nothing fancy in the code. I discovered that imaginaryunit changed sometime during an assignment to the name Calculator.

restart;
interface(imaginaryunit);
                               I
Calculator := 1;
                               1
interface(imaginaryunit);
                               i
seq( i^2, i=1..10 );
Error, illegal use of an object as a name

Still, how does an assignment to a name cause a change to imaginaryunit?

Well, it turns out that Calculator is the name of the Maple module that is used in Maple's Calculator application. When this module is accessed, which it apparently is when the assignment is made.

restart;
print(Calculator);
module ()
description "a package for the Maplesoft graphing calculator";
local EvaluateMain, TabulateMain, SolveInequalMain, DefineSequenceMain,
   EnvDegrees, EnvComplex, EnvPolarCoords, CheckMapDim,
   ClearVars, CleanFloat, IsTable, MakeInt, 
   MakeMx, MakeVec, ToGlobalFn, ToLocalFn, UndefHandler, 
   VerifyFnUse, ToFraction0, _x, LocalFns, GlobalFns, Error; 
   export ModuleLoad, SetEnv, Evaluate, Tabulate, SolveInequal, 
   DefineSequence, `+`, `*`, `^`, factorial, ToPolar, 
   ToRectangular, GenericFn, TrigFn, ArctrigFn, abs, signum, 
   round, trunc, frac, floor, ceil, argument, conjugate, Re, 
   Im, exp, ln, log10, sqrt, sin, cos, tan, csc, sec, cot, 
   arcsin, arccos, arctan, arccsc, arcsec, arccot, sinh, cosh, 
   tanh, csch, sech, coth, arcsinh, arccosh, arctanh, arccsch, 
   arcsech, arccoth, Calculus, List, Mx, Pbty, Stats; option 
   package, `Copyright (c) Maplesoft, a division of Waterloo 
   Maple Inc. 2005`;
end module
showstat(Calculator:-ModuleLoad,4);
Calculator:-ModuleLoad := proc()
local factorial1;
       ...
   4   interface(('imaginaryunit') = ('i'));
       ...end proc

We can argue whether this is appropriately documented within Maple. I would have thought (expected) Maple to complain - if not refuse - to overwrite the name Calculator. I hope this improvement can be added quickly.

Thank you for listening,

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Please Wait...