# Next question to TF1

**URL:** <https://root-forum.cern.ch/t/next-question-to-tf1/2247>\
**Category:** ROOT\
**Created:** [July 31, 2005, 4:47pm UTC](https://root-forum.cern.ch/t/next-question-to-tf1/2247 "2005-07-31T16:47:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![billybob](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@billybob](https://root-forum.cern.ch/u/billybob)\
**Post date:** [July 31, 2005, 4:47pm UTC](https://root-forum.cern.ch/t/next-question-to-tf1/2247/1 "2005-07-31T16:47:20Z")

</div>

This code works:

TF1 \*f1 = new TF1(“myfunc”,“TMath::Gaus(x,0,2)”,-5,5);

f1-\>Draw();

TF1 \*f1t = new TF1(“myfunc”,“TMath::Gaus(x,0,5)”,-5,5);

f1t-\>Draw(“SAME”);

BUT this code doesn’t :

TF1 \*f1 = new TF1(“myfunc”,Gfunction1,-5,5,2);  
f1-\>SetParameters(2,0);

f1-\>Draw();

TF1 \*f2 = new TF1(“myfunc”,Gfunction2,-5,5,2);  
f2-\>SetParameters(5,0);

f2-\>Draw(“SAME”);

with some functions like these:

Double\_t Gfunction1(Double\_t \*x, Double\_t \*para)  
{  
Double\_t x1 =x[0];

Double\_t gf1 = 1/(TMath::Sqrt(2_TMath::Pi())para[0]) \* TMath::Exp(-0.5((x1-para[1])/para[0])_((x1-para[1])/para[0]));

return gf1;  
}

Double\_t Gfunction2(Double\_t \*x, Double\_t \*parb)  
{  
Double\_t x2 =x[0];

Double\_t gf2 = 1/(TMath::Sqrt(2_TMath::Pi())parb[0]) \* TMath::Exp(-0.5((x2-parb[1])/parb[0])_((x2-parb[1])/parb[0]));

return gf2;  
}

This really drives me nuts !! Please help !

---

<div class="post-metadata">

**Author:** ![brun](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/b9e5f3/32.png) [@brun](https://root-forum.cern.ch/u/brun)\
**Post date:** [July 31, 2005, 6:54pm UTC](https://root-forum.cern.ch/t/next-question-to-tf1/2247/2 "2005-07-31T18:54:14Z")

</div>

You should not give the same name to two different functions.  
Replace  
TF1 \*f2 = new TF1(“myfunc”,Gfunction2,-5,5,2);  
by  
TF1 \*f2 = new TF1(“myfunc2”,Gfunction2,-5,5,2);

Rene

---

<div class="post-metadata">

**Author:** ![billybob](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@billybob](https://root-forum.cern.ch/u/billybob)\
**Post date:** [July 31, 2005, 9:42pm UTC](https://root-forum.cern.ch/t/next-question-to-tf1/2247/3 "2005-07-31T21:42:47Z")

</div>

Hm…‘cough’ i should have seen this. Thank you Rene !
