The Method

By far the easiest way to find a curve through the points is to use a Lagrangian Polynomial. For example, if you have four points:


  x={1,2.7,3.2,4.8,5.6}
  y={14.2,17.8,22,38.3,51.7}

We can use a Lagrangian polynomial of degree 4, P4. The following function will return the Lagrangian polynomial of degree one less than the number of points. By the way, if you want a lesser degree, simply disregard some of the points.


  lagrangepoly[t_,x_,y_]:=
  Module[{n,poly,q,i,j},
  	n=Dimensions[x][[1]];poly=0;
  	For[i=1,i<=n,i++,
  	  q=1;
  	  For[j=1,j<=n,j++,
  	     If[j!=i,q=q*(t-x[[j]])/(x[[i]]-x[[j]])]
  	  ];
  	  poly=poly+q*y[[i]];
  	]; 
  	poly  
  ];


  p4[t_]:=lagrangepoly[t,x,y]


  p4[t]

Do you trust the Lagrange polynomial? Let's evaluate it at the x values and see if the match the y values.


  test=p4[x]
  y

To convince you that the Lagrange polynomial is an easy way to fit points, let's look more closely at its definition:


  x={x1,x2,x3,x4,x5}
  y={y1,y2,y3,y4,y5}


  p4[t_]:=lagrangepoly[t,x,y]


  p4[t]

Now do you see why this works? (And works easily!)

Up to First Attempt: Lagrange Polynomial Interpolation