# Increase free parameters accuracy for fits with 20 parameters

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:

``````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

``````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?

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)))`

It does converge, but the values are wrong again:

`````` 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
``````