# Integrating a function using TF1

**URL:** <https://root-forum.cern.ch/t/integrating-a-function-using-tf1/47691>\
**Category:** Newbie\
**Created:** [November 16, 2021, 7:38pm UTC](https://root-forum.cern.ch/t/integrating-a-function-using-tf1/47691 "2021-11-16T19:38:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SarahHamad](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/8797f3/32.png) [@SarahHamad](https://root-forum.cern.ch/u/SarahHamad)\
**Post date:** [November 16, 2021, 7:38pm UTC](https://root-forum.cern.ch/t/integrating-a-function-using-tf1/47691/1 "2021-11-16T19:38:37Z")

</div>

I am trying to plot a function f(t)=f1(t)/f2(t) where f1 is a gaussian and f2 contains an integral. How can I use TF1 to integrate the following function from 0 to t:  
`a*exp(-0.5*((x-280)/10)**2)) dx`

Thank 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:** [November 16, 2021, 7:42pm UTC](https://root-forum.cern.ch/t/integrating-a-function-using-tf1/47691/2 "2021-11-16T19:42:40Z")

</div>

Looks like you wanted to play with: [`TMath::Erf((t - 280.) / 10. / TMath::Sqrt2())`](https://root.cern/doc/master/namespaceTMath.html#a44e82992cba4684280c72679f0f39adc)

E.g., [the integral from “-infinity” to “t”](https://en.wikipedia.org/wiki/Normal_distribution):  
`a * 10. * (TMath::Erf((t - 280.) / 10. / TMath::Sqrt2()) + 1.) * TMath::Sqrt(TMath::PiOver2())`

---

<div class="post-metadata">

**Author:** ![SarahHamad](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/8797f3/32.png) [@SarahHamad](https://root-forum.cern.ch/u/SarahHamad)\
**Post date:** [November 17, 2021, 3:02pm UTC](https://root-forum.cern.ch/t/integrating-a-function-using-tf1/47691/3 "2021-11-17T15:02:04Z")

</div>

Yes exactly! Thank you so much for your help.

---

<div class="post-metadata">

**Author:** ![SarahHamad](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/8797f3/32.png) [@SarahHamad](https://root-forum.cern.ch/u/SarahHamad)\
**Post date:** [November 17, 2021, 3:25pm UTC](https://root-forum.cern.ch/t/integrating-a-function-using-tf1/47691/5 "2021-11-17T15:25:31Z")

</div>

Is the 10, sqrt (piover2) added because we did a change of variable in the integral, or was it to cancel out the factors of the normal distribution? and why did we add the 1?

Thank you
