| GNU Scientific Library Reference Manual - Revised Second Edition (v1.8) by M. Galassi, J. Davies, J. Theiler, B. Gough, G. Jungman, M. Booth, F. Rossi Paperback (6"x9"), 636 pages, 60 figures ISBN 0954161734 RRP £24.99 ($39.99) |
2.1 An Example Program
The following short program demonstrates the use of the library by computing the value of the Bessel function J_0(x) for x=5,
#include <stdio.h>
#include <gsl/gsl_sf_bessel.h>
int
main (void)
{
double x = 5.0;
double y = gsl_sf_bessel_J0 (x);
printf ("J0(%g) = %.18e\n", x, y);
return 0;
}
If GSL is installed in its default location, the command to compile this program and link to the necessary libraries is,
$ gcc -Wall example.c -lgsl -lgslcblas -lm
The result of running the program is shown below, and should be correct to double-precision accuracy,
J0(5) = -1.775967713143382920e-01
The compilation and linking procedure may vary on different platforms--full details are given in the following sections.
| ISBN 0954161734 | GNU Scientific Library Reference Manual - Revised Second Edition (v1.8) | See the print edition |