Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #1314 > unrolled thread

Special functions in gnuplot

Started byboruun@gmail.com
First post2012-08-10 20:34 -0700
Last post2012-08-18 10:56 -0700
Articles 7 — 4 participants

Back to article view | Back to comp.graphics.apps.gnuplot


Contents

  Special functions in gnuplot boruun@gmail.com - 2012-08-10 20:34 -0700
    Re: Special functions in gnuplot sfeam <sfeam@users.sourceforge.net> - 2012-08-10 23:05 -0700
    Re: Special functions in gnuplot boruun@gmail.com - 2012-08-14 12:39 -0700
    Re: Special functions in gnuplot boruun@gmail.com - 2012-08-14 12:37 -0700
      Re: Special functions in gnuplot Dr Engelbert Buxbaum <engelbert_buxbaum@hotmail.com> - 2012-09-11 11:26 -0400
    Re: Special functions in gnuplot hogney@gmail.com - 2012-08-18 08:34 -0700
      Re: Special functions in gnuplot sfeam <sfeam@users.sourceforge.net> - 2012-08-18 10:56 -0700

#1314 — Special functions in gnuplot

Fromboruun@gmail.com
Date2012-08-10 20:34 -0700
SubjectSpecial functions in gnuplot
Message-ID<1694fa1b-c5e4-4561-8594-40d67337d065@googlegroups.com>
Can someone give me some pointers on how can I figure out:

a) what ALGORITHMS (files/codes either gnuplot specific or system specific) gnuplot is ACCESSING to calculate special functions like gamma, or lgamma, igamma, ibeta etc..... and WHERE are these algorithms/files located

and,

b) (if possible) tell me (or guide me on how to find) how accurate are these estimates and over what range of values for their arguments.

I am using these functions in the "fit" command and not merely for plotting. Hence it is extremely important for me to know the error bounds of these estimates and the range of values over which they are valid. 


Any help will be much appreciated. [Please read the background below before responding].

I am using: Scientific Linux 6.2 (Kernel Linux 2.6.32-220.23.1.el6.x86_64)


BACKGROUND:
=============
I hunted for this information a bit and have come across a file called specfun.c in the gnuplot /src directory. The file contains lines of code with:

ifdef ..., ifndef... and ifdef HAVE_function

I think that something like HAVE_LGAMMA indicates that if a function called LGAMMA exists then that one is preferred. 

BUT, WHERE is GNUPLOT looking for such pre-existing LGAMMA (and other function definitions)? 

[I dont understand what "HAVE_function" type references really mean. I searched a lot but could not really understand what it is doing and WHERE exactly is it looking so that I can go to that file and take a look at the algorithm used to define that function].

Also is LGAMMA the same as "log gamma" or is it "gamma in long format/type (i.e. double precision)". If it is "log gamma" then why is a call to gamma(x) referred to lgamma(x) without any 'exponentiation'? 

This link indicates that lgamma is log(gamma) and not just gamma in double-precision.

http://www.kernel.org/doc/man-pages/online/pages/man3/lgamma.3.html

But I am not sure if gnuplot is accessing this one or not. I also do not know WHERE to find this lgamma in my system files.

I also checked the GNU scientific library, but here gamma is referred to differently and not as lgamma:
http://www.gnu.org/software/gsl/manual/html_node/Gamma-Functions.html

Further, the GNU scientific library also has igamma defined:
http://www.gnu.org/software/gsl/manual/html_node/Incomplete-Gamma-Functions.html

BUT, the GNUPLOT specfun.c file does not seem to use this function even if it exists in the GNU scientific library. Anyone knows why? Is the gnuplot version of igamma more accurate than that in the GNU scientific library?

Please give me as specific info as possible (given my operating system..see above). Like if you say system file, then let me know whether you are referring to:

usr/lib/x86_64-redhat..... 

OR

usr/include/ etc..

