Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1552 plot2d of sin(x) incorrect

closed
nobody
5
2009-01-12
2008-12-25
Anonymous
No

This is maxima-5.17.0 installed from source onto Kubuntu Ibex on
a 32-bit x86. It is running on sbcl_1%3a1.0.18.0-1_i386.deb installed from binary. A simple "plot2d(sin(x), [x, -3.25, -3]);" results in the plot output available at http://www.vsta.org/andy/maxima_sin.jpg

If you need to reach me, google "contact andy valencia".

Thanks!

Discussion

  • Robert Dodier
    Robert Dodier
    2008-12-26

    Not observed with current CVS version + SBCL, Clisp, CMUCL, or ECL.

    Please try:

    :lisp (trace sin)
    :lisp (setf (gethash '%sin *flonum-op*) #'sin)
    plot2d(sin(x), [x, -3.25, -3]);

    which should show the computed values of sin(x).
    Please paste the trace output into this bug report.

    If you can identify the values of sin(x) for which spurious values are returned, try starting SBCL by itself and paste the computed return values (spurious or otherwise) into this report.

    Thanks for your help.

     
  • Robert Dodier
    Robert Dodier
    2008-12-27

    Hi Andy,

    > It looks like the output set has numbers of the format:
    >
    > -3.2413793103448274 9.96211369590875800d-2

    Do I understand correctly that this is an excerpt from maxout.gnuplot
    or maxout.gnuplot_pipes?
    If so, something has gone wrong --- numbers are being printed with
    the "d" exponent marker but an "e" is intended.
    The numbers are double floats, but the Lisp environment is supposed
    to be arranged so that they are printed with "e" instead of "d".

    What do the following yield in Maxima?

    :lisp *read-default-float-format*
    :lisp (prin1 1d-20)
    :lisp (format t "~g~%" 1d-20)

    If *read-default-float-format* is something other than DOUBLE-FLOAT,
    try this:

    :lisp (setq *read-default-float-format* 'double-float)
    :lisp (prin1 1d-20)
    :lisp (format t "~g~%" 1d-20)

    Do prin1 and format yield something different than before?

    By the way, it would be better if you post the above results and
    any further comments directly into the bug report, so that others
    can follow this discussion.

    Thanks for your help,

    Robert

     
  • Robert Dodier
    Robert Dodier
    2008-12-27

    By the way, about this:

    > I found a gnuplot manual, and the "set datafile fortran" option appears
    to be needed to accept this kind of exponentiation.

    Using the fortran option is kind of a last resort --- we'll try to figure out the "d" versus "e" problem, but if we can't resolve it, we could work around the problem with the fortran option. Thanks for the information.

     
  • Here's the output; it sure looks like SBCL has settled on the wrong float format:

    Maxima 5.17.0 http://maxima.sourceforge.net
    Using Lisp SBCL 1.0.18.debian
    Distributed under the GNU Public License. See the file COPYING.
    Dedicated to the memory of William Schelter.
    The function bug_report() provides bug reporting information.
    (%i1) :lisp *read-default-float-format*

    SINGLE-FLOAT
    (%i1) :lisp (prin1 1d-20)
    1.d-20
    1.d-20
    (%i1) :lisp (format t "~g~%" 1d-20)
    1.00000000000000000000d-20
    NIL
    (%i1) :lisp (setq *read-default-float-format* 'double-float)

    DOUBLE-FLOAT
    (%i1) :lisp (prin1 1d-20)
    1.e-20
    1.e-20
    (%i1) :lisp (format t "~g~%" 1d-20)
    1.00000000000000000000e-20
    NIL
    (%i1)

     
  • Robert Dodier
    Robert Dodier
    2008-12-27

    > (%i1) :lisp *read-default-float-format*
    > SINGLE-FLOAT

    There is some code in Maxima (in src/clmacs.lisp) to set the default float format to DOUBLE-FLOAT. So the above result shows that code is not working as intended. It's not clear to me whose fault it is.

    I don't know if we (Maxima developers) want to try to work around this, or change the code in src/clmacs.lisp, or what.

    In any event there is an straightforward workaround for users: put

    (setq *read-default-float-format* 'double-float)

    in $HOME/.maxima/maxima-init.lisp .

     
  • > There is some code in Maxima (in src/clmacs.lisp) to set the default float
    > format to DOUBLE-FLOAT. So the above result shows that code is not working
    > as intended. It's not clear to me whose fault it is.

    Note that in my source tree the line:
    ;; (setq custom:*default-float-format* 'double-float)
    is commented out, with a comment above it. The comment references a stale URL, but the person doing the change was "rtoy".

     
  • Raymond Toy
    Raymond Toy
    2008-12-28

    That change is for clisp and has nothing to do with sbcl.

     
  • Robert Dodier
    Robert Dodier
    2009-01-12

    • status: open --> closed
     
  • Robert Dodier
    Robert Dodier
    2009-01-12

    After some discussion on the Maxima mailing list, we couldn't figure out why the float format is set incorrectly for the bug reporter's installation. Closing this report as "works for me".