- publishing free software manuals
 GNU Scientific Library Reference Manual - Third Edition (v1.12) by M. Galassi, J. Davies, J. Theiler, B. Gough, G. Jungman, P. Alken, M. Booth, F. RossiPaperback (6"x9"), 592 pages, 60 figuresISBN 0954612078RRP £24.95 (\$39.95)

7.33 Examples

The following example demonstrates the use of the error handling form of the special functions, in this case to compute the Bessel function J_0(5.0),

```#include <stdio.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_sf_bessel.h>

int
main (void)
{
double x = 5.0;
gsl_sf_result result;

double expected = -0.17759677131433830434739701;

int status = gsl_sf_bessel_J0_e (x, &result);

printf ("status  = %s\n", gsl_strerror(status));
printf ("J0(5.0) = %.18f\n"
"      +/- % .18f\n",
result.val, result.err);
printf ("exact   = %.18f\n", expected);
return status;
}
```

Here are the results of running the program,

```\$ ./a.out
status  = success
J0(5.0) = -0.177596771314338292
+/-  0.000000000000000193
exact   = -0.177596771314338292
```

The next program computes the same quantity using the natural form of the function. In this case the error term result.err and return status are not accessible.

```#include <stdio.h>
#include <gsl/gsl_sf_bessel.h>

int
main (void)
{
double x = 5.0;
double expected = -0.17759677131433830434739701;

double y = gsl_sf_bessel_J0 (x);

printf ("J0(5.0) = %.18f\n", y);
printf ("exact   = %.18f\n", expected);
return 0;
}
```

The results of the function are the same,

```\$ ./a.out
J0(5.0) = -0.177596771314338292
exact   = -0.177596771314338292
```
 ISBN 0954612078 GNU Scientific Library Reference Manual - Third Edition (v1.12) See the print edition