Suspicious behaviour of "residue"



Hi everyone,

I've just discovered Maxima a few days ago, and therefore I'm far from being
an experienced user... I have to say Maxima really is fantastic, I just love
it !

However I've come across the following problem, involving residues :

(%i1) set_display('ascii) $
domain : complex $
declare(N, integer) $
H : 1 / (x*(x - x0)*(1 - x^N/y)) $

(%i5) residue(H, x, 0);
                                       y
(%o5)                           - ------------
                                          N
                                  x0 y - x  x0


Why oh why does the residue of H(x) at 0 depend on x ? It actually turns out
that the result is correct, when x is replaced with 0 :

(%i6) subst(x=0, %);
                                       1
(%o6)                                - --
                                       x0

I kind of guess that the problem is related to Maxima being unable to
perform the full partial fraction decomposition, although 0 is a pole of
order 1 (not even a multiple pole) :

(%i7) partfrac(H, x);
                             y                     y
(%o7)             ----------------------- - ----------------
                                    N                  N
                  (x - x0) (x0 y - x  x0)   x (x0 y - x  x0)


There might be something I don't know about Maxima, and the way it solves
problems... It's just a bit disturbing that the residue of H(x) depends on
x... I think this is not something the user might reasonably expect.

At last, a related question / suggestion :

(%i8) declare(k, integer) $
Hk : x^(k-1) / ((x - x0)*(1 - x^N/y)) $

(%i10) residue(Hk, x, 0);

(%o10)                                  0

Here I would have thought Maxima would ask if k is positive or not...

As a matter of fact, the answer is 0 for all positive k, but not for
negative k (including k=0, where the result was found earlier...). Does
Maxima provide "conditional results", with various expressions depending on
the value of a parameter ? I appreciate that Maxima can't do everything, and
that users have to know what they are doing in the first place... But
sometimes it helps to be warned that things are a bit more subtle than they
seem (e.g. someone who looked a bit quickly would have thought that all
residues are 0, including for k<=0).

Funnily enough I've just noticed the following :

(%i17) declare(p, integer) $
       residue(subst(k=+p, Hk), x, 0);
       residue(subst(k=-p, Hk), x, 0);

(%o18)                                 0
                                        y
(%o19)                       - -------------------
                                p         N + p
                               x  x0 y - x      x0

Again, maybe I'm really missing something about how Maxima works, but I
would not expect the result to be different depending on the sign affected
to a parameter (which can be positive or negative itself)...

Many thanks for any comments, and to anyone who can shed some light on
Maxima's philosophy !
David.