Dieter Kaiser | 1 Nov 2009 17:34
Picon

asksign, clearsign, and meval* causes problems

I had again a look at the bug report ID: 626607 "Defint doesn't clean up
asksign db" and I think I have found the underlying problem. It is the
mechanism of asksign itself and meval*, which causes the problem.

First, we confirm the bug in a fresh Maxima session. After we have done
the integration Maxima still knows that n is positive, if we ask with
asksign(n):

(%i2) integrate(x^n,x,1,inf);
Is  n  positive, negative, or zero?
p;
defint: integral is divergent.
 -- an error. To debug this try: debugmode(true);
(%i3) asksign(n);
(%o3) pos

Second, we look at the sign of n with the function sign and not asksign.
Maxima does not know the sign. The fact is not present in the database:

(%i2) integrate(x^n,x,1,inf);
Is  n  positive, negative, or zero?
p;
defint: integral is divergent.
 -- an error. To debug this try: debugmode(true);
(%i3) sign(n);
(%o3) pnz
(%i4) asksign(n);
Is  n  positive, negative, or zero?
p;
(%o4) pos
(Continue reading)

Stavros Macrakis | 1 Nov 2009 17:56
Picon
Favicon
Gravatar

Re: asksign, clearsign, and meval* causes problems

Thanks for fixing this long-standing problem!  It will be interesting to see how many more problems will be fixed in reviewing the 68 uses of meval*.

             -s

On Sun, Nov 1, 2009 at 11:34 AM, Dieter Kaiser <drdieterkaiser <at> web.de> wrote:
I had again a look at the bug report ID: 626607 "Defint doesn't clean up
asksign db" and I think I have found the underlying problem. It is the
mechanism of asksign itself and meval*, which causes the problem.

First, we confirm the bug in a fresh Maxima session. After we have done
the integration Maxima still knows that n is positive, if we ask with
asksign(n):

(%i2) integrate(x^n,x,1,inf);
Is  n  positive, negative, or zero?
p;
defint: integral is divergent.
 -- an error. To debug this try: debugmode(true);
(%i3) asksign(n);
(%o3) pos

Second, we look at the sign of n with the function sign and not asksign.
Maxima does not know the sign. The fact is not present in the database:

(%i2) integrate(x^n,x,1,inf);
Is  n  positive, negative, or zero?
p;
defint: integral is divergent.
 -- an error. To debug this try: debugmode(true);
(%i3) sign(n);
(%o3) pnz
(%i4) asksign(n);
Is  n  positive, negative, or zero?
p;
(%o4) pos

Last, we do first an evaluation after the integration. It does not
matter, what we exactly do, but the information about the sign of n is
lost after every next evaluation:

(%i2) integrate(x^n,x,1,inf);
Is  n  positive, negative, or zero?
p;
defint: integral is divergent.
 -- an error. To debug this try: debugmode(true);
(%i3) 2+2;
(%o3) 4
(%i4) asksign(n);
Is  n  positive, negative, or zero?
p;
(%o4) pos


That is what happens:

1.
ASKSIGN puts its facts in a global variable LOCALES. ASKSIGN uses its
own syntax to store the facts.

2.
The facts in the global variable LOCALES are cleared with the function
CLEARSIGN, which is called from MEVAL* after evaluating an expression.
Therefore, the facts of ASKSIGN are only present during the current
evaluation of an expression.

3.
If the evaluation of an expression does not end normally, e.g. we get a
Maxima error, the facts in LOCALES are not cleared and are still present
in the following evaluation. That is the observation in the reported
bug.


This is what we can do to improve the function meval*:

(defun meval* (test)
 ;; Make sure that clearsign is called.
 (unwind-protect
   (let (refchkl baktrcl checkfactors)
     (if $ratvarswitch (setq varlist (cdr $ratvars)))
     (meval test))
   (clearsign)))

With this code, CLEARSIGN is executed after an Maxima error too. The
reported bug is no longer present:

(%i4) integrate(x^n,x,1,inf);
Is  n  positive, negative, or zero?
p;
defint: integral is divergent.
 -- an error. To debug this try: debugmode(true);
1. Trace: (CLEARSIGN)
1. Trace: CLEARSIGN ==> NIL
(%i5) asksign(n);
Is  n  positive, negative, or zero?

Remark:

meval* is called 68 times in Maxima core and share code. I am in doubt,
that all of this calls are appropriate. meval* should be called only at
the top level evaluation. Because every call of meval* clears the facts
from asksign, we might have some more bugs (See e.g. problems with
redundant questions form asksign).

I have tested the change of meval* and have got no problems with the
test_suite and share_testsuite.

Dieter Kaiser


_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima

_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima
Robert Dodier | 1 Nov 2009 18:30
Picon

Re: solve(x/sqrt(x+2)=1,x)

On 10/29/09, Stavros Macrakis <macrakis <at> alum.mit.edu> wrote:

> 1) When a loadfile changes name, leave a stub behind with the old name that
> prints a warning that the file has been moved, and then loads it from the
> new location.  This is easy to do.

Agreed.

> 2) Include at least a one-line description of all share functions (not
> including contrib) in the main help library, mentioning what file to load
> them from. This requires some labor, but not specialized knowledge.

I wouldn't mind seeing a documentation summary function,
not limited to share functions. E.g. print just the name of a
function and the first line of documentation.
If it isn't built-in, mention what to load as well (not sure how to
detect that automatically).

> 3) Add some specific help functionality to help find share files. This
> requires some programming as well as as more documentation data.

