(* *)
(* Numerical Mathematics and Computing, Fifth Edition *)
(* Ward Cheney & David Kincaid *)
(* Brooks/Cole Publ. Co. *)
(* (c) 2004 *)
(* No warranties implied or expressed. *)
(* File: ls_fit *)
(* linear least-squares example *)
points = {{1.0, 3.7}, {2.0, 4.1}, {2.5, 4.3}, {3.0, 5.0}}
plotpoints = ListPlot[points, PlotStyle->PointSize[0.02]]
Fit[points, {1, x}, x]
plotline = Plot[%, {x, 0.0, 3.0}]
Show[plotpoints, plotline]