I'm fitting data points with cubic polynomials. The standard linear least squares approach (ie. ATAc = ATy, where c are the polynomial coefficients and A is the matrix of basis functions) works just fine, but I want to guarantee that the curve go through the 1st and last points, which standard least squares doesn't do.

Anybody know how this is done from a mathematical standpoint? I can solve the problem using, for example, the solver within Excel, but I'm curious as to the math development/theory for this kind of problem. Anybody know of any reference that deals with this?