andre maute | 8 Sep 10:06

sloane's integer sequences and maxima

wouldn't it be nice to optionally ship a version
of sloane's integer sequences with maxima?

see url:
http://www.research.att.com/~njas/sequences/Seis.html

and have a function ala

identify_integer_sequence([a1,a2,a3,...] )

which gives some information of similar sequences.

I'm working most the time offline,
and that would be a cool feature for maxima,

The sequences are available in two gzip archives (12 megs).

Andre
John Lapeyre | 8 Sep 05:37

endcons

I think the Maxima manual should mention somewhere to be
careful about using endcons, because it makes a copy of the
list, rather than cons which doesn't make a copy. If
possible you should either build the list in the reverse
order or make a final call to reverse. This is certainly
common knowledge to lisp programmers and Maxima developers.

When building a very large list, I find the factor in speed is
orders of magnitude.

I searched 1) The Maxima manual 2) The Maxima Book,
3) the list archives since 2000.

Altogether, there are two references to the issue. I
was clued by this single oblique reference in the book:

 endcons(elem,list) returns an (unshared) list where ...

The second reference is in a post from Jaime Villate 2007.

Thanks,
John
Richard Hennessy | 7 Sep 18:23

Error comparing strings

(%i1) is("John">"Barry");
Maxima encountered a Lisp error: Error in PROGN [or a callee]: 
Caught fatal error [memory may be damaged]
Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.

(%i2) build_info()$
Maxima version: 5.16.3
Maxima build date: 22:48 8/24/2008
host type: i686-pc-mingw32lisp-implementation-type: GNU Common Lisp (GCL)
lisp-implementation-version: GCL 2.6.8

Is this a bug or is it illegal to try to compare strings this way?

Rich
Stavros Macrakis | 7 Sep 17:49

reverse and nreverse in nset performance review

Andreas,

In reviewing the performance of the set functions, I noticed that there was a call to "reverse" in do-merge-asym where an "nreverse" would make more sense.  I wrote this code, so I was embarrassed to see this elementary oversight.  But then I checked the revision log of nset, and discovered that it was you who had made this change in nset.lisp 1.20 -> 1.21 (March 2007). Barton had also pointed this out to me last year, but I wasn't focussed on nset at the time.

Nreverse is of course a destructive operation and reverse is a non-destructive (copy) operation, so nreverse is suitable when it is known that a list structure is unshared (e.g. (nreverse (mapcar ...))) while reverse is suitable when a list structure may be shared. Nreverse has the advantage of not cons'ing new list structure unnecessarily and in most implementations should be much faster than reverse.(*)

I had used nreverse in do-merge-asym because the list structure here is supposed to be guaranteed to be unshared.  I assume you changed it to reverse in the belief that there are cases where it might be shared. If that is true, then there is a bug in do-merge-asym which should be corrected at the source, not symptomatically.  If it is not true, the only effect will be to increase the amount of cons'ing, which is generally considered a bad thing. WHich is it?

Thanks,

            -s

(*) In some implementations, like the old Lisp Machine Zetalisp, nreverse may actually be less efficient because of special data representations for linear lists.  Do any current Lisp implementations have such a property?

_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima
megha patnaik | 7 Sep 10:21

Evaluation in maxima-mode

I'm running maxima-mode in emacs to create latex output, but controls such as C-c C-u c don't work for me. My file looks like this:

\documentclass{article}
\usepackage{emaxima}

\begin{document}
\begin{maxima}
  integrate(1/x,x);
\end{maxima}

\end{document}

When I run a pdflatex, the output looks like maxima. Inside emacs, though, I can't evaluate the cells.
My .emacs includes the following:

