# How do I make my poln fit go through the origin?

**URL:** <https://root-forum.cern.ch/t/how-do-i-make-my-poln-fit-go-through-the-origin/34756>\
**Category:** Newbie\
**Created:** [June 21, 2019, 7:26pm UTC](https://root-forum.cern.ch/t/how-do-i-make-my-poln-fit-go-through-the-origin/34756 "2019-06-21T19:26:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Skip](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/skip/32/16865_2.png) [@Skip](https://root-forum.cern.ch/u/Skip)\
**Post date:** [June 21, 2019, 7:26pm UTC](https://root-forum.cern.ch/t/how-do-i-make-my-poln-fit-go-through-the-origin/34756/1 "2019-06-21T19:26:36Z")

</div>

Hello, ROOTers! I have a very simple question that I imagine has a very simple solution, but I can’t seem to figure it out myself.

I have a polynomial fit I’m doing, and I would like to make it go through the origin. The online tutorials say to use the “B” option, but I have no idea how to use it. I have right now:

```auto
TFitResultPtr r = hEPDRefMult[i]->Fit(Form("pol%d",polyFit),"S")

```

The polyFit stuff is because I’m using a different degree polynomial for different values of [i] (works fine).  
So, how do I demand that the p0 coefficient is 0.0?

Thanks!

---

<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:** [June 21, 2019, 7:34pm UTC](https://root-forum.cern.ch/t/how-do-i-make-my-poln-fit-go-through-the-origin/34756/2 "2019-06-21T19:34:14Z")

</div>

Try:

```auto
TF1 *f = ((TF1*)(gROOT->GetFunction(Form("pol%d", polyFit))));
f->SetParameters(0., ... ); // set "reasonable" initial values for all parameters
f->FixParameter(0, 0.); // "p0"
TFitResultPtr r = hEPDRefMult[i]->Fit(f, "S");
f->ReleaseParameter(0); // "p0"

```

---

<div class="post-metadata">

**Author:** ![Skip](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/skip/32/16865_2.png) [@Skip](https://root-forum.cern.ch/u/Skip)\
**Post date:** [June 21, 2019, 7:49pm UTC](https://root-forum.cern.ch/t/how-do-i-make-my-poln-fit-go-through-the-origin/34756/3 "2019-06-21T19:49:01Z")

</div>

That did the trick; thank you!
