[gambit-list] Fix complex division

Bradley Lucier lucier at math.purdue.edu
Mon Apr 18 20:58:54 EDT 2011


Marc:

There was a problem with complex division:

        > (define a (make-rectangular (expt 2 1022) (expt 2 1022)))
        > (exact->inexact a)                                       
        4.49423283715579e307+4.49423283715579e307i
        > (/ a a)                                                  
        1
        > (/ a (exact->inexact a))                                 
        1.+0.i
        > (/  (exact->inexact a) a)                                
        +nan.0+nan.0i
        
With the attached patch, things are better:

        > (define a (make-rectangular (expt 2 1022) (expt 2 1022)))
        > (exact->inexact a)                                       
        4.49423283715579e307+4.49423283715579e307i
        > (/ a a)                                                  
        1
        > (/ a (exact->inexact a))                                 
        1.+0.i
        > (/  (exact->inexact a) a)                                
        1.+0.i
        
The rest of the logic of ##cpxnum./ looks very complicated, but I
convinced myself once upon a time that it is correct ;-).

Brad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: _num.diff
Type: text/x-patch
Size: 723 bytes
Desc: not available
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20110418/f297502e/attachment.bin>


More information about the Gambit-list mailing list