And once again, I dont just want to know what it is doing, I want to know (and see for myself) what ALGORITHM it is accessing and if possible get some idea of what are the errors in estimation of these special functions and over what range of values for its arguments.

Thank you very much for your help in advance!
Kind regards,
Barun.

[toc] | [next] | [standalone]


#1315

Fromsfeam <sfeam@users.sourceforge.net>
Date2012-08-10 23:05 -0700
Message-ID<k04smg$s4t$1@dont-email.me>
In reply to#1314
boruun@gmail.com wrote:

> Can someone give me some pointers on how can I figure out:
> 
> a) what ALGORITHMS (files/codes either gnuplot specific or system
> specific) gnuplot is ACCESSING to calculate special functions like
> gamma, or lgamma, igamma, ibeta etc..... and WHERE are these
> algorithms/files located

The first step in building gnuplot from source is to run a configuration
script.  The configuration script tests for the availability of certain
math and other functions in the standard system libraries.  
The command is in the file configure.in and looks like this:

AC_CHECK_FUNCS(atexit memcpy memmove memset \
  on_exit bcopy bzero \
  setvbuf strerror strchr strrchr strstr \
  index rindex \
  erf erfc gamma lgamma \
  getcwd poll pclose popen select sleep stpcpy \
  strcspn strdup strndup strnlen strcasecmp stricmp strncasecmp strnicmp \
  sysinfo tcgetattr vfprintf doprnt usleep
)

For each function in the list, if it is found in a system library than
the library version is used.  If it is not found then gnuplot's internal
version is used.   Linux systems normally provide lgamma() in libm, so
that is almost certainly what your gnuplot is using.  Documentation for
this should be avaible from your system via the command
   man 3 lgamma

ibeta() is provided in specfun.c as you already noted.
gnuplot command "help ibeta" reports
gnuplot> help ibeta

 The `ibeta(p,q,x)` function returns the incomplete beta function of the real
 parts of its arguments. p, q > 0 and x in [0:1].  If the arguments are
 complex, the imaginary components are ignored.  The function is approximated by
 the method of continued fractions (Abramowitz and Stegun, 1964).
 The approximation is only accurate in the region x < (p-1)/(p+q-2). 

