# Increase free parameters accuracy for fits with 20 parameters

**URL:** <https://root-forum.cern.ch/t/increase-free-parameters-accuracy-for-fits-with-20-parameters/50273>\
**Category:** Newbie\
**Tags:** root\
**Created:** [June 4, 2022, 6:21pm UTC](https://root-forum.cern.ch/t/increase-free-parameters-accuracy-for-fits-with-20-parameters/50273 "2022-06-04T18:21:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nyx](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@Nyx](https://root-forum.cern.ch/u/Nyx)\
**Post date:** [June 4, 2022, 6:21pm UTC](https://root-forum.cern.ch/t/increase-free-parameters-accuracy-for-fits-with-20-parameters/50273/1 "2022-06-04T18:21:27Z")

</div>

I am trying to use a fitting function that consists of a sum of 20 cosine functions of the form `[0]*exp(-x/[1])*( 1.0+[2]*cos([3]*x-[j]))`. The order of magnitude for the parameters are 10^5 for `p0`, 10^1 for `p1`, 10^-1 for `p2`, 10^0 for `p3`, and 10^-3 for `p[i]`. The fit converges, but it strongly depends on the initial values for `p[i]` parameters.  
If my initial guess is 0 for all of the parameters `p[i]` the result is:

```auto
FCN=4750.84 FROM MIGRAD STATUS=CONVERGED 2101 CALLS 2102 TOTAL
                     EDM=5.58924e-08 STRATEGY= 1 ERROR MATRIX UNCERTAINTY 0.9 per cent

```

But if my initial guess is closer to the real values, the result is

```auto
FCN=4712.66 FROM MIGRAD STATUS=CONVERGED 1835 CALLS 1836 TOTAL
                     EDM=9.18336e-07 STRATEGY= 1 ERROR MATRIX UNCERTAINTY 0.1 per cent

```

Is there a way to make MIGRAD get closer to the real values of p[i] without stopping the minimizer algorithm?

---

<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 4, 2022, 7:02pm UTC](https://root-forum.cern.ch/t/increase-free-parameters-accuracy-for-fits-with-20-parameters/50273/2 "2022-06-04T19:02:33Z")

</div>

Try to modify your function so that all parameters are of the order of 1, e.g.:  
`([0]/1.e5)*exp(-x/([1]/1.e1))*(1.+([2]/1.e-1)*cos(([3])*x-([j]/1.e-3)))`

---

<div class="post-metadata">

**Author:** ![Nyx](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@Nyx](https://root-forum.cern.ch/u/Nyx)\
**Post date:** [June 4, 2022, 7:47pm UTC](https://root-forum.cern.ch/t/increase-free-parameters-accuracy-for-fits-with-20-parameters/50273/3 "2022-06-04T19:47:32Z")

</div>

It does converge, but the values are wrong again:

```auto
 FCN=7.20178e+15 FROM MIGRAD STATUS=CONVERGED 1272 CALLS 1273 TOTAL
                     EDM=2.83846e-11 STRATEGY= 1 ERROR MATRIX UNCERTAINTY 0.4 per cent

```
