Subject: [clisp-list] clisp and gclisp give different answer for the same problem, not related to texmacs/maxima interface

From: Javed Alam <[email-masked]>
Date: Fri Sep 19 12:49:04 2003

David

Thanks for the tips both of the approaches suggested by you worked in 
getting
maxima{compiled with clisp}  shell to open up in texmacs 
{winxp/win200/cygwin/}. However, that is not the end
of my problems. I tried to solve this 2nd order differential equation 
and end up with
a wrong answer because if I try doing the same with maxima compiled with 
GCL I get the
right answer. Did some body else had the same problem?

$ maxima
  i i i i i i i       ooooo    o        ooooooo   ooooo   ooooo
  I I I I I I I      8     8   8           8     8     o  8    8
  I  \ `+' /  I      8         8           8     8        8    8
   \  `-+-'  /       8         8           8      ooooo   8oooo
    `-__|__-'        8         8           8           8  8
        |            8     o   8           8     o     8  8
  ------+------       ooooo    8oooooo  ooo8ooo   ooooo   8

Copyright (c) Bruno Haible, Michael Stoll 1992, 1993
Copyright (c) Bruno Haible, Marcus Daniels 1994-1997
Copyright (c) Bruno Haible, Pierpaolo Bernardi, Sam Steingold 1998
Copyright (c) Bruno Haible, Sam Steingold 1999-2003

Maxima 5.9.0 http://maxima.sourceforge.net
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
This is a development version of Maxima. The function bug_report()
provides bug reporting information.
;; Loading file /usr/local/share/maxima/5.9.0/share/maxima-init.lisp ...
;; Loaded file /usr/local/share/maxima/5.9.0/share/maxima-init.lisp
(C1) 'diff(x,t,2) + a*x = b*sin(c*t);
                             2
                            d x
(D1)                        --- + a x = b SIN(c t)
                              2
                            dt
(C2) ode2(d1,x,t);
Is  a  positive, negative, or zero?

positive;
                          /
                          [
(D2) x = b SIN(SQRT(a) t) I (SIN(c t + SQRT(a) t) + SIN(c t - SQRT(a) t))
                          ]
1. Break [1]>

                    d
/(2 COS(SQRT(a) t) (-- (SIN(SQRT(a) t)))
                    dt

                     d
 - 2 SIN(SQRT(a) t) (-- (COS(SQRT(a) t)))) dt
                     dt

                    /
                    [
 + b COS(SQRT(a) t) I (COS(c t + SQRT(a) t) - COS(c t - SQRT(a) t))
                    ]
                    /

                    d
/(2 COS(SQRT(a) t) (-- (SIN(SQRT(a) t)))
                    dt

                     d
 - 2 SIN(SQRT(a) t) (-- (COS(SQRT(a) t)))) dt + %K1 SIN(SQRT(a) t)
                     dt

 + %K2 COS(SQRT(a) t)

Same solution using maxima compiled under gclisp

C:\Program Files\Maxima-5.9.0\lib\maxima\5.9.0\binary-gcl>maxima -eval
n)
GCL (GNU Common Lisp)  Version(2.5.0) Thu Jan 30 02:37:51 CST 2003
Licensed under GNU Library General Public License
Contains Enhancements by W. Schelter

Use (help) to get some basic information on how to use GCL.
Maxima 5.9.0 http://maxima.sourceforge.net
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
This is a development version of Maxima. The function bug_report()
provides bug reporting information.
                 
(C3) 'diff(x,t,2) + a*x= b*sin(c*t);

                             2
                            d x
(D3)                        --- + a x = b SIN(C t)
                              2
                            dt
(C4) ode2(d3,x,t);

Is  a  positive, negative, or zero?

positive;
                b SIN(C t)
(D4)      x = - ---------- + %K1 SIN(SQRT(a) t) + %K2 COS(SQRT(a) t)
                   2
                  C  - a
(C5)

The two solutions are totally different. This has to do with the CLISP 
and GCLISP compilers. Any help or suggestions in this regard
will be highly appreciated.

regards

javed

Billinghurst, David (CALCRTS) wrote:

>>From: Billinghurst, David (CALCRTS) 
>>
>>    
>>
>>>From: Javed Alam
>>>Sent: Saturday, 13 September 2003 12:02 AM
>>>
>>>I have been trying to run texmacs-1.0.1.21 with maxima-5.9.0 under 
>>>cygwin on a win/xp and win/2000 system.
>>>
>>>[...]
>>>
>>>I get the following error.
>>>
>>>[...]
>>>
>>>Fatal error: bad url in 'complete'
>>>See file   : url.cpp
>>>      
>>>
>>See if https://savannah.gnu.org/bugs/?func=detailbug&group_id=156&bug_id=4241
>>helps.  It suggests hard coding a file location. I will have a look 
>>myself over weekend.
>>    
>>
>
>Alternatively:
>http://www.mail-archive.com/[email-masked]/msg09820.html
>indicates that the problem is related to locate/updatedb.  
>
>When "locate toc_maxima.html" finds the file then texmacs will run maxima.  
>However, I have some unresolved issues on cygwin:
> - the machine that used to work now doesn't, 
> - the one that didn't now does after doing an updatedb
> - updatedb is giving me some grief.
>
>
>  
>

-- 

*Javed Alam, *Ph.D.

*Professor*

*Civil/Environmental/Chemical Engineering Department*

Youngstown State University

Youngstown, Ohio 44555

Phone 330-941-3029

Fax     330-941-3265

e-mail [email-masked] <mailto:[email-masked]>

web: http://www.eng.ysu.edu/~jalam/ <http://www.eng.ysu.edu/%7Ejalam/>

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

"Knowledge will forever govern ignorance, and a people who mean to be 
their own governors, must arm themselves with the power knowledge gives. 
A popular government without popular information or the means of 
acquiring it, is but a prologue to a farce or a tragedy or perhaps both."
  - James Madison /(Fourth President of the United States)/ 
<http://opengov1.media.mit.edu/>

"Facts are stupid things..."
  - Ronald Reagan /(40th President of the United States)/ 
<http://opengov1.media.mit.edu/>

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

---

From: Richard Fateman <[email-masked]>
Date: Fri Sep 19 14:05:10 2003

Usually the way to tell if something is a compiler bug is
to find load the corresponding non-compiled file and run
the program again.  Then try the program again but load
only one definition from the file and see if it fixes it.

Which one file, which one definition... that's tricky to
determine.

Another way, if you have 2 different behaviors, is to
trace all the programs that you think might matter, and look
at the two traces. (output the trace info to text files...)

Good luck.

RJF

Javed Alam wrote:

> a wrong answer because if I try doing the same with maxima compiled 
> with GCL I get the
>>> See if 
>>> https://savannah.gnu.org/bugs/?func=detailbug&group_id=156&bug_id=4241
>> When "locate toc_maxima.html" finds the file then texmacs will run 
>> maxima.  However, I have some unresolved issues on cygwin:
>> - the machine that used to work now doesn't, - the one that didn't 
>> now does after doing an updatedb

---

From: Javed Alam <[email-masked]>
Date: Fri Sep 19 15:20:10 2003

Hi

I ran the  maxima versions(5.9.0) compiled with clisp(2.31) and 
gclisp(2.5.0) for exact same problems. The build_info for both is included.
OS ENVIRONMENT: CYGWIN under WINXP
CYGWIN { 2003/08/31 12:05:44 Starting cygwin install, version 2.340.2.5 }

Here is what I am getting as output:

MAXIMA version compiled with the clisp  runs most of the problems but 
fails to produce results for

1. problems involving differentiation of functions
2. 2nd order non-homogeneous ordinary differential equations. It works 
ok for 2nd order homogenous ordinary equations.

Other than this everything else seems to work including plot2d and 
plot3d functions.

I am including the screen output from both runs :

CLISP run

jalam@JOVE4 ~
$ maxima

(C1) build_info;
(D1)                              BUILD_INFO
(C2) build_info();

Maxima version: 5.9.0
Maxima build date: 6:33 9/12/2003
host type: i686-pc-cygwin
lisp-implementation-type: CLISP
lisp-implementation-version: 2.31 (released 2003-09-01) (built 
3272325060) (memo
ry 3272351601)

(D2)
(C3) 2 + 2;
(D3)                                   4
(C4) integrate(x^2,x);
                                       3
                                      x
(D4)                                  --
                                      3
(C5) integrate(x^3,x,0,1);
                                       1
(D5)                                   -
                                       4
(C6) 'diff(x,t,2)=0;
                                     2
                                    d x
(D6)                                --- = 0
                                      2
                                    dt
(C7) ode2(d6,x,t);
(D7)                            x = %K2 t + %K1
(C8) 'diff(x,t,2) + a*'diff(x,t) + b*x=0;
                              2
                             d x     dx
(D8)                         --- + a -- + b x = 0
                               2     dt
                             dt
(C9) ode2(d8,x,t);
           2
Is  4 b - a   positive, negative, or zero?

positive;
              a t
            - ---                      2                           2
               2           SQRT(4 b - a ) t            SQRT(4 b - a ) t
(D9)  x = %E      (%K1 SIN(----------------) + %K2 COS(----------------))
                                  2                           2
(C10) solve(x^2 -3*x +2=0,x);
(D10)                           [x = 1, x = 2]
(C11) diff(x,x);
(D11)                                  1
(C12) diff(x^2,x);
                                    d    2
(D12)                               -- (x )
                                    dx
(C13) 'diff(x,t,2) +a*'diff(x,t) + b*x =d*sin(e*t);
                          2
                         d x     dx
(D13)                    --- + a -- + b x = d SIN(e t)
                           2     dt
                         dt
(C14) ode2(d13,x,t);
           2
Is  4 b - a   positive, negative, or zero?

positive;
              a t
            - ---                    2
               2         SQRT(4 b - a ) t
(D14) x = %E      (d SIN(----------------)
                                2

 /                          2                       2
 [      2 e t + SQRT(4 b - a ) t        SQRT(4 b - a ) t - 2 e t
 I (SIN(------------------------) - SIN(------------------------))
 ]                 2                               2
 /

                                   a t
                    2            - ---                 2
        SQRT(4 b - a ) t   d        2      SQRT(4 b - a ) t
/(2 COS(----------------) (-- (%E      SIN(----------------)))
               2           dt                     2

                                    a t
                     2            - ---                 2
         SQRT(4 b - a ) t   d        2      SQRT(4 b - a ) t
 - 2 SIN(----------------) (-- (%E      COS(----------------)))) dt
                2           dt                     2

                     2     /                          2
         SQRT(4 b - a ) t  [      2 e t + SQRT(4 b - a ) t
 + d COS(----------------) I (COS(------------------------)
                2          ]                 2
                           /

                   2                                 2
       SQRT(4 b - a ) t - 2 e t          SQRT(4 b - a ) t
 - COS(------------------------))/(2 COS(----------------)
                  2                             2

          a t
        - ---                 2                           2
  d        2      SQRT(4 b - a ) t            SQRT(4 b - a ) t
 (-- (%E      SIN(----------------))) - 2 SIN(----------------)
  dt                     2                           2

          a t
        - ---                 2
  d        2      SQRT(4 b - a ) t
 (-- (%E      COS(----------------)))) dt)
  dt                     2

(C15)
     - ---                      2                           2
        2           SQRT(4 b - a ) t            SQRT(4 b - a ) t
 + %E      (%K1 SIN(----------------) + %K2 COS(----------------))
                           2                           2
(C15)

GCLISP RUN for the sake of comparison

jalam@JOVE4 ~
jalam@JOVE4 /tmp/maxima/lib/maxima/5.9.0/binary-gcl
$ ./maxima -eval "(user::run)"
GCL (GNU Common Lisp)  Version(2.5.0) Thu Jan 30 02:37:51 CST 2003
Licensed under GNU Library General Public License
Contains Enhancements by W. Schelter

(C1) build_info;

(D1)                              BUILD_INFO
(C2) build_info();

Maxima version: 5.9.0
Maxima build date: 19:10 2/9/2003
host type: i686-pc-mingw32
lisp-implementation-type: Kyoto Common Lisp
lisp-implementation-version: GCL-2-5.0

(D2)
(C3) 2 + 2;

(D3)                                   4
(C4) integrate (x^2,x);

                                       3
                                      x
(D4)                                  --
                                      3
(C5) integrate(x^3,x,0,1);

                                       1
(D5)                                   -
                                       4
(C6) 'diff(x,t,2)=0;

                                     2
                                    d x
(D6)                                --- = 0
                                      2
                                    dt
(C7) ode2(d6,x,t);

(D7)                            x = %K2 t + %K1
(C8) 'diff(x,t,2) + a*'diff(x,t) + b*x=0;

                              2
                             d x     dx
(D8)                         --- + a -- + b x = 0
                               2     dt
                             dt
(C9) ode2(d8,x,t);

           2
Is  4 b - a   positive, negative, or zero?

positive;
              a t
            - ---                      2                           2
               2           SQRT(4 b - a ) t            SQRT(4 b - a ) t
(D9)  x = %E      (%K1 SIN(----------------) + %K2 COS(----------------))
                                  2                           2
(C10) solve(x^2 - 3*x +2=0,x);

(D10)                           [x = 1, x = 2]
(C11) diff(x,x);

(D11)                                  1
(C12) diff(x^2,x);

(D12)                                 2 x
(C13) 'diff(x,t,2) + a*'diff(x,t) + b*x = d*sin(e*t);

                          2
                         d x     dx
(D13)                    --- + a -- + b x = d SIN(e t)
                           2     dt
                         dt
(C14) ode2(d13,x,t);

           2
Is  4 b - a   positive, negative, or zero?

positive;
              a t
            - ---                      2                           2
               2           SQRT(4 b - a ) t            SQRT(4 b - a ) t
(D14) x = %E      (%K1 SIN(----------------) + %K2 COS(----------------))
                                  2                           2

                                             2
                                         (d e  - b d) SIN(e t) + a d e 
COS(e t)
                                       - 
--------------------------------------
                                                 4     2         2    2
                                                e  + (a  - 2 b) e  + b
(C15)

This shows that it could be a very small problem in clisp compilation of 
maxima on winxp under cygwin. Any suggestion will be very helpful. Thanks

regards javed

James Amundson wrote:

>On Fri, 2003-09-19 at 01:31, Javed Alam wrote:
>  
>
>>I tried to solve this 2nd order differential equation 
>>and end up with
><snip>
>I was not able to reproduce this result with Maxima 5.9.0+Clisp 2.29 or
>the current Maxima cvs+Clisp 2.31. Looking at it, I don't see how you
>could possibly get "1. Break [1]>" In the middle of a displayed
>equation. Do you know what happened there? It would be helpful for you
>to send us the output of "build_info();"
>
>--Jim
>
>
>
>  
>

-- 

*Javed Alam, *Ph.D.

*Professor*

Youngstown, Ohio 44555

Phone 330-941-3029

Fax     330-941-3265

---

From: James Amundson <[email-masked]>
Date: Fri Sep 19 16:25:48 2003

<snip>

--Jim

---

From: James Amundson <[email-masked]>
Date: Fri Sep 19 17:55:15 2003

> CYGWIN { 2003/08/31 12:05:44 Starting cygwin install, version 2.340.2.5 }

I am pretty sure there is a small, but important conflict between clisp
2.31 and Maxima 5.9.0. The good news is that the problem is fixed in
CVS. The bad news is that I don't remember exactly which change it was.
(Anyone else? It may have been a change for CMUCL. It definitely
predates Clisp 2.31.) 

We need to think about making a 5.9.1 release. In the meantime, getting
the CVS version of Maxima would be the easiest workaround.

--Jim

---

From: Fred Cohen <[email-masked]>
Date: Fri Sep 19 18:25:02 2003

So we are all clear, which versions have this problem?

And on another related issue - how can it really be that we get a
working functional system with that wrong an answer? It dramtically
reduces my confidence in the tests and related material associated with
maxima / clisp if such problems can happen so easily without notice.

FC

> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> clisp-list mailing list
> [email-masked]
> https://lists.sourceforge.net/lists/listinfo/clisp-list

-- This communication is confidential to the parties it is intended to serve --
Fred Cohen - http://all.net/ - [email-masked] - [email-masked] - tel/fax: 925-454-0171
Fred Cohen & Associates	- University of New Haven - Security Posture

---

From: "Vadim V. Zhytnikov" <[email-masked]>
Date: Fri Sep 19 21:12:05 2003

> the CVS version of Maxima would be the easiest workaround.

Right, Maxima 5.9.0 will not work with clisp 2.31 and 2.30 (other 
reason).  As for clisp 2.31 incompatibolity - the fix is the
latest patch to commac.lisp (maclisp-typep).

-- 
      Vadim V. Zhytnikov

       <[email-masked]>
      <[email-masked]>

---

From: James Amundson <[email-masked]>
Date: Sat Sep 20 18:21:30 2003

> So we are all clear, which versions have this problem?

Clisp 2.29 works well with Maxima 5.9.0. Clisp 2.30 has some problem with
numerical type conversions that causes huge problems with Maxima, as is
documented in the file README.lisps, which is included in the Maxima
distribution.. Clisp 2.31 has "this problem" with Maxima 5.9.0, but the
problem is fixed in the current Maxima cvs.

> working functional system with that wrong an answer? 

Maxima comes with a test suite, which can be invoked with "make check" in
the source directory. When compiled with Clisp 2.31, Maxima 5.9.0 crashes
roughly 1/3 of the way into the test suite. It isn't a working, functional
system.

> It dramtically

The current Maxima test suite easily identifies the problem. I would be
worried if it didn't.

--Jim Amundson

---

From: James Amundson <[email-masked]>
Date: Mon Sep 22 08:23:07 2003

On Mon, 2003-09-22 at 09:24, Sam Steingold wrote:
> The following message is a courtesy copy of an article
> that has been posted to gmane.lisp.clisp.general as well.
> 
> > * James Amundson <[email-masked]> [2003-09-20 19:49:52 -0500]:
> > When compiled with Clisp 2.31, Maxima 5.9.0 crashes roughly 1/3 of the
> > way into the test suite. It isn't a working, functional system.
> 
> could you please send us with a test case?

If you have a maxima source directory, just type "make check". You
should get "Unkown error in log file." The details can be seen in
tests/tests-clisp.log.

The problem is completely maxima's fault. Raymond Toy fixed the problem
in CVS a few months ago. I've attached the relevant section of code
below. (The buggy function is the one that now has #+nil.) We will try
to make a new release soon.

--Jim

Relevant section of commac.lisp:

;; This assumes way too much about how typep works, so don't use it.
;; We leave it here for reference to make sure the replacement below
;; does the same thing.
#+nil
(defun maclisp-typep (x &optional type)
  (cond (type
         (lisp:let (( pred (get type 'ml-typep)))
        (cond (pred
                (funcall pred x))
               (t (typep x type)))))
        (t
        (lisp:let ((.type. (#. (if (boundp
'*primitive-data-type-function*)
                                   *primitive-data-type-function*
'type-of)
                                   x)))
          (cond
           ((one-of-types .type.  'hi nil) 'symbol)
           ((one-of-types .type. '(a)) 'list)
           ((one-of-types .type. 3) 'fixnum)
           ((one-of-types .type.  (make-array 3) "abc")
            (cond ((stringp x) 'string) ;;should really be symbol 'ugggh
                  #+ti ((hash-table-p x) 'hash-table)
                  (t 'array)))
           ((one-of-types .type. (expt 2 50) 1.234
most-positive-single-float
                          most-positive-double-float
most-positive-long-float )
              (cond
                    ((integerp x) 'bignum)
                    ((floatp x) 'flonum )
                    (t 'number)))
           ;;note the following is 'random in maclisp
           ((one-of-types .type. #'cons) 'compiled-function)
           #-ti ((one-of-types .type.  (make-hash-table))
            (cond ((hash-table-p x) 'hash-table)
                  (t (type-of x))))
           ((arrayp x) 'array)
           ;((one-of-types .type. (make-array '(2 3)))  'array)
           (t (type-of x)))))))

;; A more portable implementation of maclisp-typep.  I (rtoy) think it
;; would probably be better to replace uses of maclisp-typep and/or
;; ml-typep with the corresponding Common Lisp typep or type-of or
;; subtypep, as appropriate.
(defun maclisp-typep (x &optional type)
  (cond (type
         (lisp:let ((pred (get type 'ml-typep)))
           (cond (pred
                  (funcall pred x))
                 (t (typep x type)))))
        (t
         (typecase x
           (cl:cons 'list)
           (cl:fixnum 'fixnum)
           (cl:integer 'bignum)
           (cl:float 'flonum)
           (cl:number 'number)
           (cl:array 'array)
           (cl:hash-table 'hash-table)
           (t
            (type-of x))))))

---

From: James Amundson <[email-masked]>
Date: Mon Sep 22 10:51:11 2003

On Mon, 2003-09-22 at 10:45, Sam Steingold wrote:

> thanks - I thought that "crash" meant a CLISP sergfault (which is always
> a CLISP fault, not an application problem).

That's a reasonable assumption. What I really meant is that Maxima falls
into the Lisp debugger, which is Maxima's equivalent of crashing.

Sorry for causing unnecessary alarm.

--Jim