alias problem (25.1.99)

Roberto A Sussman

The command alias in Release 5 and 5.1 fails to alias second (or greater) order derivatives. Consider the following instructions

> alias(F=F(x)); 
> alias(Fx=diff(F(x),x));

These I copied from the examples in the help file of alias. Everything is OK up to this point, if you key in

> diff(F,x);

you get ”Fx”, as stipulated by the alias. However, as you key in the following alias instruction

> alias(Fxx=diff(F(x),x,x));

you get the right output (I,F,Fx,Fxx), but it does not work: the second derivative is not aliased since the call

> diff(F,x,x);

does not produce ”Fxx” as in the first order derivative. This does not happen in Release 4 and 3 (the aliasing works fine), but it happens in R5. I am using R5 and R5.1, mac and windows versions (the hardware is irrelevant).

Is this a bug? or am I missing some very special Maple-related subtlety?

For those interested, I extended the alias command to a ”difalias” procedure that includes aliasing of partial derivatives up to 3rd order. The derivatives appear as subindices and can be differentiated with diff and manipulated as indexed names.

This utility is very helpful for manipulating large expressions containing partial derivatives (or ordinary ones). The difalias code has been already incorporated into the tensor manipulator grtensor, though, they removed the zero order aliasing, which in my opinion defeats the purpose of this utility. I also did an unaliasing procedure.

However, as I was porting these simple procedures from R4 to R5, I noticed the (possible) bug I am reporting, and so difalias only aliases first derivatives in R5.

Those interested in getting the code or binaries of difalias and undifalias, please send me a note to

sussman@nuclecu.unam.mx

I will also place the material soon in my web page http://www.nuclecu.unam.mx/~sussman for downloading

Willard, Daniel, Dr.(3.2.99)

From the Help file on alias I quote: ”This means that you cannot define one alias in terms of another. ” I suspect this is your problem.

Try:

alias(Fx=diff(F(x),x)); 
alias(Fxx=diff(F(x),x$2)); 
alias(Fxxx=diff(F(x),x$3));

this seems to work ad lib:

diff(Fxxxx,x$3)=diff(F(x),x$7): etc.

Joe Riel (4.2.99

Roberto Sussman asks why alias doesn’t work properly in R5 with second or higher order derivatives. The problem lies in the ‘print/diff‘ procedure, which is new for R5. In order to avoid an ugly display, ‘print/diff‘ combines repeated terms in a derivative. To see this, erase the ‘print/diff‘ procedure and see what happens.

> restart; 
> interface(prettyprint=0); 
> diff(f(x,y),x,x); 
diff(f(x,y),`$`(x,2)) 
`print/diff` := NULL: 
> diff(f(x,y),x,x); 
diff(diff(f(x,y),x),x)

Note that with ‘print/diff‘ erased, aliasing works correctly. The output of second and higher order differentials, however, is very ugly.

Because the print alias mechanism operates on the output of a print procedure, you can get aliasing to work by properly aliasing to the output of print.

The following procedure simplifies the process

aliasdiff := proc(eq) 
local fx,dfx; 
option `Copyright (c) 1999 by Joseph Riel. All rights reserved.`; 
    if nargs > 1 then RETURN(map(procname,[args])[]) fi; 
    fx,dfx := op(eq); 
    fx = subs(diff=''diff'',`$`=''`$`'',readlib(`print/diff`)(op(dfx))); 
    alias(%); 
    fx 
end:

For example,

alias(f = f(x,y)): 
aliasdiff(fx=diff(f,x), fxx=diff(f,x,x), 
          fy=diff(f,y), fyy=diff(f,y,y), fxy=diff(f,x,y)): 
\begin{Verbatim} 
 
Note that aliasdiff, unlike alias, allows you to define aliases 
in terms of previously defined aliases. 
 
\begin{Verbatim} 
> f = f(x,y); 
 
                             f = f(x, y) 
> diff(%,x); 
                                d 
                           fx = -- f(x, y) 
                                dx 
> diff(%,y); 
                                 2 
                                d 
                         fxy = ----- f(x, y) 
                               dy dx