As you can see from the Documentation for FindFit
, it has the following Method
s: "ConjugateGradient"
, "Gradient"
, "LevenbergMarquardt"
, "Newton"
, "NMinimize"
, and "QuasiNewton"
. With exception for NMinimize
none of these supports fitting in integer domain. So you should recast your problem for NMinimize
as follows:
sin2[n_Integer] := Sin[n]^2
cos2[n_Integer] := Cos[n]^2
NMinimize[{Total[Table[a sin2[x] + b cos2[x] - 1, {x, 1, 4}]^2]}, {a, b}, Integers]
{3.15853*10^-32, {a -> 1, b -> 1}}