(setq auto-mode-alist (cons '("\\.max" . maxima-mode) auto-mode-alist))
(setq load-path (cons  "/usr/share/maxima/5.9.0/emacs" load-path ))
(autoload 'maxima "maxima" "Running Maxima interactively" t)
(autoload 'maxima-mode "maxima" "Maxima editing mode" t)\

What am I doing wrong? The other C-c 's do work, just the maxima ones don't.

_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima
John Lapeyre | 7 Sep 00:11

tar compfile compile_file

If a file myarch.tar.gz exists and at the shell I
accidentally type

 tar czf myarch.tar.gz,

then I get
 tar: Cowardly refusing to create an empty archive,

which is good behavior.

If a file of Maxima functions myfuncs.mac exists and I type

compile_file("myfuncs.mac");

then the functions are compiled and loaded into my session.

But if instead, I type

compfile("myfuncs.mac");

then myfuncs.mac is overwritten by a file of length zero,
which makes a poor choice in naming functions much worse.

I suppose it wouldn't break any existing code to change the
behavior of compfile to be more like that of tar.

Below is a one-line patch for instance.  I haven't tried to
build or test Maxima, but I did try the modified function.

----------------------------------------------------------
--- src/transs.lisp	2008-08-14 22:47:37.000000000 -0700
+++ src/transs.lisp	2008-09-06 14:50:13.000000000 -0700
@@ -89,6 +89,7 @@

 (defmspec $compfile (forms)
     (setq forms (cdr forms))
+    (if (eq 1 (length forms)) (merror "bravely refusing to write file of 
length 0"))   
     (bind-transl-state
      (setq $transcompile t
 	   *in-compfile* t)
----------------------------------------------------------
Jussi Eloranta | 6 Sep 07:49

reading a string from keyboard

Hi,

I just recently noticed that readline(true) (or readline(false)) no 
longer reads a string from the keyboard (stdin). It used to work before 
5.15 - probably this was not the correct way of doing it but couldn't 
figure out anything else at that time. Note that I want to read a string 
- not expression. This string can be, for example, a path name which is 
not a valid expression obviously.

After testing a bit, I found out that the following seems to work now:

readline(?\*standard\-input\*)

where the stream refers to the corresponding lisp stream name that 
points to standard input. This also works well with wxmaxima (which 
communicates via pipes I suppose). Is this the right way of doing this? 
Meaning that is it standard enough that it should work with future 
maxima releases as well.

It might be a good idea to include the pre-existing stream names that 
are accessible in maxima in the manual - the previous one was
not trivial to figure out.

Jussi Eloranta
Cal State Northridge
John Lapeyre | 6 Sep 04:50

compiling and undefined variables

Here I compile two functions
(the source is given below)

(%i2) compile(integerdigits,fromdigits);

Warning-> block is an undefined global variable.
Warning-> m is an undefined global variable.
Warning-> diff is an undefined global variable.
Warning-> b is an undefined global variable.
Warning-> r is an undefined global variable.
Warning-> pad is an undefined global variable.
Warning-> i is an undefined global variable.
Warning-> s is an undefined global variable.

I wonder why these warnings appear ?
The functions still seem to work, but I haven't
tested them thoroughly.

------code

/*
   integerdigit(n) returns list of digits in integer n
   integerdigits(n,b) returned digits are in base b
   integerdigits(n,b,pad) leading zeros appended so list
            is of total length pad.
   for base greater than 10, additional digits are denoted in decimal,
   not using A,B, etc.
*/
integerdigits(n,[ib]) := (block[m,r:[],b:10,pad:0,diff],
   n : abs(n),
   if length(ib)>0 then b:ib[1],
   if length(ib)>1 then pad:ib[2],
   while n > 0 do (
    m : floor(n/b),
    r:cons( n-m*b, r),
    n:m),
   diff : pad-length(r),
   if diff > 0 then r:append(create_list(0,i,1,diff),r),
  r);

/* fromdigits(v) return integer computed from list of digits v
   fromdigits(v,b) digits are interpreted base b
*/
fromdigits(v,[ib]) := (block[s:0,b:10,i,m],
  if length(ib)>0 then b:ib[1],
  m:length(v),
  for i thru m do
      s : s + v[m-i+1]*b^(i-1),
      s);
Alasdair McAndrew | 6 Sep 01:38

Printing without linefeed?

I'm running a long program, and every now and then I'd like to print something, just as an indicator of how much it's done.  The "print" command gives me a linefeed, which I don't want.  The lisp command "?write" might work, if I could work out how to include a space as well; ?write(i," ") doesn't work.  Also, I don't seem to be able to use ?write in a program.  Are there other options?

Thanks,
Alasdair

--
Blog: http://amca01.wordpress.com
_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima
Edwin Woollett | 6 Sep 00:56

integrate adds "ind" to correct answer

A standard technique to get definite integrals
is to differentiate a known integral with respect
to a parameter.

This technique is used first to generate the
correct answer:

(%i1) display2d : false$
(%i2) assume( a > 0, w > 0 )$
(%i3) i1 : 'integrate( exp( -a*x)*cos( w*x ), x , 0 , inf )$
(%i4) i2 : ev(i1, nouns);
(%o4) a/(w^2 + a^2)
(%i5) di2 : ( diff(i2, a),  ratsimp(%%) );
(%o5) (w^2 - a^2)/(w^4 + 2*a^2*w^2 + a^4)
(%i6) eqn : (-1)*(diff( i1, a)  =  di2 );
(%o6) 'integrate( x*%e^-(a*x)*cos( w*x), x, 0, inf)
        = -(w^2 - a^2)/(w^4 + 2*a^2*w^2 + a^4)

but direct use of integrate adds "ind" to the
correct answer.

(%i7) integrate(x*exp(-a*x)*cos( w*x), x, 0, inf);
(%o7) ind  -  (w^2 - a^2)/(w^4 + 2*a^2*w^2 + a^4)

Is this a bug?

Ted Woollett
Dieter Kaiser | 5 Sep 23:56

Implementation of Gamma functions

I have started to implement support for the Incomplete Gamma function. Maxima
only knows the symbols gammaincomplete and gammagreek.

I have already finished the routines for the numerical evaluation of the
Incomplete Gamma function for Float, Complex float and Bigfloat. Now I am
working on the routines for Complex Bigfloats. I have used again an expansion in
a series or continued fractions for the Regularized Incomplete Gamma function. 

In principle it is not necessary to implemenent a new algorithm. We can use the
routines for the Exponential Integral E because gamma(a,z) =
z^a*expintegral_e(1-a,z). But it is interessting to see that both algorithm
converge to every desired accurracy and give correct and equivalent results.

Because the different Gamma functions are interconnected it would be possible to
implement the following functions:

Incomplete Gamma function (The upper tail of the Gamma Incomplete function.)
Complement of the Incomplete Gamma function
Generalized Incomplete Gamma function
Regularized Incomplete Gamma function
Generalized Regularized Incomplete Gamma function

Perhaps the names could be:

gamma_incomplete(a,z)
gamma_greek(a,z)
gen_gamma_incomplete(a,z1,z2)
reg_gamma_incomplete(a,z)
gen_reg_gamma_incomplete(a,z1,z2)

Or we could use names like

gamma_incomplete(a,z)
gamma_greek(a,z)                 = 1 - gamma_incomplete(a,z)
gamma_incomplete_gen(a,z1,z2)    = gamma_incomplete(a,z1)-gamma_incomplete(a,z2)
gamma_incomplete_reg(a,z)        = gamma_incomplete(a,z)/gamma(a)
gamma_incomplete_gen_reg(a,z1,z2)= gamma_incomplete_gen(a,z1,z2)/gamma(a)

The second scheme has the advantage that the main name is always at the
beginning. You can see that in principle the Gamma function and the Incomplete
Gamma function are sufficient because they have simple interconnections to the
other functions.

Perhaps more interessting would be to implement a Log Gamma function and the
Inverse Gamma functions.

Dieter Kaiser

Gmane