[Daniel Sullivan <daniels@mdo.net>] Bug#99447: maxima: Summation command displays incorrectly



I list four responses grouped together, so that I dont flood you
with too much mail...   But given the length of this message maybe you
prefer separate ones!!

I.  Camm:

   Error maxima output of not centered... 
   (C2) sum(n^2,n,1,n);
...
I have added a correction in cvs to displa.lisp.   This bug was introduced when I
added the stuff for allowing sums over lists, and the integration of f/g
with g irreducible, by making it a sum over the roots of...  

===================

II.  Fateman writes:

   I suggest: 

      ListMatrixEntries (M):=  apply (append, substinpart("[",M,0))$

   in lisp,
     (defun $LIST_MATRIX_ENTRIES (m)... (apply #'append (cdr v))  instead
   of sloop...

I put the version using 'sloop' in the sources because I think it is
more readable, and I KNOW it is efficient in every lisp, not creating
any more cons's than absolutely necessary.   For example if you do
5000 iterations of doing list_matrix_entries of a 7 7 matrix.


  Cons's    Seconds     Method
  250,000    1.27       sloop method                    
  320,000    1.65       apply '$append
3,600,000   42.0        apply (append, substinpart("[",M,0))$  

I guess I am very sensitive to storage use and timings .. and I probably 
go a little overboard on making things efficient.    But I do think the sloop

   (sloop for row in (cdr matrix) append (cdr row))
  "for each row  in matrix append the row"
is pretty readable.   Of course I wrote the sloop macro, so thats probably
why I think it is readable, but it is also why I am sure it is efficient.

The lisp version you suggest:
  (defun $LIST_MATRIX_ENTRIES1 (m)
    (or ($matrixp m) (error "not a matrix"))
    (apply #'append (cdr m)))

needs to use '$append since the rows are maxima lists not lisp lists.
Note the timings were done on a slow notebook (166Mhz) here in St Petersburg
russia, and so may appear high.    Functions were compiled, and I used gcl's
gc monitor.  

==========================
III.

   You might prefer this version of gcdex, though it takes
   an additional argument, the main variable..., it does
   not require that expressions be univariate.

   gcdex1(m,n,x):=

Thank you yes we should handle the case where coefficients are in some rational
function field.  
Normally when we speak about gcd of elements in k[x,y] we mean in the 
polynomial ring in two variables, where of course ideals cannot be
generated by one element .. their gcd.

x k[x,y] + y k[x,y]  != 1 k[x,y]

But if we look at the field of fractions k(y) and then adjoin x, then
of course that ring k(y)[x] is a Principal ideal domain (indeed a euclidean
domain), and we can use the euclidean algorithm and produce elements which
will be fractions in y but polynomials in x.    I have modified share/gcdex.mc
to allow an optional argument specifying a main variable.   Just remember the
gcd is not the usual multivariate gcd!

gcdex(x*(y+1),y^2-1,x);

				      1
(D1)    		        [0, ------, 1]
				     2
				    y  - 1

saying the 'gcd' is 1, since that is what it is in k(y)[x],
however it would be of course y+1 if we were just thinking in k[x,y].

Note that I did not actually get the code you sent to work correctly.
I added SUBSCRMAP:true to the binds, so that the list assignments would be ok,
but still it gave incorrect answers:
(C17) gcdex1(x^3+2,x^3+1,x);

			     3	     3	     3
(D17)/R/ 		   [x  + 1, x  + 1, x  + 1]

but anyway I am sure knuth's algorithm is correct and there is just a typo somewhere..
but I dont have the book with me and so can't verify it, and once I have one
working it is hard to go back and trouble shoot another!


===============

IV.

   Billinghurst, David (CRTS)" <David.Billinghurst@riotinto.com>

   cvs update -d
   cvs server: Updating .
   cvs server: failed to create lock directory in repository
   `/home/cvs/gcl/gcl/gmp': Permission denied

I have corrected the cvs/gcl permissions which seem to become incorrect each
time I add a new cvs directory (or maybe even file...)  We need a cron job
or a fixed cvs add ... 

william