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

Home » Public Forums » archive » IDL is not accurate enough!
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
IDL is not accurate enough! [message #62192] Thu, 28 August 2008 09:30 Go to next message
noahh.schwartz is currently offline  noahh.schwartz
Messages: 10
Registered: February 2008
Junior Member
Hi,

I've been having problems with IDL accuracy. I'm trying to perform
calculations using the gamma function. The problem is that it grows
VERY fast! Performing this calculation in double (namely gamma(x)/
gamma(y) with x and y big) yields the result: NaN...
Would it be possible to use a program like 'Mathematica' (or any
other) and to plug it in my ILD program? Some kind of CALL_EXTERNAL
that is to say. If it is possible, how can I do it and what is the
best program to use?

Thanks,
Noah
Re: IDL is not accurate enough! [message #62299 is a reply to message #62192] Tue, 02 September 2008 05:20 Go to previous messageGo to next message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
Noah,
other in this thread have laid out the issue, nothing to add here. If you
want to go brute force with extended precision, check out the cephes math
library at http://www.netlib.org/cephes/. There is an extended precision
version that has a gamma function. I have used that in the past for
calculating hypergeometric functions and it served my needs. I used
call_external, but you can certainly turn this into a dlm.

Cheers,
Haje

<noahh.schwartz@gmail.com> wrote in message
news:c7b7fc70-b4db-4c3d-8d2b-50f88dbd1d62@s50g2000hsb.google groups.com...
> Hi,
>
> I've been having problems with IDL accuracy. I'm trying to perform
> calculations using the gamma function. The problem is that it grows
> VERY fast! Performing this calculation in double (namely gamma(x)/
> gamma(y) with x and y big) yields the result: NaN...
> Would it be possible to use a program like 'Mathematica' (or any
> other) and to plug it in my ILD program? Some kind of CALL_EXTERNAL
> that is to say. If it is possible, how can I do it and what is the
> best program to use?
>
> Thanks,
> Noah
Re: IDL is not accurate enough! [message #62321 is a reply to message #62192] Fri, 05 September 2008 09:53 Go to previous messageGo to next message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article
<53e9aaf0-6cd2-41c0-95ca-1559353845a4@m36g2000hse.googlegroups.com>,
"mgalloy@gmail.com" <mgalloy@gmail.com> wrote:

> On Sep 4, 2:33�pm, "Kenneth P. Bowman" <k-bow...@null.edu> wrote:
>> So, when you say DLMs, does that mean Windows only? �It means nothing
>> to me as a Linux and Mac user.
>
> DLMs (Dynamically Loadable Modules) are available on all platforms.
> This is a way of wrapping and loading C code to make it usable from
> within IDL. DLLs are a Windows thing (the equivalent of a shared
> object on Unix).
>
> Mike
> --
> www.michaelgalloy.com
> Tech-X Corporation
> Software Developer

Thanks, Mike. I will take a look and see what I need to do to
make one work.

Ken
Re: IDL is not accurate enough! [message #62336 is a reply to message #62192] Fri, 05 September 2008 09:18 Go to previous messageGo to next message
MP is currently offline  MP
Messages: 15
Registered: March 2006
Junior Member
On Sep 5, 9:57 am, "mgal...@gmail.com" <mgal...@gmail.com> wrote:

> DLMs (Dynamically Loadable Modules) are available on all platforms.
> This is a way of wrapping and loading C code

and Fortran code, too!

mp
Re: IDL is not accurate enough! [message #62339 is a reply to message #62192] Fri, 05 September 2008 08:57 Go to previous messageGo to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On Sep 4, 2:33 pm, "Kenneth P. Bowman" <k-bow...@null.edu> wrote:
> So, when you say DLMs, does that mean Windows only?  It means nothing
> to me as a Linux and Mac user.

DLMs (Dynamically Loadable Modules) are available on all platforms.
This is a way of wrapping and loading C code to make it usable from
within IDL. DLLs are a Windows thing (the equivalent of a shared
object on Unix).

Mike
--
www.michaelgalloy.com
Tech-X Corporation
Software Developer
Re: IDL is not accurate enough! [message #62353 is a reply to message #62192] Thu, 04 September 2008 13:33 Go to previous messageGo to next message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article
<e32f4688-b58e-4f27-b2f9-17faea24285a@i24g2000prf.googlegroups.com>,
rtk <oneelkruns@hotmail.com> wrote:

> On Aug 28, 2:50 pm, "Kenneth P. Bowman" <k-bow...@null.edu> wrote:
>> Mathematica can do arbitrary-precision arithmetic ... with hundreds of digits,
>> if necessary. Don't expect it to be fast, though, as it is all done
>> in software, not with the hardware floating-point unit with which we
>> normally do single- and double-precision arithmetic.
>
> Check on the IDL code contrib site sometime next week. I just
> uploaded DLMs that add arbitrary precision floating point as well as
> integer and rational types to IDL. These are wrappers on the MPFR and
> GMP libraries, respectively. Caveat emptor, but I'll answer emails.
> You will need to recompile if using something later than IDL 6.3.
> Examples included.
>
> Ron Kneusel
> rkneusel@ittvis.com

So, when you say DLMs, does that mean Windows only? It means nothing
to me as a Linux and Mac user.

Ken Bowman
Re: IDL is not accurate enough! [message #62508 is a reply to message #62192] Thu, 11 September 2008 07:44 Go to previous messageGo to next message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
pgri...@gmail.com wrote:
> noahh.schwa...@gmail.com wrote:
>> On 28 ao�t, 18:42, F�LDY Lajos <fo...@rmki.kfki.hu> wrote:
>>> On Thu, 28 Aug 2008, noahh.schwa...@gmail.com wrote:
>>>> Hi,
>>>
>>>> I've been having problems with IDL accuracy. I'm trying to perform
>>>> calculations using the gamma function. The problem is that it grows
>>>> VERY fast! Performing this calculation in double (namely gamma(x)/
>>>> gamma(y) with x and y big) yields the result: NaN...
>>>> Would it be possible to use a program like 'Mathematica' (or any
>>>> other) and to plug it in my ILD program? Some kind of CALL_EXTERNAL
>>>> that is to say. If it is possible, how can I do it and what is the
>>>> best program to use?
>>>
>>>> Thanks,
>>>> Noah
>>>
>>> gamma(x)/gamma(y) => exp(lngamma(x)-lngamma(y))
>>>
>>> regards,
>>> lajos
>>
>>
>> lngamma works fine for my propose! Would you know if an equivalent
>> function exists for the beselk function? Something like lnbeselk?
>> beselk(x) for x>709 doesn't seen to work.
>
> Isn't 0 a good enough approximation?

If not, log(K(x,n))~ln(sqrt(!pi/(2*x)))-x for large x

Paolo


>
> Paolo
>
>
>> If not, I guess that I'll have to wait for the DLMs that add arbitrary
>> precision floating point...
>>
>> cheers,
>> Noah
Re: IDL is not accurate enough! [message #62509 is a reply to message #62192] Thu, 11 September 2008 07:35 Go to previous messageGo to next message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
noahh.schwa...@gmail.com wrote:
> On 28 ao�t, 18:42, F�LDY Lajos <fo...@rmki.kfki.hu> wrote:
>> On Thu, 28 Aug 2008, noahh.schwa...@gmail.com wrote:
>>> Hi,
>>
>>> I've been having problems with IDL accuracy. I'm trying to perform
>>> calculations using the gamma function. The problem is that it grows
>>> VERY fast! Performing this calculation in double (namely gamma(x)/
>>> gamma(y) with x and y big) yields the result: NaN...
>>> Would it be possible to use a program like 'Mathematica' (or any
>>> other) and to plug it in my ILD program? Some kind of CALL_EXTERNAL
>>> that is to say. If it is possible, how can I do it and what is the
>>> best program to use?
>>
>>> Thanks,
>>> Noah
>>
>> gamma(x)/gamma(y) => exp(lngamma(x)-lngamma(y))
>>
>> regards,
>> lajos
>
>
> lngamma works fine for my propose! Would you know if an equivalent
> function exists for the beselk function? Something like lnbeselk?
> beselk(x) for x>709 doesn't seen to work.

Isn't 0 a good enough approximation?

Paolo


> If not, I guess that I'll have to wait for the DLMs that add arbitrary
> precision floating point...
>
> cheers,
> Noah
Re: IDL is not accurate enough! [message #62558 is a reply to message #62192] Mon, 15 September 2008 06:40 Go to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
noahh.schwa...@gmail.com wrote:
> On 11 sep, 16:44, pgri...@gmail.com wrote:
>> pgri...@gmail.com wrote:
>>> noahh.schwa...@gmail.com wrote:
>>>> On 28 ao t, 18:42, F LDY Lajos <fo...@rmki.kfki.hu> wrote:
>>>> > On Thu, 28 Aug 2008, noahh.schwa...@gmail.com wrote:
>>>> > > Hi,
>>
>>>> > > I've been having problems with IDL accuracy. I'm trying to perform
>>>> > > calculations using the gamma function. The problem is that it grows
>>>> > > VERY fast! Performing this calculation in double (namely gamma(x)/
>>>> > > gamma(y) with x and y big) yields the result: NaN...
>>>> > > Would it be possible to use a program like 'Mathematica' (or any
>>>> > > other) and to plug it in my ILD program? Some kind of CALL_EXTERNAL
>>>> > > that is to say. If it is possible, how can I do it and what is the
>>>> > > best program to use?
>>
>>>> > > Thanks,
>>>> > >Noah
>>
>>>> > gamma(x)/gamma(y) => exp(lngamma(x)-lngamma(y))
>>
>>>> > regards,
>>>> > lajos
>>
>>>> lngamma works fine for my propose! Would you know if an equivalent
>>>> function exists for the beselk function? Something like lnbeselk?
>>>> beselk(x) for x>709 doesn't seen to work.
>>
>>> Isn't 0 a good enough approximation?
>>
>> If not, log(K(x,n))~ln(sqrt(!pi/(2*x)))-x for large x
>>
>> Paolo
>>
>>
>>
>>> Paolo
>>
>>>> If not, I guess that I'll have to wait for the DLMs that add arbitrary
>>>> precision floating point...
>>
>>>> cheers,
>>>> Noah
>
>
>
> Hi Paolo,
> Your approximation seems to be missing a factor? This is what IDL
> gives me:
>
> IDL> x=705d & n=1.1 & print, alog10(beselk(x,n)), (alog(sqrt(!pi/
> (2*x)))-x)
> -307.50372 -708.05331

I meant the natural log (why should a bessel function
care about base 10 anyway?), so use alog instead.

Cheers,
Paolo

>
> Cheers,
> Noah
Re: IDL is not accurate enough! [message #62563 is a reply to message #62508] Mon, 15 September 2008 02:37 Go to previous message
noahh.schwartz is currently offline  noahh.schwartz
Messages: 10
Registered: February 2008
Junior Member
On 11 sep, 16:44, pgri...@gmail.com wrote:
> pgri...@gmail.com wrote:
>> noahh.schwa...@gmail.com wrote:
>>> On 28 ao t, 18:42, F LDY Lajos <fo...@rmki.kfki.hu> wrote:
>>>> On Thu, 28 Aug 2008, noahh.schwa...@gmail.com wrote:
>>>> > Hi,
>
>>>> > I've been having problems with IDL accuracy. I'm trying to perform
>>>> > calculations using the gamma function. The problem is that it grows
>>>> > VERY fast! Performing this calculation in double (namely gamma(x)/
>>>> > gamma(y) with x and y big) yields the result: NaN...
>>>> > Would it be possible to use a program like 'Mathematica' (or any
>>>> > other) and to plug it in my ILD program? Some kind of CALL_EXTERNAL
>>>> > that is to say. If it is possible, how can I do it and what is the
>>>> > best program to use?
>
>>>> > Thanks,
>>>> >Noah
>
>>>> gamma(x)/gamma(y) => exp(lngamma(x)-lngamma(y))
>
>>>> regards,
>>>> lajos
>
>>> lngamma works fine for my propose! Would you know if an equivalent
>>> function exists for the beselk function? Something like lnbeselk?
>>> beselk(x) for x>709 doesn't seen to work.
>
>> Isn't 0 a good enough approximation?
>
> If not, log(K(x,n))~ln(sqrt(!pi/(2*x)))-x for large x
>
> Paolo
>
>
>
>> Paolo
>
>>> If not, I guess that I'll have to wait for the DLMs that add arbitrary
>>> precision floating point...
>
>>> cheers,
>>> Noah



Hi Paolo,
Your approximation seems to be missing a factor? This is what IDL
gives me:

IDL> x=705d & n=1.1 & print, alog10(beselk(x,n)), (alog(sqrt(!pi/
(2*x)))-x)
-307.50372 -708.05331

Cheers,
Noah
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Maximum index for arrays?
Next Topic: Re: IDL calls C calls IDL?

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

Current Time: Wed Oct 08 18:38:33 PDT 2025

Total time taken to generate the page: 0.00761 seconds