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.
e
is notE
. $\endgroup$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$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$FindFit
throw an exception thanFindException
throw a fit... $\endgroup$