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

 
 

bug #33135: nthroot failure for complex inputs

Submitted by:  Pascal Dupuis <cdemills>
Submitted on:  Thu 21 Apr 2011 10:04:45 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Pascal DupuisOpen/Closed: Closed
Release: 3.2.4Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

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>
Project 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>
Project Member
Fri 22 Apr 2011 01:11:10 PM UTC, comment #2:
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

throws an error because the input is complex?

Rik <rik5>
Project 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>
Project Member

 

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

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 22 Apr 2011 03:59:00 PM UTCrik5StatusNeed Info=>Fixed
      Open/ClosedOpen=>Closed
    Thu 21 Apr 2011 07:29:15 PM UTCrik5StatusNone=>Need Info

    Back to the top


    Powered by Savane 3.1-cleanup1