bugGNU Octave - Bugs: bug #39044, sign function gives wrong answer...

 
 

bug #39044: sign function gives wrong answer for complex numbers.

Submitted by:  Robert Jacobs <robertlj52>
Submitted on:  Wed 22 May 2013 09:21:25 PM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: Wont FixAssigned to: None
Originator Name: Robert JacobsOpen/Closed: Closed
Release: 3.6.4Operating System: Microsoft Windows

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Wed 17 Jul 2013 06:47:59 PM UTC, comment #5:

Octave has to use whatever convention Matlab has established, in this case Z / abs (Z) for complex numbers. The documentation reference is explicit about that formula (http://www.mathworks.com/help/matlab/ref/sign.html).

Rik <rik5>
Project Administrator
Wed 22 May 2013 09:50:56 PM UTC, comment #4:

My original definintion was incorrect, but the example was correct.
But wikipedia defines a complex sign as 'x ./ (sqrt(x^2))'

yes I was refering to csgn.

Robert Jacobs <robertlj52>
Wed 22 May 2013 09:45:14 PM UTC, comment #3:

I can see a use both ways since MATLAB's way would make
sign(a) * abs(a) == a, which I guess is what they were after.

Robert Jacobs <robertlj52>
Wed 22 May 2013 09:37:14 PM UTC, comment #2:

Are you referring to this page [1]? If yes, then it seems to me that octave sign definition is consistent with the wikipedia definition (z/abs(z)). According to the same link, you seem to refer to what wikipedia defines as "csgn" (z/sqrt(z^2)).

[1] http://en.wikipedia.org/wiki/Sign_function

Michael Goffioul <goffioul>
Project Member
Wed 22 May 2013 09:28:26 PM UTC, comment #1:

It doesn't really matter what wikipediea says, Matlab's sign function returns x./abs(x). So that's what Octave has to do as well. Otherwise we'd get just as many bug reports saying that Octave's sign function is incompatible with Matlab.

John W. Eaton <jwe>
Project Administrator
Wed 22 May 2013 09:21:25 PM UTC, original submission:

According to your documentation.
For complex arguments, `sign' returns `x ./ abs (X)'

But wikipedia defines a complex sign as 'x ./ (abs(x^2))'

Example:
a = 3 - 4i;
sign(a)
ans = 0.60000 - 0.80000i
a ./ sqrt(a.*a)
ans = 1

Robert Jacobs <robertlj52>

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by goffioul (Posted a comment)
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by robertlj52 (Submitted the item)
  • -unavailable- added by robertlj52
  •  

    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 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 17 Jul 2013 06:47:59 PM UTCrik5StatusNone=>Wont Fix
      Open/ClosedOpen=>Closed
    Wed 22 May 2013 09:21:25 PM UTCrobertlj52Carbon-Copy-=>Added robertlj52

    Back to the top


    Powered by Savane 3.1-cleanup1