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?

  • 2
    $\begingroup$ Also take a look at question 80998 for some discussion of the different fitting functions in Mathematica. $\endgroup$
    – MarcoB
    Commented May 1, 2015 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$ Commented May 1, 2015 at 11:11

1 Answer 1


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$ Commented May 1, 2015 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
    Commented May 1, 2015 at 10:32

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