Question: Unprotect This, Unprotect That

Maple has a number of protected names that cannot be redefined without some work.

A common request is to use the letter j or J instead of the default I for the imaginary unit. Also common is to be able to use the letter I as an ordinary variable, rather than as an imaginary unit. For this, there is a very convenient interface command.


restart;

(-1)^(1/2);

I

interface(imaginaryunit=J):
(-1)^(1/2);
 
 J

(There is an odd feature to this though: if you copy-paste the above from your Maple worksheet, the Maple output J, which properly displays as a J in the Maple interface, is pasted as an I, so in the above I had to change the I to a J to represent what I can see in the Maple window)

Also very common is a request to "remove" Pi or gamma from the list of Maple constants, so that the symbols may be used as ordinary variables. (even more common is the confusion between pi and Pi: the former is unprotected and unassigned, while the latter is protected and assigned as the well-known 3.141592,etc.)

I don't think it's a good idea to redefine I or Pi, because they show up even when you don't expect them to, whenever you have imaginary numbers, or trigonometric expressions.

But I do want my gamma back. I thought it would be easy. What am I doing wrong?

Thanks!


restart;

# Unprotect gamma so it may be used as a normal variable

# display list of Maple protected constants
constants;
false, gamma, infinity, true, Catalan, FAIL, Pi

# check that gamma is indeed protected
type(gamma,protected);
true

# remove gamma from the list of protected constants and unprotect it
constants:= op(subs(gamma=NULL,[constants])); # this step does not seem to be needed
false, infinity, true, Catalan, FAIL, Pi

unprotect(gamma);

# check that gamma is indeed unprotected
type(gamma,protected);
false

constants; # gamma automatically removed from list of constants
false, infinity, true, Catalan, FAIL, Pi

# Unassign gamma for use as an ordinary variable
unassign('gamma');
evalf(gamma); # failed to unassign unprotected gamma

0.5772156649

# Unassign gamma with another approach, based on the idea that x:=x: 'clears' x from memory
gamma := gamma;
evalf(gamma); # failed to unassign unprotected gamma


# Try to unassign some unprotected constant
restart:
amma := 0;
unassign('amma');
evalf(amma); # succeeds with amma where it failed with gamma

0
amma

# Try to unassign an unprotected constant with x:=x;
restart:
amma := 0;
amma := amma;
evalf(amma); # fails to unassign amma, maybe I remember wrongly about x:=x; 

0
0
0.

Please Wait...