Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I tried to nonlinear fit a set of data as described below. However, it appears to yield a fit solution that in appearance looks good with the plotted data set, 'dat1', however, actual fit solution answers don't appear to represent the fit curve in the plot. (Note, I could not copy over the plot image itself.) Here's what I did,

I have a set of data:

dat1 = {{.1, .1010}, {.04, 0.1192}, {.02, 0.1555}, {.01, 0.1777}, {.004, 0.1789}};

to which I have fit a model using the nonlinear fit model function:

nlm = 
  NonlinearModelFit[dat1, a + b Log10[x] + c Log10[x]^2, {a, b, c}, x];


FittedModel[-0.0298908 - 0.0662938 Log[x] - 0.00502002 Log[x]^2 ]

When the fit model, nlm and the data set, 'dat1' are plotted:

Plot[nlm[x], {x, 0.004, 0.1}, 
  Epilog -> {Red, PointSize[Medium], Point@dat1}]  

it gives a plot containing the combined fit curve and red dot point curve for dat1 data. (Note: can't get graphic to insert here.)

I tested the fitted model:

d + e Log10[x] + f Log10[x]^2 /. 
  {x -> .04, d -> -0.0298908, e -> -0.0662938, f -> -0.00502002}

and it gave the answer:


However if you look at the plot, this answer is nowhere near the value estimate in the plot.

I also tried:

d + e Log10[x] + f Log10[x]^2 /. {x -> .004, d -> -0.0298908, 
e -> -0.0662938, f -> -0.00502002}

and it's answer was:


Am I missing something or what? Please advise.


(add plot image)

Plot of superimposed data

share|improve this question
You are mixing up Log and Log10. The values you are entering for e and f are the coefficients of Log not Log10. –  bobthechemist Aug 17 '13 at 22:04
As bobthechemist has pointed out, you probably require d + e Log[x] + f Log[x]^2 /. {x -> .04, d -> -0.0298908, e -> -0.0662938, f -> -0.00502002} => 0.131487 –  TomD Aug 17 '13 at 22:15
Why don't you use nlm["Function"][.04] which gives 0.131487. –  m_goldberg Aug 17 '13 at 23:26
add comment

closed as off-topic by m_goldberg, Sjoerd C. de Vries, Kuba, Yves Klett, Artes Aug 18 '13 at 19:54

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, Sjoerd C. de Vries, Kuba, Yves Klett, Artes
If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

As pointed out in the comments to the question, the OP made a simple mistake of confusing Log with Log10. However, the OP could have saved himself a lot of grief by using NonlinearModelFit as Stephan Wolfram intended him to :-)

data = {{.1, .1010}, {.04, 0.1192}, {.02, 0.1555}, {.01, 0.1777}, {.004, 0.1789}};
nlm = NonlinearModelFit[data, a + b Log10[x] + c Log10[x]^2, {a, b, c}, x];

nlmF = nlm["Function"]
0.0298908 - 0.0662938 Log[#1] - 0.00502002 Log[#1]^2 &
nlmF /@ {.004, .04}
{0.183105, 0.131487}
share|improve this answer
Thanks very much, a very obvious point I overlooked. –  user9102 Aug 18 '13 at 0:06
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.