You can look in Abramowitz and Stegun (it's a standard reference book)
to see what accuracy is guaranteed for this approximation.

	Ethan


> 
> and,
> 
> b) (if possible) tell me (or guide me on how to find) how accurate are
> these estimates and over what range of values for their arguments.
> 
> I am using these functions in the "fit" command and not merely for
> plotting. Hence it is extremely important for me to know the error
> bounds of these estimates and the range of values over which they are
> valid.
> 
> 
> Any help will be much appreciated. [Please read the background below
> before responding].
> 
> I am using: Scientific Linux 6.2 (Kernel Linux
> 2.6.32-220.23.1.el6.x86_64)
> 
> 
> BACKGROUND:
> =============
> I hunted for this information a bit and have come across a file called
> specfun.c in the gnuplot /src directory. The file contains lines of
> code with:
> 
> ifdef ..., ifndef... and ifdef HAVE_function
> 
> I think that something like HAVE_LGAMMA indicates that if a function
> called LGAMMA exists then that one is preferred.
> 
> BUT, WHERE is GNUPLOT looking for such pre-existing LGAMMA (and other
> function definitions)?
> 
> [I dont understand what "HAVE_function" type references really mean. I
> [searched a lot but could not really understand what it is doing and
> [WHERE exactly is it looking so that I can go to that file and take a
> [look at the algorithm used to define that function].
> 
> Also is LGAMMA the same as "log gamma" or is it "gamma in long
> format/type (i.e. double precision)". If it is "log gamma" then why is
> a call to gamma(x) referred to lgamma(x) without any 'exponentiation'?
> 
> This link indicates that lgamma is log(gamma) and not just gamma in
> double-precision.
> 
> http://www.kernel.org/doc/man-pages/online/pages/man3/lgamma.3.html
> 
> But I am not sure if gnuplot is accessing this one or not. I also do
> not know WHERE to find this lgamma in my system files.
> 
> I also checked the GNU scientific library, but here gamma is referred
> to differently and not as lgamma:
> http://www.gnu.org/software/gsl/manual/html_node/Gamma-Functions.html
> 
> Further, the GNU scientific library also has igamma defined:
> http://www.gnu.org/software/gsl/manual/html_node/Incomplete-Gamma-Functions.html
> 
> BUT, the GNUPLOT specfun.c file does not seem to use this function
> even if it exists in the GNU scientific library. Anyone knows why? Is
> the gnuplot version of igamma more accurate than that in the GNU
> scientific library?
> 
> Please give me as specific info as possible (given my operating
> system..see above). Like if you say system file, then let me know
> whether you are referring to:
> 
> usr/lib/x86_64-redhat.....
> 
> OR
> 
> usr/include/ etc..
> 
> And once again, I dont just want to know what it is doing, I want to
> know (and see for myself) what ALGORITHM it is accessing and if
> possible get some idea of what are the errors in estimation of these
> special functions and over what range of values for its arguments.
> 
> Thank you very much for your help in advance!
> Kind regards,
> Barun.

[toc] | [prev] | [next] | [standalone]


#1325

Fromboruun@gmail.com
Date2012-08-14 12:39 -0700
Message-ID<12c24817-081e-430e-a275-15bb45908a7f@googlegroups.com>
In reply to#1314
No one in this group has any ideas/suggestions on this?

[toc] | [prev] | [next] | [standalone]


#1326

Fromboruun@gmail.com
Date2012-08-14 12:37 -0700
Message-ID<f679d1fa-5ff0-46a7-827b-1376002bc8e0@googlegroups.com>
In reply to#1314
No one in this group has any ideas/know-how/suggestions on this?







On Friday, August 10, 2012 10:34:54 PM UTC-5, (unknown) wrote:
> Can someone give me some pointers on how can I figure out:
> 
> 
> 
> a) what ALGORITHMS (files/codes either gnuplot specific or system specific) gnuplot is ACCESSING to calculate special functions like gamma, or lgamma, igamma, ibeta etc..... and WHERE are these algorithms/files located
> 
> 
> 
> and,
> 
> 
> 
> b) (if possible) tell me (or guide me on how to find) how accurate are these estimates and over what range of values for their arguments.
> 
> 
> 
> I am using these functions in the "fit" command and not merely for plotting. Hence it is extremely important for me to know the error bounds of these estimates and the range of values over which they are valid. 
> 
> 
> 
> 
> 
> Any help will be much appreciated. [Please read the background below before responding].
> 
> 
> 
> I am using: Scientific Linux 6.2 (Kernel Linux 2.6.32-220.23.1.el6.x86_64)
> 
> 
> 
> 
> 
> BACKGROUND:
> 
> =============
> 
> I hunted for this information a bit and have come across a file called specfun.c in the gnuplot /src directory. The file contains lines of code with:
> 
> 
> 
> ifdef ..., ifndef... and ifdef HAVE_function
> 
> 
> 
> I think that something like HAVE_LGAMMA indicates that if a function called LGAMMA exists then that one is preferred. 
> 
> 
> 
> BUT, WHERE is GNUPLOT looking for such pre-existing LGAMMA (and other function definitions)? 
> 
> 
> 
> [I dont understand what "HAVE_function" type references really mean. I searched a lot but could not really understand what it is doing and WHERE exactly is it looking so that I can go to that file and take a look at the algorithm used to define that function].
> 
> 
> 
> Also is LGAMMA the same as "log gamma" or is it "gamma in long format/type (i.e. double precision)". If it is "log gamma" then why is a call to gamma(x) referred to lgamma(x) without any 'exponentiation'? 
> 
> 
> 
> This link indicates that lgamma is log(gamma) and not just gamma in double-precision.
> 
> 
> 
> http://www.kernel.org/doc/man-pages/online/pages/man3/lgamma.3.html
> 
> 
> 
> But I am not sure if gnuplot is accessing this one or not. I also do not know WHERE to find this lgamma in my system files.
> 
> 
> 
> I also checked the GNU scientific library, but here gamma is referred to differently and not as lgamma:
> 
> http://www.gnu.org/software/gsl/manual/html_node/Gamma-Functions.html
> 
> 
> 
> Further, the GNU scientific library also has igamma defined:
> 
> http://www.gnu.org/software/gsl/manual/html_node/Incomplete-Gamma-Functions.html
> 
> 
> 
> BUT, the GNUPLOT specfun.c file does not seem to use this function even if it exists in the GNU scientific library. Anyone knows why? Is the gnuplot version of igamma more accurate than that in the GNU scientific library?
> 
> 
> 
> Please give me as specific info as possible (given my operating system..see above). Like if you say system file, then let me know whether you are referring to:
> 
> 
> 
> usr/lib/x86_64-redhat..... 
> 
> 
> 
> OR
> 
> 
> 
> usr/include/ etc..
> 
> 
> 
> And once again, I dont just want to know what it is doing, I want to know (and see for myself) what ALGORITHM it is accessing and if possible get some idea of what are the errors in estimation of these special functions and over what range of values for its arguments.
> 
> 
> 
> Thank you very much for your help in advance!
> 
> Kind regards,
> 
> Barun.

[toc] | [prev] | [next] | [standalone]


#1368

FromDr Engelbert Buxbaum <engelbert_buxbaum@hotmail.com>
Date2012-09-11 11:26 -0400
Message-ID<MPG.2ab9304085cc1492989696@News.Individual.DE>
In reply to#1326
In article <f679d1fa-5ff0-46a7-827b-1376002bc8e0@googlegroups.com>, 
boruun@gmail.com says...
> 
> No one in this group has any ideas/know-how/suggestions on this?
> On Friday, August 10, 2012 10:34:54 PM UTC-5, (unknown) wrote:
> > Can someone give me some pointers on how can I figure out:
> > 
> > a) what ALGORITHMS (files/codes either gnuplot specific or system specific) gnuplot is ACCESSING to calculate special functions like gamma, or lgamma, igamma, ibeta etc..... and WHERE are these algorithms/files located
> > and,
> > b) (if possible) tell me (or guide me on how to find) how accurate 
are these estimates and over what range of values for their arguments.

