2
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ Where is your data? $\endgroup$
    – Apple
    Jul 9, 2014 at 13:46

2 Answers 2

1
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ No need to guess, the error message shows shift = -0.273062. $\endgroup$
    – m_goldberg
    Jul 9, 2014 at 14:46
1
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.