bugGNU Octave - Bugs: bug #33135, nthroot failure for complex inputs

 
 

bug #33135: nthroot failure for complex inputs

Submitter:  Pascal Dupuis <cdemills>
Submitted:  Thu 21 Apr 2011 10:04:45 AM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Pascal Dupuis Open/Closed:  * Closed
Release:  * 3.2.4 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 22 Apr 2011 03:59:00 PM UTC, comment #4: 

I've fixed the input validation to disallow complex values as input.  The change is available on the default branch of Octave (http://hg.savannah.gnu.org/hgweb/octave/rev/619fbc98a7eb)

Rik <rik5>
Group administrator
Fri 22 Apr 2011 03:50:04 PM UTC, comment #3: 

Under Matlab R2010A:

nthroot(1+j, 5)

??? Error using ==> nthroot at 17
Both X and N must be real.

Same behaviour.

iscomplex() can be emulated by
if any(abs(imag(x)) > eps)

Regards

Pascal

Pascal Dupuis <cdemills>
Group Member
Fri 22 Apr 2011 01:11:10 PM UTC, comment #2: 


>> disp(version())
7.9.0.529 (R2009b)
>> nthroot(1+j, 5)
??? Error using ==> nthroot at 17
Both X and N must be real.


Anonymous
Thu 21 Apr 2011 07:29:15 PM UTC, comment #1: 

Actually, I think the problem may be that there is no iscomplex() test to validate the input.  The function nthroot that is being emulated (http://www.mathworks.com/help/techdoc/ref/nthroot.html) only accepts real values for the input.

Can someone with Matlab access validate that


nthroot(1+j, 5)


throws an error because the input is complex?

Rik <rik5>
Group administrator
Thu 21 Apr 2011 10:04:45 AM UTC, original submission:  

Some peoples need basic math lessons.

 (nthroot(1+j, 5))^5
ans = -0.077760 - 0.077760i

at nthroot.m line 62:
 y = abs (x) .^ (1/n) .* sign (x);

This is valid only if x is real ! In case of complex numbers, the value is
y = abs(x).^(1/n) .* exp(j*arg(x)/n))

Regards

Pascal

Pascal Dupuis <cdemills>
Group Member

 

(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 cdemills (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
    2011-04-22 rik5 StatusNeed Info Fixed
        Open/ClosedOpen Closed
    2011-04-21 rik5 StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code