I have data
data = {{5, 580}, {10, 570}, {15, 565}, {20, 562}, {25, 560}};
I have fitting function
A[x_] := a*Sqrt[1 - x/b]
I expect value a = 600, b = 300. Using
FindFit[data, A[x], {a, b}, x]
I instead error message:
"indFit::nrlnum: "The function value {-580.`+2.` I,-570.`+3.` I,-565.`+3.7416573867739413` I,-562.`+4.358898943540674` I,-560.`+4.898979485566356` I} is not a list of real numbers with dimensions {5} at {a,b} = {1.`,1.`}""
How to use FindIt to get a and b?
FindFit[data,A[x],{{a,600},{b,300}},x]
will specify starting points. Just FYI though, I'd probably defineA
asfitfun[x_,a_,b_]:=...
and doFindFit[data, fitfun[x,a,b],{{a,600},{b,300}},x]
. Better to avoid capital letters in your defs. to avoid clashing with MMA functions, and prevent your function from messing up ifa,b
end up with global defs. I'd also look intoNonlinearModelFit
$\endgroup$FindFit
tries values that make theSqrt
complex. Restrictingb
fixes that :FindFit[data, {A[x], b > 25}, {a, b}, x]
$\endgroup$