comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Cubic root finding on a grid
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: cubic root [message #83964 is a reply to message #68737] Tue, 16 April 2013 08:19 Go to previous message
Lajos Foldy is currently offline  Lajos Foldy
Messages: 176
Registered: December 2011
Senior Member
On Tuesday, April 16, 2013 5:08:12 PM UTC+2, fd_...@mail.com wrote:
> Hi all
>
>
>
> I have a question about cubic roots. The cubic roots of a negative number there exists. The cubir root of -1 is -1, 0f -2 is -1.25 and so on why when I typed in IDL to calculate the cubic root of a negative value it print out NaN which means Not a Number?
>
>
>
> E.g. I typed: (-1)^1.0/3 and it prints out NaN
>
>
>
> Is there any way to fixed it and don't get NaNs but get the actual value?
>
>
>
> Best Wishes
>
> Maria

(-1)^1.0/3 gives -0.333333 for me.

You have to specify that you want complex roots:

IDL> help, complex(-1.0)^(1.0/3)
<Expression> COMPLEX = ( 0.500000, 0.866025)

(and note that ^ has higher precedence than /).

regards,
Lajos
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Finding distance with longitude and latitude
Next Topic: All logical unit currently in use

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 16:28:59 PDT 2025

Total time taken to generate the page: 0.80015 seconds