3
<title>An Example Program - GNU Scientific Library -- Reference Manual</title>
4
<meta http-equiv="Content-Type" content="text/html">
5
<meta name="description" content="GNU Scientific Library -- Reference Manual">
6
<meta name="generator" content="makeinfo 4.8">
7
<link title="Top" rel="start" href="index.html#Top">
8
<link rel="up" href="Using-the-library.html#Using-the-library" title="Using the library">
9
<link rel="next" href="Compiling-and-Linking.html#Compiling-and-Linking" title="Compiling and Linking">
10
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
12
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 The GSL Team.
14
Permission is granted to copy, distribute and/or modify this document
15
under the terms of the GNU Free Documentation License, Version 1.2 or
16
any later version published by the Free Software Foundation; with the
17
Invariant Sections being ``GNU General Public License'' and ``Free Software
18
Needs Free Documentation'', the Front-Cover text being ``A GNU Manual'',
19
and with the Back-Cover Text being (a) (see below). A copy of the
20
license is included in the section entitled ``GNU Free Documentation
23
(a) The Back-Cover Text is: ``You have freedom to copy and modify this
24
GNU Manual, like GNU software.''-->
25
<meta http-equiv="Content-Style-Type" content="text/css">
26
<style type="text/css"><!--
27
pre.display { font-family:inherit }
28
pre.format { font-family:inherit }
29
pre.smalldisplay { font-family:inherit; font-size:smaller }
30
pre.smallformat { font-family:inherit; font-size:smaller }
31
pre.smallexample { font-size:smaller }
32
pre.smalllisp { font-size:smaller }
33
span.sc { font-variant:small-caps }
34
span.roman { font-family:serif; font-weight:normal; }
35
span.sansserif { font-family:sans-serif; font-weight:normal; }
41
<a name="An-Example-Program"></a>
42
Next: <a rel="next" accesskey="n" href="Compiling-and-Linking.html#Compiling-and-Linking">Compiling and Linking</a>,
43
Up: <a rel="up" accesskey="u" href="Using-the-library.html#Using-the-library">Using the library</a>
47
<h3 class="section">2.1 An Example Program</h3>
49
<p>The following short program demonstrates the use of the library by
50
computing the value of the Bessel function J_0(x) for x=5,
52
<pre class="example"><pre class="verbatim"> #include <stdio.h>
53
#include <gsl/gsl_sf_bessel.h>
59
double y = gsl_sf_bessel_J0 (x);
60
printf ("J0(%g) = %.18e\n", x, y);
64
<p class="noindent">The output is shown below, and should be correct to double-precision
67
<pre class="example"><pre class="verbatim"> J0(5) = -1.775967713143382920e-01
69
<p class="noindent">The steps needed to compile this program are described in the following