Find the best fitting function for some experimental data

I am almost new in Mathematica, and so I have some problems that may appear basic for you. I am given a set of data taken from an experiment. I am supposed to find the curve that best fits them. The data are:

data = {{0.12, 1.51}, {0.12, 1.50}, {0.46, 1.51}, {0.51, 1.52}, {0.79,
1.52}, {1.07, 1.55}, {1.41, 1.53}, {1.46, 1.51}, {1.73,
1.51}, {1.74, 1.50}, {2.02, 1.49}, {2.02, 1.47}, {2.37,
1.41}, {2.42, 1.40}, {2.70, 1.34}, {2.97, 1.28}, {2.97,
1.29}, {2.98, 1.28}, {2.99, 1.30}, {3.00, 1.28}, {3.31,
1.21}, {3.61, 1.17}, {3.62, 1.17}, {3.65, 1.18}, {3.78,
1.15}, {3.79, 1.16}, {3.93, 1.15}, {3.94, 1.17}, {3.94,
1.17}, {4.18, 1.19}, {4.18, 1.20}, {4.34, 1.29}, {4.48,
1.39}, {4.48, 1.38}, {4.60, 1.56}};


Originally, I was looking for a function of the form

$$a - bx - \frac{c - (dx - e)^2}{f - (g x - k)^3}$$

where $a,b,c,d,e,f,g,k$ are constants to be determined, but if you have better ideas for the function form, please inform me. The code I used is:

nlm = NonlinearModelFit[
data, (a - bx - (c - (dx - e)^2)/(f - (g x - k)^3)), {a, b, c, d, e,
f, g, k}, x]
Show[Plot[nlm[x], {x , 0, 6}]
, ListPlot[data, PlotStyle -> {Darker@Green, PointSize[0.03]}]]


But I get a number of errors, like "First argument data in NonlinearModelFit is not a list or a rectangular arrow" I am searching for such a function desperately for some time now, I would deeply appreciate any help I could get....

• bx is a symbol, b x or b*x is b times x, fix that (with dx ) and you're on your way... – ciao Jun 10 '15 at 5:30
• Ditto for d x versus dx. – Verbeia Jun 10 '15 at 5:34
• Is there a reason you've chosen that particular function? Is it known that the data in this experiment should have such a mathematical form? I ask because a 5th order polynomial fits the data pretty nicely, and with 2 fewer parameters. Of course, any relatively nice looking data set will fit some polynomial... – march Jun 10 '15 at 5:35
• Yes indeed, I am told by my professor that this mathematical formula could be used, but I am not restricted to use this formula only.... – Arbër Ll Jun 10 '15 at 11:45

nlm = NonlinearModelFit[ data, (a - b x - (c - (d x - e)^2)/(f - (g  x - k)^3)),

• @ArbërLl Version 7 is rather old,and I don't have it around anymore. I don't think it supports Method -> NMinimize The other error is possibly solved by restarting Mathematica – Dr. belisarius Jun 10 '15 at 12:38
• @ArbërLl Execute nlm["BestFitParameters"]. You'll never be able to program a single line of Mathematica code if you don't read the docs. Try reading the NonlinearModelFit[ ] help page. (BTW the docs aren't friendly at first. Keep trying) – Dr. belisarius Jun 11 '15 at 3:46