Your best source is probably the "Handbook of Mathematical Functions" by 
Abramowitz & Stegun, which is available free on several sites on the 
internet, e.g., http://dlmf.nist.gov/


Car (noun): erratically moving obstacle on the road

[toc] | [prev] | [next] | [standalone]


#1339

Fromhogney@gmail.com
Date2012-08-18 08:34 -0700
Message-ID<f5718a50-fb47-41de-ae71-a2acd94138bb@googlegroups.com>
In reply to#1314
I'm not too familiar with the gnuplot source, but I took a look. Yes, it involves a confusing spaghetti of name substitution. eval.c maps user input to internal names. Gamma function is defined in specfun.c from line 296 to line 553.

[toc] | [prev] | [next] | [standalone]


#1340

Fromsfeam <sfeam@users.sourceforge.net>
Date2012-08-18 10:56 -0700
Message-ID<k0okvp$ard$1@dont-email.me>
In reply to#1339
hogney@gmail.com wrote:

> I'm not too familiar with the gnuplot source, but I took a look. Yes,
> it involves a confusing spaghetti of name substitution. eval.c maps
> user input to internal names. Gamma function is defined in specfun.c
> from line 296 to line 553.

That code is only a last resort fallback that is compiled if the
system does not provide a gamma function in the math library.
Normally "gamma(x)" from the gnuplot command line will use the lgamma() 
function from the system library libm.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.graphics.apps.gnuplot


csiph-web