Need Math Instruction [message #83439] |
Wed, 06 March 2013 17:22  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Folks,
I need some help with a math problem. Here are some values and an
expression. The result of the expression is a NaN.
arec= 7.0380332e-005
brec= 0.011374851
crec= 0.010008938
drec= 3.8378659e-005
Tprec = (brec-(brec^2 -4*arec)^(1.0/2))/(2*arec)
IDL> help, Tprec
TPREC FLOAT = -NaN
I want to know why this is a NaN and how to explain the following
results:
IDL> help, brec, arec
BREC FLOAT = 0.0113749
AREC FLOAT = 7.03803e-005
IDL> print, (brec^2 -4*arec)
-0.000152134
IDL> d = (brec^2 -4*arec)
IDL> help, d
D FLOAT = -0.000152134
IDL> print, d^(1.0/2)
-NaN
IDL> print, -0.000152134^(1.0/2)
-0.0123343
IDL> print, d, format='(F0.12)'
-0.000152134089
IDL> print, -0.000152134089D^(1.0/2)
-0.012334265
IDL> print, Float(-0.0001521340891486)^(1.0/2)
-NaN
IDL> print, -0.0001521340891486^(1.0/2)
-0.0123343
IDL> print, Double(-0.0001521340891486D)^(1.0/2)
-NaN
IDL> print, -0.0001521340891486D^(1.0/2)
-0.012334265
Any ideas?
Thanks,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|
Re: Need Math Instruction [message #83496 is a reply to message #83439] |
Thu, 07 March 2013 15:34  |
DavidF[1]
Messages: 94 Registered: April 2012
|
Member |
|
|
On Thursday, March 7, 2013 4:31:35 PM UTC-7, Mike Galloy wrote:
> Your Tprec expression looks suspiciously like the quadratic formula,
> but, if so, has a couple typos.
Ah, a misspent youth drinking beer and chasing women instead of paying attention in math class, I guess. :-)
Cheers,
David
|
|
|
Re: Need Math Instruction [message #83497 is a reply to message #83439] |
Thu, 07 March 2013 15:31  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On 3/7/13 3:41 PM, Coyote wrote:
> On Thursday, March 7, 2013 3:30:44 PM UTC-7, Craig Markwardt wrote:
>> On Wednesday, March 6, 2013 11:52:54 PM UTC-5, Jeremy Bailin
>> wrote:
>>
>>> Is it -4*arec or -4*arec*crec?
>>
>> Hah, nice catch! David, you should check your math again. Also
>> whether the first term should be -BREC.
>
> I really don't have *any* idea what you guys are talking about. You
> will have to explain it to me like I am a 5-year-old. :-)
>
> David
>
Your Tprec expression looks suspiciously like the quadratic formula,
but, if so, has a couple typos.
Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Research Mathematician
Tech-X Corporation
|
|
|
Re: Need Math Instruction [message #83501 is a reply to message #83439] |
Thu, 07 March 2013 14:41  |
DavidF[1]
Messages: 94 Registered: April 2012
|
Member |
|
|
On Thursday, March 7, 2013 3:30:44 PM UTC-7, Craig Markwardt wrote:
> On Wednesday, March 6, 2013 11:52:54 PM UTC-5, Jeremy Bailin wrote:
>
>> Is it -4*arec or -4*arec*crec?
>
> Hah, nice catch! David, you should check your math again. Also whether the first term should be -BREC.
I really don't have *any* idea what you guys are talking about. You will have to explain it to me like I am a 5-year-old. :-)
David
|
|
|