help-gsl
[Top][All Lists]

## [Help-gsl] QAG Integration with variable parameters

 From: Anders Misfeldt Subject: [Help-gsl] QAG Integration with variable parameters Date: Tue, 14 Sep 2004 13:22:20 +0200 User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040803

```Hi,

```
I'm using gsl_integration_qags to calculate some integrals, but I've encountered a problem I can't seem to find out.
```
I want to calculate the following integral

Int (from 0 to 100) x^3/(exp(x-eps) + 1) dx

```
I'm trying to make multiple calculations for different values of a, but how can I call gsl_integration_qags with a different a? As until now I've just made the variable a in my function, but I'm making a for statement, so that I get multiple results out. And I'm kinda stuck.
```
Can someone help me out here?

My code is:

#include <stdio.h>
#include <math.h>
#include <gsl/gsl_integration.h>
#define real double

real calls = 0;

real f (real x, void * params) {
real alpha = *(real *) params;
calls+=1;
return x*x*x/(exp(x-eps)+1);
}

int main(void) {
gsl_integration_workspace * w
= gsl_integration_workspace_alloc(100000);
real res,a,b,acc,error,expected,alpha;
int key,i;
size_t limit;

acc=0.00001;
expected=0.339047; //disregard this
alpha=1.0;
limit=100000;
key=1;
calls=0;

gsl_function F;
F.function=&f;
F.params=&alpha;

a=0;
b=100;

for (i=0;i<=20;i++) {
eps=i;
gsl_integration_qags(&F,a,b,acc,acc,limit,w,&res,&error);
printf("%g \n", res);
}
return 0;
}

```