#include<stdio.h>
#include<stdio.h>
#include<math.h>
#include<gsl/gsl_errno.h>
#include<gsl/gsl_integration.h>

double g(double x, void *v){return exp(-x*x);}

int main(){
  double result,err,xmin,xmax,tol;
  gsl_integration_workspace *work;
  gsl_function F;

  work=gsl_integration_workspace_alloc(100000);
  F.function=g;
  F.params=NULL;
  xmin=0;
  xmax=10;
  tol=1e-4;

  gsl_integration_qag(&F,xmin,xmax,0,tol,100000,GSL_INTEG_GAUSS15,
                      work,&result,&err);

  printf("Integral is %f\n",result);
  gsl_integration_workspace_free(work);
  return(0);
}
