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

 
 

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

Submitted by:  Doug Stewart <dastew>
Submitted on:  Fri 07 Dec 2012 03:13:16 PM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Inaccurate Result
Status: FixedAssigned to: None
Originator Name: Doug StewartOpen/Closed: Closed
Release: devOperating System: Any

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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>
Project 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>
Project 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 File(s):
   
   
Comment:
   

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

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 21 Oct 2013 10:19:12 PM UTCrik5StatusPatch Submitted=>Fixed
      Open/ClosedOpen=>Closed
    Thu 17 Oct 2013 09:20:08 PM UTCrik5StatusNeed Info=>Patch Submitted
    Mon 30 Sep 2013 01:34:19 AM UTCmtmillerCategoryNone=>Octave Function
      StatusNone=>Need Info
    Fri 07 Dec 2012 03:13:16 PM UTCdastewAttached File-=>Added 15744.patch, #27052

    Back to the top


    Powered by Savane 3.1-cleanup