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

Home » Public Forums » archive » Re: Math Question
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: Math Question [message #51118 is a reply to message #51117] Sun, 29 October 2006 09:59 Go to previous message
Foldy Lajos is currently offline  Foldy Lajos
Messages: 268
Registered: October 2001
Senior Member
On Sun, 29 Oct 2006, David Fanning wrote:

> Folks,
>
> OK, I get the feeling that I am going to be referred to
> my own web page with this question:
>
> http://www.dfanning.com/math_tips/sky_is_falling.html
>
> And it is certainly true that I have been watching WAY
> too much TV lately (World Series, you know), but here is
> my question. How does one explain the following two
> IDL commands?
>
> IDL> Help, (-0.1)^2.0
> <Expression> FLOAT = 0.0100000
> IDL> Help, (-0.1)^2.01
> <Expression> FLOAT = -NaN
>
> In general, raising a negative number to any integer
> power seems to produce a real number, whereas raising
> a negative number to a non-integer power causes a NAN.
>
> I am sure this is explained in one of those textbooks
> covered with dust in my garage, but I thought one of
> you math guys could rescue me from a beautiful day
> spent covered with dust. :-)
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
>

I had the opposite problem with FL: (-0.1)^2.0 was also a NaN. Power is
defined for floats as x^y = exp(log(x)*y), and log() is undefined for
non-positive numbers. Now FL examines y first, and if its is an integer,
then uses multiplications. I think IDL does the same.

regards,
lajos

ps: what will be the result for (-0.1)^2.0000001 ? :-)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Determining a safe variable name from a string
Next Topic: overlaying arrow plots

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

Current Time: Fri Oct 10 16:57:35 PDT 2025

Total time taken to generate the page: 0.79822 seconds