I am trying to fit a polynomial through 340 points in a 3D space, i.e.
$$f(x,y,z) = k$$
I asked previously about the theory behind polynomial interpolation here -> Polynomial interpolation
Few interesting points came out from the discussion, but I would like to understand how to correctly implement them in Python.
I am writing a script in Python to compute the Vandermonde matrix for a polynomial of a generic order $p$. Now the implementation problem arises.
I have 340 points $(x,y,z)$. Supposing I have a polynomial of 6th order I have
(order+1) ^ number_of_dimensions
degrees of freedom for my polynomial. Therefore, it means that I have 343 degrees of freedom. Since I have 340 points I cannot use such order because otherwise the problem is underdetermined.
If I use a 5th order polynomial I have 216 degrees of freedom, and in this case the problem is overdetermined and the polynomial is an approximating polynomial. In a preliminary phase I do not need the exact interpolation, since I can solve the problem with a complementary solution, but do you think it is feasible the solution given?
As suggested by the user who helped me in the previous question, actually a polynomial of 6th order has 84 degrees of freedom. This is related to the constraint given by $$a+b+c<p$$ with $a,b,c$ the exponents in each term $x^a y^b z^c$.
The question which arises is if it more feasible to create a Vandermonde matrix which respects this constraint. Does it give an improved approximated solution compared to a full Vandermonde matrix?