# Fitting 5p function to pseudodata

**URL:** <https://root-forum.cern.ch/t/fitting-5p-function-to-pseudodata/40507>\
**Category:** Newbie\
**Created:** [July 19, 2020, 2:53am UTC](https://root-forum.cern.ch/t/fitting-5p-function-to-pseudodata/40507 "2020-07-19T02:53:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edward\_Finkelstein](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/edward_finkelstein/32/20070_2.png) [@Edward\_Finkelstein](https://root-forum.cern.ch/u/Edward_Finkelstein)\
**Post date:** [July 19, 2020, 2:53am UTC](https://root-forum.cern.ch/t/fitting-5p-function-to-pseudodata/40507/1 "2020-07-19T02:53:27Z")

</div>

Hello,  
I am trying to fit a five parameter function to pseudo data, but for some reason I get the warning  
`Warning in <ROOT::Math::ROOT::Math::GausIntegrator>: Failed to reach the desired tolerance ; maxtol = 1e-09`  
I think it has to do with the function I am using. I attached the function and the file.  
 ![Screen Shot 2020-07-18 at 6.09.14 PM](https://root-forum.cern.ch/uploads/default/original/3X/5/7/5746b015a3b30328e63df92e9b36313d46005c36.png)  
[para\_five.cxx](https://root-forum.cern.ch/uploads/short-url/uX08fu6LXdVWc5uUCO8WfZAFNJO.cxx) (upload://cs4ZfvQyPBAxP4MCmSg2jkLWX7U.png)  
\_ROOT Version: 6.23/01

---

<div class="post-metadata">

**Author:** ![smgrig](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/smgrig/32/19464_2.png) [@smgrig](https://root-forum.cern.ch/u/smgrig)\
**Post date:** [July 19, 2020, 9:30am UTC](https://root-forum.cern.ch/t/fitting-5p-function-to-pseudodata/40507/2 "2020-07-19T09:30:00Z")

</div>

Your function is singular at x=0 and invalid at x\>1. Define it in the interval say 1.e-9\<=x\<=1

---

<div class="post-metadata">

**Author:** ![smgrig](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/smgrig/32/19464_2.png) [@smgrig](https://root-forum.cern.ch/u/smgrig)\
**Post date:** [July 19, 2020, 9:35am UTC](https://root-forum.cern.ch/t/fitting-5p-function-to-pseudodata/40507/3 "2020-07-19T09:35:23Z")

</div>

Use

```auto
TF1 *parabola_5 = new TF1("para_five","[0]*((1-x)**[1])*x**([2]+[3]*TMath::Log(x)+[4]*(TMath::Log(x))^2)",1.e-9,1);
parabola_5->SetParameters(a,b,c,d,f);
parabola_5->SetParNames("a","b","c","d","f");

```

and

```auto
for (int i=1; i<=5000;++i) histo.Fill(parabola_5->GetRandom(1.e-9,1));

```
