0
$\begingroup$

I am attempting to fit a function with three free parameters to a set of data points. I get the error: "Power: Infinite expression 1/0 encountered."

The function in question is:

fit = 
  (Exp[-x* (a + b + c)]* 
    (-1 + Exp[(x* c)]* a* b* 
      (Exp[x* (a + b)]* (a - b) + Exp[x* (b + c)]* (b - c) + 
         Exp[x* (a + c)]* (-a + c)))) /
      ((a - b)* (a - c)* (b - c))

I believe this could be fixed by telling Mathematica to assume that a, b, and c are positive and a != b != c. However it seems that you can't give assumptions to FindFit. Any ideas on how to fix this or work around it?

Context:

data = 
  {{2, 1.00309*10^-6}, {7, 0.004429942}, {20, 
   1.10643*10^-10}, {40, 0.003376122}, {60, 0.012847188}, {85, 
   0.053338127}, {300, 0.226328628}}

FindFit[data, fit, {a, b, c}, x]

Amended to

FindFit[data, fit, {{a, .1}, {b, .11}, {c, .12}}, x]

which fixed the issue.

$\endgroup$
7
  • 4
    $\begingroup$ Please provide a minimal working example needed to reproduce your problem. p.s. e is not E. $\endgroup$
    – Kuba
    Commented Jul 24, 2017 at 20:06
  • 1
    $\begingroup$ Try giving FindFit unequal initial values of {a,b,c} by specifying the parameters as '{{a,1}, {b,2}, {c,3}}`. Some sets of unequal constants may work better than others. $\endgroup$
    – LouisB
    Commented Jul 24, 2017 at 20:47
  • $\begingroup$ Please change the title to something that resembles the question (or justify the relationship of the title to what is given in the text). $\endgroup$
    – JimB
    Commented Jul 25, 2017 at 0:42
  • $\begingroup$ The online documentation does state that FindFit can use constraints: FindFit[data,{expr,cons},pars,vars]. However, one can't use != in the constraints. Your best bet is to use the suggestion by @LouisB. $\endgroup$
    – JimB
    Commented Jul 25, 2017 at 2:46
  • 1
    $\begingroup$ Better that FindFit throw an exception than FindException throw a fit... $\endgroup$ Commented Jul 26, 2017 at 16:08

0

Your Answer

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

Browse other questions tagged or ask your own question.