#2749 Float evaluation of sinh causes Lisp error instead of overflowing to bigfloat

None
wont-fix
nobody
5
2016-03-14
2014-06-04
No

When the argument for sinh is so large that it would overflow an ordinary float, it causes a Lisp error instead of overflowing to a bigfloat.

sinh (1e3);
  => CDR: 1000.0 is not a list

Backtrace shows that's in the bigfloat sinh function FPSINH. Pretty sure what's going on is that FPSINH has been handed an ordinary float argument instead of a bigfloat. I'm guessing related functions could have the same bug.

Discussion

  • Tomio Arisaka

    Tomio Arisaka - 2014-06-06

    Hi,

    (%i1) cosh (1e3);
    (%o1)                        9.850355570085235b433
    (%i2) sinh (1e3);
    
    Maxima encountered a Lisp error:
    
     The value 1000.0 is not of type LIST.
    
    Automatically continuing.
    To enable the Lisp debugger set *debugger-hook* to nil.
    

    Thank you for your report.
    I am going to use the temporary function as follows:

    (%i3) h_sin (x) := (%e^x - %e^(-x)) / 2;
                                              x     - x
                                            %e  - %e
    (%o3)                       h_sin(x) := -----------
                                                 2
    (%i4) h_sin (1e3);
    (%o4)                        9.850355570085235b433
    

    My environment:
    Maxima version: "5.33.0"
    Maxima build date: "2014-04-20 04:11:32"
    Host type: "x86_64-apple-darwin10.8.0"
    Lisp implementation type: "SBCL"
    Lisp implementation version: "1.1.17"

     
  • Tomio Arisaka

    Tomio Arisaka - 2014-06-08

    Hi,

    I found a bug in the function big-float-eval included in the file trigi.lisp.
    The argument 'x' should be the Maxima bigfloat.

    My patch is as follows:

    $ diff ./src/trigi.lisp ./trigi.lisp 
    418c418
    <                (or (and bop (funcall bop x))
    ---
    >                (or (and bop (funcall bop ($bfloat x)))
    

    Examples for my test:

    (%i1) load ("~/Downloads/maxima/trigi.lisp"); 
    (%o1)                  ~/Downloads/maxima/trigi.lisp
    (%i2) :Lisp (describe 'big-float-eval)
    
    MAXIMA::BIG-FLOAT-EVAL
      [symbol]
    
    BIG-FLOAT-EVAL names a compiled function:
      Lambda-list: (OP Z)
      Derived type: (FUNCTION (T T) *)
      Source file: ~/Downloads/maxima/trigi.lisp
    (%i2) sinh (0);
    (%o2)                                  0
    (%i3) sinh (1), numer;
    (%o3)                          1.175201193643801
    (%i4) sinh (1e3);
    (%o4)                        9.850355570085235b433
    (%i5) sinh (float(2000));
    (%o5)                        1.940590097142184b868
    (%i6) sinh (1b3);
    (%o6)                        9.850355570085235b433
    

    By the way,
    the function BIG-FLOAT-SINH is defined, but BIG-FLOAT-COSH is not.

    (%i1) :Lisp (gethash '%sinh *big-float-op*)
    
    #<FUNCTION BIG-FLOAT-SINH>
    T
    (%i1) :Lisp (gethash '%cosh *big-float-op*)
    
    NIL
    NIL
    

    But "cosh (1e3)" works good.

    Because the function simp-%cosh included in the file trigo.lisp calls the function exponentialize if (gethash '%cosh *big-float-op*) returns nil.

    (%i1) cosh (1e3);
    (%o1)                        9.850355570085235b433
    
    (%i2) :Lisp (let ((x '((%cosh simp) 1000.0))) (exponentialize (caar x) ($bfloat (cadr x))) )
    
    ((BIGFLOAT SIMP 56) 58328111753116119 1442)
    (%i2) :Lisp (displa '((BIGFLOAT SIMP 56) 58328111753116119 1442) )
    9.850355570085235b433
    NIL
    

    If I remove the function BIG-FLOAT-SINH from the hash table *big-float-op*, the function simp-%sinh calls the function exponentialize without an error.

    (%i1) sinh (1e3);
    
    Maxima encountered a Lisp error:
     The value 1000.0 is not of type LIST.
    
    (%i2) :Lisp (gethash '%sinh *big-float-op*)
    
    #<FUNCTION BIG-FLOAT-SINH>
    T
    (%i2) :Lisp (setf (gethash '%sinh *big-float-op*) nil)
    
    NIL
    (%i2) :Lisp (gethash '%sinh *big-float-op*)
    
    NIL
    T
    (%i2) sinh (1e3);
    (%o2)                        9.850355570085235b433
    
     
    Last edit: Tomio Arisaka 2014-06-10
  • Jaime E. Villate

    • status: open --> closed
     
  • Robert Dodier

    Robert Dodier - 2016-03-14
    • status: closed --> wont-fix
     
  • Robert Dodier

    Robert Dodier - 2016-03-14

    Note that since the float-to-bigfloat promotion code has been moved to branch promote-float-to-bigfloat and reverted on master, this bug report is no longer applicable. I've marked it "wont-fix" to distinguish it from "closed".

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks