2

I am trying to find the fit of an equation to some data and mathematica thinks there is a list of imaginary values. My data is all real positive number.

FindFit[Data, z*(x + shift)^2*Exp[y*Sqrt[x + shift]], {z, y, shift}, x]

FindFit::nrlnum: The function value {-122.656+0. I,-88.6481+0. I,-50.2375+0. I,-25.8042+0. I,-10.6896+0. I,<<42>>,6.49683 +0. I,5.78851 +0. I,1.22054 +0. I,<<450>>} is not a list of real numbers with dimensions {500} at {z,y,shift} = {1.40756,1.57721,-0.273062}. >>

The issue only happens when I add the shift variable.

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
user16404
  • 21
  • 1

2 Answers2

1

You might want to limit "shift" to positive only? Otherwise your function can be complex? I am guessing the value of "shift" Mathematica obtained from FindFit is negative.

user29165
  • 565
  • 3
  • 10
1

I've noticed that sometimes I get some small imaginary components due to error etc. You may want to use the Chop[] function to kill anything like that.