This patchset is a proof-of-principle demonstration of detecting special functions (the Airy function in this case) in an external shared library at configuration time. I used -libgsl (the gnu scientific library) because it is easily available on linux systems. If you have libgsl.so installed then running ./configure will set the flag HAVE_GSL, which in turn controls compilation of new table entries in eval.c and wrapper code in new files bessel.c and bessel.h. The wrapper routines in src/bessel.c are called from gnuplot as
Bessel_J0(x) Bessel_J1(x) Bessel_Y0(x) Bessel_Y1(x) Bessel_Jn(x) Bessel_Yn(x)
Note that for the purpose of demonstration the functions pulled from gsl have distinct names from the existing gnuplot functions besj0(), airy(), etc. This allows you to compare the two versions directly as in the attached PDF files.
The immediate motivation for this trial was an observation by Alex van der Spek that the Airy Ai function currently in gnuplot's specfun.c has low precision (up to 2% relative error). You can see this in the comparison plot airy.pdf. The other functions I tried have comparable precision in the gnuplot and libgsl versions. It is worth noting that libgsl provides many functions not currently in gnuplot. This is illustrated by wrappers for the Riemann zeta function.
The use of libgsl in particular has a number of disadvantages, so if there is interest in this approach I think it would be better to aim for linking to some other library. Alex suggested netlib ( http://www.netlib.org/ ). This looks like it would be a better choice except for the fact that it isn't currently packaged for the common linux repositories. Can anyone offer other suggestions?
Log in to post a comment.