# Numerical Analysis Interpolation

Does anyone know an algorithm, or even better yet have code examples, for creating polynomial or Lagrange approximation, given a N number of points, and 1, 2 and 3 variables/dimensions?

I remember taking a course of Numerical Analysis way back in college, and I am pretty dusty on the math.

Much appreciated.

1. Determine the form of the polynomial (2nd order including only two-way interactions for example). With 3 variables(A, B & C) this would be
Y = c0 + c1A + c2B + c3C + c4AB + c5AC + c6BC + c7A^2 + c8B^2 + c9C^2

2. Use regression to determine the coefficients in the above equation. Keep in mind that there may not be enough degrees of freedom to determine the coefficients.

A few years ago, I wrote a Xojo program to fit a polynomial of any degree to experimental data. However, it’s only a one dimensional routine, and would have to be modified to handle extra dimensions. This straightforward in theory (just a few more rows and columns in the matrices), but the implementation might get a bit messy. I could post the code of the original, if it would help.

Nowadays, I tend to use the Nelder-Mead algorithm to fit data. It takes a lot more iterations, but is far more flexible in that it will fit just about any type of function that you can imagine, in as many dimensions as you want.