bugGNU Octave - Bugs: bug #57476, Numerical inaccuracy in range...

 
 

bug #57476: Numerical inaccuracy in range object with complex power operation

Submitter:  Luis Mendo <lmendo>
Submitted:  Wed 25 Dec 2019 12:10:57 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Inaccurate Result
Status:  Confirmed Assigned to:  None
Originator Name:  Luis Mendo Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 26 Dec 2019 06:38:23 PM UTC, comment #1: 

Confirmed.  I checked with the current development version of Octave and the behavior is still present.

On one hand, Octave is for numerical computation, not pure math.  The best one can expect is to be within an eps or two of the true result which the range operator does satisfy.

But, given that this is a simple operation and is computed correctly in one instance this leads one to believe it can be calculated exactly.

For reference, Octave has a "range" object which efficiently represents ranges (START:INCREMENT:END).  To convert from the efficient space-saving representation to a full matrix representation you can use brackets or the full() function.


x = 1:100;
whos x
Variables visible from the current scope:

variables in scope: top scope

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  =====
        x           1x100                       24  double

Total is 100 elements using 24 bytes

y = [x];
whos y
Variables visible from the current scope:

variables in scope: top scope

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  =====
        y           1x100                      800  double

Total is 100 elements using 800 bytes

z = full (x);
whos z
Variables visible from the current scope:

variables in scope: top scope

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  =====
        z           1x100                      800  double

Total is 100 elements using 800 bytes


As you noted, typeinfo() will tell you what representation Octave is using internally.

I think the best place to start debugging this is to look at the power operator implementation between Complex values and ranges.

In particular, the implementation between a Complex scalar and a range.  I did a quick check and a Complex matrix raised to a range works.


base = [i, i, i, i];
rng = 1:4;
base .^ rng
ans =

   0 + 1i  -1 + 0i   0 - 1i   1 + 0i



Rik <rik5>
Group administrator
Wed 25 Dec 2019 12:10:57 PM UTC, original submission:  

There seems to be some numerical accuracy issues with `range` objects.


x = 1:4; % typeinfo gives "range"
y = x.'.'; % typeinfo gives "matrix"
x==y % gives all true, as expected
1j.^x % gives INACCURATE result. Error is of the order of eps
1j.^y % gives the expected result


Tested in Octave 5.1 on Linux, and in Octave 4.2 on Linux and on Windows

Luis Mendo <lmendo>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by lmendo (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-12-26 rik5 StatusNone Confirmed
        Release5.1.0 dev
        SummaryNumerical inaccuracy in range object Numerical inaccuracy in range object with complex power operation

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code