I have a Problem regarding the fit of given points with a polynomial up to the fifth degree.
tableofvalues=Import["tableofvalues.csv"]
My polynomial is:
polynomtabelle={1, x[1], x[1]^2, x[1]^3, x[1]^4, x[1]^5, x[2], x[2]^2, x[2]^3, x[2]^4, x[2]^5, x[3], x[3]^2, x[3]^3, x[3]^4, x[3]^5, x[4], x[4]^2, x[4]^3, x[4]^4, x[4]^5}
polynom = LinearModelFit[tableofvalues, polynomtabelle, Array[x, {4}]];
I know that my points have a certain symmetry. So the linear factors of coordinate x[1] have to be the same as for x[4]. The same applies for x[2] and x[3]. But if I ask for the coefficients I get for example:
NumberForm[Extract[CoefficientList[polynom["BestFit"], Array[x, {4}]], {5, 0, 0, 0} + 1], Floor@$MachinePrecision]
0.0619247206844402
NumberForm[Extract[CoefficientList[polynom["BestFit"], Array[x, {4}]], {0, 0, 0, 5} + 1], Floor@$MachinePrecision]
0.0619247173030426
One sees that they differ in the eigth digit after the decimal point, which is an accuracy too low for later treatment of the polynomial. Especially we have an old fitting routine written in FORTRAN in our working group that achieves 0.0619247173 for both coefficients. (Infact I intended to replace it with this one written in Mathematica).
How can I achieve numerically a better result. Perhaps you will ask for the precision of my input.
Precision[tableofvalues]
MachinePrecision
I run Mathematica on a 64Bit Computer so
$MachinePrecision
15.9546
The tableofvalues.csv is:
0.,0.,0.,0.,-0.9084906825
-0.04724315325,0.,0.,0.,-0.9075435543
-0.0377945226,0.,0.,0.,-0.9078643076
-0.028345891949999997,0.,0.,0.,-0.9081173929
-0.0188972613,0.,0.,0.,-0.9083049166
-0.00944863065,0.,0.,0.,-0.9084286871
0.00944863065,0.,0.,0.,-0.908492608
0.0188972613,0.,0.,0.,-0.9084363935
0.028345891949999997,0.,0.,0.,-0.9083237119
0.0377945226,0.,0.,0.,-0.9081562202
0.04724315325,0.,0.,0.,-0.9079356124
0.,-0.04724315325,0.,0.,-0.9074790503
0.,-0.0377945226,0.,0.,-0.9078199288
0.,-0.028345891949999997,0.,0.,-0.9080895811
0.,-0.0188972613,0.,0.,-0.9082900218
0.,-0.00944863065,0.,0.,-0.9084230317
0.,0.00944863065,0.,0.,-0.9084947071
0.,0.0188972613,0.,0.,-0.9084370745
0.,0.028345891949999997,0.,0.,-0.9083194184
0.,0.0377945226,0.,0.,-0.9081434864
0.,0.04724315325,0.,0.,-0.9079110427
0.,0.,-0.04724315325,0.,-0.9074790503
0.,0.,-0.0377945226,0.,-0.9078199288
0.,0.,-0.028345891949999997,0.,-0.9080895811
0.,0.,-0.0188972613,0.,-0.9082900218
0.,0.,-0.00944863065,0.,-0.9084230317
0.,0.,0.00944863065,0.,-0.9084947071
0.,0.,0.0188972613,0.,-0.9084370745
0.,0.,0.028345891949999997,0.,-0.9083194184
0.,0.,0.0377945226,0.,-0.9081434864
0.,0.,0.04724315325,0.,-0.9079110427
0.,0.,0.,-0.04724315325,-0.9075435543
0.,0.,0.,-0.0377945226,-0.9078643076
0.,0.,0.,-0.028345891949999997,-0.9081173929
0.,0.,0.,-0.0188972613,-0.9083049166
0.,0.,0.,-0.00944863065,-0.9084286871
0.,0.,0.,0.00944863065,-0.908492608
0.,0.,0.,0.0188972613,-0.9084363935
0.,0.,0.,0.028345891949999997,-0.9083237119
0.,0.,0.,0.0377945226,-0.9081562202
0.,0.,0.,0.04724315325,-0.9079356124
NumberForm[ ]
in my machine are more like6.39247197093749
.... $\endgroup$tableofvalues = SetPrecision[#, 40]& @ {yourdata}
. You will then obtain coefficients from your expression that are numerically the same to within the precision you have set. Further note: I also get the 6.39... answers from your code that @belisarius reported. $\endgroup$