Well, in the html documentation at least, there is a category
for share packages. At present all that is shown is a list of links
(as with all categories); maybe it should show a 1-line summary
as in (2). If the category system is generally useful, maybe we
can somehow adapt it to the "describe" system.

> 4) When a load file is loaded, full documentation should come with it. I
> haven't looked at the help system, so I don't know how hard this would be.

Well, my preference here is that a share package should own its
own documentation (i.e. source code, test script, & documentation
all in the same directory). I figured out a way to get the per-package
Texinfo documentation merged into the general Texinfo index so that
it would be known to "describe".

At that point someone else argued that the Texinfo documentation
for all packages should be in the same place (maxima/doc/info)
and I didn't feel like arguing the point so I gave up. But it would
be easy to resurrect the per-package info stuff.

I think it should be possible to read a package's documentation
without loading the package, by the way.

> 5) Add some easy way to load up-to-date share files from the sourceforge
> server without requiring CVS knowledge.  The R system includes functions to
> install and update packages (and their prerequisites) so you neither have to
> be a systems programmer nor have to reinstall the whole system every time
> one package is updated. This requires real work, especially if it's going to
> be cross-platform.

I think we should just create a simplified CVS client (might or
might not be Lisp). Trying to figure out a separate scheme seems
like a waste of time.

best

Robert Dodier
Robert Dodier | 1 Nov 2009 18:56
Picon

Re: solve(x/sqrt(x+2)=1,x)

On 10/30/09, Raymond Toy <raymond.toy <at> stericsson.com> wrote:

> We need something more simpler.  One way is use mk:defsystem, since we
> use that in many places already and is supported on all of the lisps we
> use.  That helps with the loading, and could help with finding the
> packages since there would be a system file for each package which we
> could find.

Yeah, defsystem would be OK.

Robert Dodier
Robert Dodier | 1 Nov 2009 19:01
Picon

Re: Packages and other user-friendly things (Was Re: solve(x/sqrt(x+2)=1, x))

On 10/30/09, Harald Geyer <harald <at> lefant.net> wrote:

> We did discuss this for user supplied packages a few month ago
> and most people seemed to agree that a forum, where users can download
> add-on packages, would be enough. So maybe some webpage where users can
> download share packages to drop into $HOME/.maxima/ is enough as well?

Well, a user-supplied package forum is helpful, but it doesn't
cover built-in packages, right? It would also be helpful to be able
to get current revisions of built-in packages, and for this we
should figure out something talk to CVS, maybe defsystem or
whatever, I'm no expert.

best

Robert Dodier
Robert Dodier | 1 Nov 2009 19:05
Picon

Re: Packages and other user-friendly things (Was Re: solve(x/sqrt(x+2)=1, x))

On 10/29/09, Raymond Toy <toy.raymond <at> gmail.com> wrote:

> If we follow what emacs/xemacs does with info files, we can probably do
> 2 and 3.  Item 4 seems a bit harder, but probably because I don't know
> how the documentation stuff works anymore.  (It used to be straight info
> files, but they're not anymore.)

The built-in documentation is still just .info generated from Texinfo.
There is a script which is executed by make to build an index
so that the blob of text for any given topic can be loaded without
searching for it. Bringing additional files into the help system just
means appending additional items to the index.

FWIW

Robert Dodier
Robert Dodier | 1 Nov 2009 19:13
Picon

new developer Leo Butler

Hello,

I've taken the liberty of adding Leo Butler (l_butler) to the
list of developers, as he seems to be level-headed and
competent.

Leo, for a while anyway, I would like to ask you to give
a heads-up on the mailing list before committing stuff.
Let's take this opportunity to help Leo contribute better
to Maxima. Leo, don't take it personally if someone is
opposed to stuff you want to do.

best

Robert Dodier
Robert Dodier | 1 Nov 2009 19:33
Picon

Maxima 5.20 release branch planned for Dec 1

Hello,

I'm planning to make a branch for the Maxima 5.20 release on Dec 1,
with a stable release a few weeks after that.
So if you developers want to get something into the next release,
now is the time to do it.

best

Robert Dodier
Robert Dodier | 1 Nov 2009 19:36
Picon

Re: abs/cabs

On 10/31/09, Dieter Kaiser <drdieterkaiser <at> web.de> wrote:

> The abs function is a simplifying function, which calls cabs, when the
> argument seems to be complex. That is not perfectly implemented. More
> work can be done.
>
> The cabs function is a verb function, which assumes a complex argument.
> Therefore the argument is always split into a real and imaginary part.

Hmm. Does this suggest that cabs should be hidden from the user,
and only called from abs as necessary?

I've often wondered about abs vs cabs myself ....

best

Robert Dodier
Harald Geyer | 1 Nov 2009 19:49
Favicon

Re: Packages and other user-friendly things (Was Re: solve(x/sqrt(x+2)=1, x))

> > We did discuss this for user supplied packages a few month ago
> > and most people seemed to agree that a forum, where users can download
> > add-on packages, would be enough. So maybe some webpage where users can
> > download share packages to drop into $HOME/.maxima/ is enough as well?
> 
> Well, a user-supplied package forum is helpful, but it doesn't
> cover built-in packages, right? 

Sure. All I wanted to say is: Perhaps we don't need to integrate such
a tool with maxima. Just setting up some webpage that gets the files
from CVS might be enough.

Of couse we would still need some way to specify which files belong
to which package.

> It would also be helpful to be able
> to get current revisions of built-in packages, and for this we
> should figure out something talk to CVS, maybe defsystem or
> whatever, I'm no expert.
> 
> best
> 
> Robert Dodier
> _______________________________________________
> Maxima mailing list
> Maxima <at> math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima

Gmane