algsubs, bug (25.5.01)

Luis Goddyn

For lack of knowlege of a better place to report these things, here is a bug appearing in Maple versions 3, 4, 5, 5.1 and 6.

> algsubs(x=y, 1/x ); 
                                 1/x 
The correct output should be 1/y.

The bug affects expressions containing operands of the form x^k for negative integers k.

I have traced it to the following line in ‘algsubs/expanded‘, which causes it to falsely assert that x^k (k<0) is already in ”expanded form”:

`algsubs/expanded`(1/x,[x]); 
                                true 
 
> print(`algsubs/expanded`); 
proc(f, vars) 
... 
elif type(f, `^`) then 
        evalb(not (has(op(1, f), vars) and type(op(1, f), `+`))) 
...

It is easy but annoying to fix this problem. Does WaterlooMaple make available a patch file of elementary bug fixes such as this? (”elementary” = bugs not associated with the kernel). One could then simply tack it into the .mapleinit file and, VOILA, no need to wait until the next release version... I found not even a report of known bugs at www.maplesoft.com! Could someone please advise me of existing repositories?

Bill Page (28.5.01)

But the online documentation for algsubs (in Maple 5 at least) states specifically:

Note that the requirement for monomials in a to divide monomials in f means that the negative powers of u in the following example are not substituted, and must be handled separately as shown.

 
     > f := a/u^4+b/u^2+c+d*u^2+e*u^4; 
 
                              a      b           2      4 
                       f := ---- + ---- + c + d u  + e u 
                              4      2 
                             u      u 
 
     > algsubs(u^2=v,f); 
                                       2     b      a 
                          d v + c + e v  + ---- + ---- 
                                             2      4 
                                            u      u 
 
     > algsubs(1/u^2=1/v,f); 
                                                     2 
                             4      2   a + v b + c v 
                          e u  + d u  + -------------- 
                                               2 
                                              v

Hence, to substitute for both positive and negative powers

    > algsubs(u^2=v,algsubs(1/u^2=1/v,f)); 
 
                             4      3                2 
                          e v  + d v  + a + v b + c v 
                          ---------------------------- 
                                        2 
                                       v

Helmut Kahovec (31.5.01)

Well, you may do the following:

 
> restart; 
> seq(algsubs(1/x=1/y,1/x^k),k=1..10); 
 
             1     1     1     1     1     1     1     1     1 
       1/y, ----, ----, ----, ----, ----, ----, ----, ----, --- 
              2     3     4     5     6     7     8     9    10 
             y     y     y     y     y     y     y     y    y 
 
> seq(algsubs(1/x=1/y,x^(-k)),k=1..10); 
 
             1     1     1     1     1     1     1     1     1 
       1/y, ----, ----, ----, ----, ----, ----, ----, ----, --- 
              2     3     4     5     6     7     8     9    10 
             y     y     y     y     y     y     y     y    y