I fitted some function via Mathematica in a way like this
parameter = {a, b};
parameter
data = {{0, 1.2}, {0, 0.1}, {0.1, 0.2}, {1.1, 0}}
Ftest[x_, y_] := a*x^2 + b*y^2
fit = FindMinimum[Total[(Ftest @@@ data - 2)^2], parameter]
ContourPlot[(Ftest[x, y] /. fit[[2]]) == 2, {x, 0, 1.5}, {y, 0, 1.5},
Epilog -> {Red, Point /@ data}]
With the appropriate outcome. However my actual function is more complex and consists of a sinus/cosinus/arccos functions with some exponent to the power of 8. Use my actual code with the actual function I get some error:
The function value {3.74166 (-2.+81. (256. Power[<<2>>]+256. Power[<<2>>]+256. Power[<<2>>]) (Times[<<4>>]+Times[<<2>>])^4)^2} is not a list of real numbers with dimensions {1} at {apb3d,bpb3d,cpb3d,fpb3d,gpb3d,hpb3d} = {1.,1.,1.,1.,1.,1.}. >>
The function I want to fit is in an area for x of 0 and 90 whereas y is between 0 and 2. However since it is a series of sinus functions the fitting function is symertical The parameters I want to fit are between the values of -2 and 2. Some test with known parameter values have been performed so the actual function is correct. Does Mathematica need some further input of where to limit the search for the parameters to?