# Wrong convolution of 2 functions

**URL:** <https://root-forum.cern.ch/t/wrong-convolution-of-2-functions/26205>\
**Category:** ROOT\
**Created:** [September 13, 2017, 2:24pm UTC](https://root-forum.cern.ch/t/wrong-convolution-of-2-functions/26205 "2017-09-13T14:24:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![FoxWise](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/foxwise/32/37588_2.png) [@FoxWise](https://root-forum.cern.ch/u/FoxWise)\
**Post date:** [September 13, 2017, 2:24pm UTC](https://root-forum.cern.ch/t/wrong-convolution-of-2-functions/26205/1 "2017-09-13T14:24:27Z")

</div>

Dear root users, I have a strange calculation of convolutions of 2 defined functions gaus and exponent.  
The result graph in some places randomly has 0 value… And I have some parody on the exponent. See below.

 ![results](https://root-forum.cern.ch/uploads/default/original/2X/8/88dbdb982016418dc88c98cfa715b11a566835b0.png)  
So I cant understand how to solve it. I have tried another method of making Convolution through TF1Convolution but it gives the same results… Can someone help me with this one? I will really appreciate that.  
Have a nice day, all! [Besh.cxx](https://root-forum.cern.ch/uploads/default/original/2X/2/2c2b990b150b5b2c3d72d6f7b60be79747ced16d.cxx) (2.5 KB)

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [September 13, 2017, 3:12pm UTC](https://root-forum.cern.ch/t/wrong-convolution-of-2-functions/26205/2 "2017-09-13T15:12:12Z")

</div>

I think @moneta should be able to help you…

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [September 13, 2017, 6:49pm UTC](https://root-forum.cern.ch/t/wrong-convolution-of-2-functions/26205/3 "2017-09-13T18:49:21Z")

</div>

I blame the ROOT’s “Integral” method, so try with FWHM=10 …

> [@Convolution of two TF1](https://root-forum.cern.ch/t/convolution-of-two-tf1/23625/8):
>
> If you do not like this plot, you can also try: ROOT::Math::IntegratorOneDimOptions::SetDefaultIntegrator("Gauss"); TF1Convolution \*f\_conv = new TF1Convolution(f1, f1, emin, emax, false); You will then have four different curves, so you should be able to pick one for you exclamation [:mrgreen:] Well, you could try all different available ROOT’s “1-dim integrators”: “Gauss”, “GaussLegendre”, “Adaptive”, “AdaptiveSingular” and “NonAdaptive”. wink Seven different curves should be a “good m…

> [@Creating TF1 from TGraph](https://root-forum.cern.ch/t/creating-tf1-from-tgraph/10522/10):
>
> Why are you still complaining question [[-(] You now have three different integral values, so you can choose the one you like the most exclamation [:mrgreen:] Using “ROOT::Math::IntegratorOneDimOptions::SetDefaultIntegrator(…);”, you could try all different available ROOT’s “1-dim integrators”: “Gauss”, “GaussLegendre”, “Adaptive”, “AdaptiveSingular” and “NonAdaptive”. wink You will then have six different integral values to choose from exclamation [:mrgreen:] BTW. ROOT’s “integr…

> [@Why is my integral zero?](https://root-forum.cern.ch/t/why-is-my-integral-zero/21999/3):
>
> I don’t think your calls to “Integral” are wrong. I guess it’s a deficiency in ROOT. It’s the “efficiency” / “efficiencyF” function which fools ROOT. It’s value “jumps” between 0 and 1 and the current “integrator” is known to misbehave in such cases. See also, for example: [Simple Integral](https://root-forum.cern.ch/t/simple-integral/21760/2) Sometimes you can try to “hide” this problem if you increase the number of points … for each of your functions try to add: SomeTF2-\>SetNpx(1000); SomeTF2-\>SetNpy(1000); But I wouldn’t really trust the res…

> [@Integral of 2D function](https://root-forum.cern.ch/t/integral-of-2d-function/15146/2):
>
> A very brutal fix (works just in this case; in another cases you’ll need to “tune” the “number of points”): g2D1-\>SetNpx(700); g2D1-\>SetNpy(700); // “number of points” \>= 700 I guess the problem is that your “g2dBIF1” is not smooth at the “edge” given by the “radius” (i.e. it’s not differentiable there) and the “numerical integrator” gets fooled (there’s a “jump” from about 8000 to 0). That’s not a problem for your “g2dBIF2” because the “radius” is much larger and the “jump” at the “edge” is …

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [September 27, 2017, 6:58pm UTC](https://root-forum.cern.ch/t/wrong-convolution-of-2-functions/26205/4 "2017-09-27T18:58:31Z")

</div>

Closed on September 27, 2017, 6:58pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
