I am very much new to Mathematica, and facing several difficulties. I used the following code

Fit[{2, 4, 6, 8}, {1, x}, x]

The output is 8.88178*10^-16 + 2. x.

Now I have the following data set.


How can I fit this data set?


closed as off-topic by Sjoerd C. de Vries, Oleksandr R., bbgodfrey, Dr. belisarius, Daniel Lichtblau May 1 '15 at 14:13

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." – Sjoerd C. de Vries, Oleksandr R., bbgodfrey, Dr. belisarius, Daniel Lichtblau
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ Also take a look at question 80998 for some discussion of the different fitting functions in Mathematica. $\endgroup$ – MarcoB May 1 '15 at 8:03
  • 2
    $\begingroup$ Really, the very first example on the Fit doc page shows this use case. Although we love to help people out here, we also appreciate it if we see some minimal effort. I don't want to be too harsh on you, but it seems that this minimal effort is lacking here. $\endgroup$ – Sjoerd C. de Vries May 1 '15 at 11:11

Like this?

data = {{0.1, 2}, {0.12, 3}, {0.15, 4.2}, {0.17, 5}};
line = Fit[data, {1, x}, x];
Show[Plot[line, {x, 0, 0.2}], ListPlot[data]]

enter image description here

  • $\begingroup$ It works fine... $\endgroup$ – kallol mondal May 1 '15 at 10:15
  • 3
    $\begingroup$ I would strongly advise you to get used to going through the docs. If you are new to Mathematica, the documentation is likely to be immensily helpful, as it has been for me. This answer came straight out of an example in the docs. $\endgroup$ – Julian May 1 '15 at 10:32

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