Off[General::spell1];
Clear[BestFit, BestPoly,XY0,p];
BestFit[XY0_,p0_] := 
Block[{XY},
  XY = XY0;
  p = p0;
m=Length[XY];
Clear[a,b,ips,P];
ips[f_,g_] := Sum[ f g /. x-> XY[[i,1]] ,{i,m}];
a[n_] := a[n] = ips[ x P[n-1,x] , P[n-1,x] ] / ips[ P[n-1,x] , P[n-1,x] ]; 
b[n_] := b[n] = ips[ x P[n-1,x] , P[n-2,x] ] / ips[ P[n-2,x] , P[n-2,x] ];
P[0,x_] = 1;
P[1,x_] = x - a[1];
P[n_,x_] := P[n,x] = (x-a[n]) P[n-1,x] - b[n] P[n-2,x];
For[i=1,i <= m,i++,
   xy[XY[[i,1]]] = XY[[i,2]] ];
BestPoly[x_,p] = 
        Sum[ (ips[ xy[x] , P[k,x] ] /
        ips[ P[k,x], P[k,x] ]) P[k,x]  ,{k,0,p} ]; ];
On[General::spell1];

Clear[XY];
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}};

BestFit[XY,6]

For[j=0, j<=6, j++,
   Print["P",j,"(x)=" Simplify[P[j,x]]] ]

Simplify[BestPoly[x,6]]

Clear[nodes,fcn]
nodes=ListPlot[XY,PlotStyle->PointSize[.02],
              DisplayFunction->Identity]; 
fcn=Plot[ BestPoly[x,6],{x,0.2,3.2},
              DisplayFunction->Identity];
Show[nodes,fcn,DisplayFunction->$DisplayFunction]

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];

BestFit[XY,6]; 
 Simplify[BestPoly[x,6]]

Clear[nodes,fcn]
nodes=ListPlot[XY,PlotStyle->PointSize[.02], 
              DisplayFunction->Identity];  
fcn=Plot[ BestPoly[x,6],{x,10,11},
              DisplayFunction->Identity];
Show[nodes,fcn,DisplayFunction->$DisplayFunction]