# Re: Bug or feature?

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Wed, 26 Oct 2005 12:46:23 +0200 (MEST)

Art,

See comments in the example below. If you execute the script, you should get:

```g->Integral(0,5)               = 1.25331
g->Integral(0,1000)            = 1.25319
g->IntegralFast(n,x,w,0,5)     = 1.25331
g->IntegralFast(n,x,w,0,1000)  = 1.25331
g->IntegralFast(n,x,w,0,10000) = 1.25331
g->IntegralFast(n,x,w,0,100000)= 1.253

```

Rene Brun

void gint() {

TF1 *g = new TF1("g","gaus",-5,5);
g->SetParameters(1,0,1);
//default gaus integration method uses 6 points     //not suitable to intregrate on a large domain     double r1 = g->Integral(0,5);
double r2 = g->Integral(0,1000);

//try with user directives computing more points

```    Int_t np = 1000;
double *x=new double[np];
double *w=new double[np];
```

g->CalcGaussLegendreSamplingPoints(np,x,w,1e-15);
```    double r3 = g->IntegralFast(np,x,w,0,5);
double r4 = g->IntegralFast(np,x,w,0,1000);
double r5 = g->IntegralFast(np,x,w,0,10000);
double r6 = g->IntegralFast(np,x,w,0,100000);
printf("g->Integral(0,5)               = %g\n",r1);
printf("g->Integral(0,1000)            = %g\n",r2);
printf("g->IntegralFast(n,x,w,0,5)     = %g\n",r3);
printf("g->IntegralFast(n,x,w,0,1000)  = %g\n",r4);
```
printf("g->IntegralFast(n,x,w,0,10000) = %g\n",r5);     printf("g->IntegralFast(n,x,w,0,100000)= %g\n",r6);     delete [] x;
delete [] w;
}

On Tue, 25
Oct 2005, Arthur E. Snyder wrote:

>
> I find if I do an integral of a positive definite function I get 0 if the
> limits are large. E.g., a simple 1 sigma Gaussian:
>
> root  g->Integral(0,5)
> (Double_t)6.26657068657750171e-01
> root  g->Integral(0,1000)
> (Double_t)5.47544282673530046e-24
> root  g->Integral(0,10000)
> (Double_t)0.00000000000000000e+00
> root 
>
> This is not a very sensible or convenient behavior. It appears if the
> limits are set very large the interval used in the nummerical intergration
> are so large that the non-zero regions of the function may be missed
> entirely.
>
> A bug or a feature? Certainly a nuissance when I'm trying to convolute a
> Gaussian with some other function using this numerical integration.
>
> Is there perhaps some way to avoid this problem?
>
> -Art S.
>
> A.E. Snyder, Group EC \!c*p?/
> SLAC Mail Stop #95 ((. .))
> Box 4349 |
> Stanford, Ca, USA, 94309 '\|/`
> e-mail:snyder_at_slac.stanford.edu o
> phone:650-926-2701 _
> http://www.slac.stanford.edu/~snyder BaBar
> FAX:650-926-2657 Collaboration
>
Received on Wed Oct 26 2005 - 12:46:33 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:13 MET