bugGNU Octave - Bugs: bug #37880, Make factor to not show wrong...

 
 

bug #37880: Make factor to not show wrong answers for large numbers

Submitter:  Doug Stewart <dastew>
Submitted:  Fri 07 Dec 2012 03:13:16 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Inaccurate Result
Status:  Fixed Assigned to:  None
Originator Name:  Doug Stewart Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 21 Oct 2013 10:19:12 PM UTC, comment #3: 

I modified and applied your patch here (http://hg.savannah.gnu.org/hgweb/octave/rev/e48f5a52e838).  This will be a part of the 3.8 release due out in a few weeks.

It seems like we could actually do better if we switched to calculating with int64, instead of double.  I tested this idea and it works for numbers above bitmax(), but there is a problem with the prod() function in that it only works in double precision.  If we fix that to be able to use the class of the inputs to prod() then this restriction can be lifted.

Rik <rik5>
Group administrator
Mon 30 Sep 2013 03:13:39 PM UTC, comment #2: 

See bug #37830

octave-3.2.4:1> bitmax
ans =  9.0072e+15
octave-3.2.4:2> factor(bitmax)
ans =

       6361      69431   20394401

octave-3.2.4:3> prod(ans)
ans =  9.0072e+15
octave-3.2.4:4> factor(bitmax+1)
ans =

 Columns 1 through 20:

   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2

 Columns 21 through 40:

   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2
Columns 41 through 53:

   2   2   2   2   2   2   2   2   2   2   2   2   2

octave-3.2.4:5> prod(ans)
ans =  9.0072e+15



 octave-3.2.4:6> factor(bitmax+2)
ans =

 Columns 1 through 20:

   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2

 Columns 21 through 40:

   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2

 Columns 41 through 53:

   2   2   2   2   2   2   2   2   2   2   2   2   2

octave-3.2.4:7> prod(ans)
ans =  9.0072e+15
 


octave-3.2.4:6> factor(bitmax+2)
ans =

 Columns 1 through 20:

   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2

 Columns 21 through 40:

   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2

 Columns 41 through 53:

   2   2   2   2   2   2   2   2   2   2   2   2   2

octave-3.2.4:7> prod(ans)
ans =  9.0072e+15


octave-3.2.4:8> factor(bitmax+200)
ans =

   2.0000e+00   2.0000e+00   2.0000e+00   8.9000e+01   6.9490e+03   1.8205e+09

octave-3.2.4:9> prod(ans)
ans =  9.0072e+15
octave-3.2.4:10> factor(bitmax+20011)
ans =

           2          71         107         919   645063007

octave-3.2.4:11> prod(ans)
ans =  9.0072e+15



I don't know what matlab does.

I understand that the user should not ask such a question, but they do.
So what should we do when they do ask?

I think we should worn them, and this is what the patch does.

Doug

Doug Stewart <dastew>
Mon 30 Sep 2013 01:34:19 AM UTC, comment #1: 

Can you paste an example with input and output parameters of what problem this patch is addressing? And what does Matlab do with the same example?

Mike Miller <mtmiller>
Group Member
Fri 07 Dec 2012 03:13:16 PM UTC, original submission:  

Patch is attached.

Doug

Doug Stewart <dastew>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #27052:  15744.patch added by dastew (1KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by dastew (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-10-21 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2013-10-17 rik5 StatusNeed Info Patch Submitted
    2013-09-30 mtmiller CategoryNone Octave Function
        StatusNone Need Info
    2012-12-07 dastew Attached File- Added 15744.patch, #27052

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code