Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Matlab wrong cubic root
Replies: 3   Last Post: Dec 15, 2012 9:05 PM

 Messages: [ Previous | Next ]
 bartekltg Posts: 55 Registered: 12/11/12
Re: Matlab wrong cubic root
Posted: Dec 15, 2012 9:05 PM

W dniu 2012-12-15 19:19, sergio_r@mail.com pisze:
> Hello all,
>
> Is there a way of telling matlab to return first a real root
> instead of a complex one?
>
> For some strange reason matlab seems not to handle cubic roots
> properly. Apparently the default behaviour is to first
> report a complex root. Let's see two examples:
>

>>> (-1/2)^(1/3)
>
> ans =
>
> 0.3969 + 0.6874i

nthroot(-1/2,3)

>
>>> (-1/2)^(2/3)
>
> ans =
>
> -0.3150 + 0.5456i

nthroot(-1/2,3)^2

I'm afraid this is the simplest way, but I'm not sure.

bartekltg

Date Subject Author
12/15/12 sergio_r@mail.com
12/15/12 Nasser Abbasi
12/15/12 Roger Stafford
12/15/12 bartekltg