Clear[XY,f];
XY={{1, 3.7}, {2, 4.1}, {2.5, 4.3}, 
{3, 5}};
f[x_]=Fit[XY, {1,x}, x]

Clear[dots, least];
dots = ListPlot[XY,PlotStyle->
{PointSize[0.02]}, 
   DisplayFunction->  Identity];
least= Plot[f[x],{x,1,3.2},
   DisplayFunction->Identity];
Show[least, dots, DisplayFunction->
$DisplayFunction, PlotLabel->txt,
AxesLabel->{"x","y    "}]

Clear[XY,f];
XY={{0.24, 0.23}, {0.65, -0.26}, 
{0.95, -1.10},{1.24, -0.45}, 
{1.73,0.27},  {2.01, 0.10}, 
{2.23, -0.19},{2.52, 0.24}, 
{2.77,0.56},  {2.99, 1.00}};

f[x_]=Fit[XY, {1,x,x^2}, x]

Clear[dots, least];
dots = ListPlot[XY,PlotStyle->
{PointSize[0.02]}, 
   DisplayFunction->Identity];
least= Plot[f[x],{x,0,3.2},
   DisplayFunction->Identity];
Show[least, dots,DisplayFunction->
$DisplayFunction, PlotLabel->txt,
AxesLabel->{"x","y    "}]

Clear[f];
f[x_]=Fit[XY, {1,x,x^2, x^3, x^4, x^5,
   x^6}, x]

Clear[dots, least];
dots = ListPlot[XY,PlotStyle->{PointSize[0.02]},
   DisplayFunction->Identity];
least= Plot[f[x],{x,0.2,3.05}, 
   DisplayFunction->Identity];
Show[least, dots, DisplayFunction->$DisplayFunction,PlotLabel->txt,
AxesLabel->{"x","y    "}]

Clear[XY, n]; 
f[x_]:=1 + Sin[10 x]; 
pt[x_]:= 10+ (x-1)/14;  
n=15;
XY=N[Table[{pt[i], f[pt[i]]},  
  {i, 1,n}],10];

Clear[f];
f[x_]=Fit[XY, {1,x,x^2, x^3, x^4, x^5,
x^6}, x]

Clear[dots, least];
dots = ListPlot[XY,PlotStyle->
{PointSize[0.02]},
  DisplayFunction->Identity];
least= Plot[f[x],{x,10,11}, 
  DisplayFunction->Identity];
Show[least, dots, DisplayFunction->
$DisplayFunction,PlotLabel->txt,
AxesLabel->{"x","y    "}]