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


Groups > comp.graphics.apps.gnuplot > #1315

Re: Special functions in gnuplot

From sfeam <sfeam@users.sourceforge.net>
Newsgroups comp.graphics.apps.gnuplot
Subject Re: Special functions in gnuplot
Followup-To comp.graphics.apps.gnuplot
Date 2012-08-10 23:05 -0700
Organization gnuplot development team
Message-ID <k04smg$s4t$1@dont-email.me> (permalink)
References <1694fa1b-c5e4-4561-8594-40d67337d065@googlegroups.com>

Followups directed to: comp.graphics.apps.gnuplot

Show all headers | View raw


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.

Back to comp.graphics.apps.gnuplot | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

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

csiph-web