
Introduction to Dynamical Systems 271
7 #include <math.h>
8 #include <gsl/gsl_integration.h>
9 double myf (double x, void
*
params) {
10 return (exp(x));
11 }
12 int main (void) {
13 gsl_integration_workspace
*
w
14 = gsl_integration_workspace_alloc (1000);
15 double intres, error;
16 double exactint = 1.718282;
17 double alpha = 1.0;
18 double xa = 0.0; // integration interval
19 double xb = 1.0;
20 int key = 3; // integration rule: Gauss31
21 gsl_function F;
22 F.function = &myf;
23 F.params = α
24 gsl_integration_qag (&F, xa, xb, 0.0, 1e-7, 1000, key,
25 w, &intres, &error);
26 printf ("Computed integral of f(x) = eˆx: % .15f\n", intres);
27 printf ("exact ...