I want to perform quartic regression on following data:
x =
375
1029
2187
3993
6591
10125
14739
y=
0.5608
0.8522
0.9075
0.9994
0.8668
0.7162
0.9143
To do that I've implemented following function:
function[str] = quarticRegression(x, y)
A = [x.^4 x.^3 x.^2 x ones(length(x), 1)];
res = A\y;
str = sprintf('%fx^4 + (%f)x^3 + (%f)x^2 + (%f)x + %f',...
res(1), res(2), res(3), res(4), res(5));
end
Unfortunately, I'm getting following error:
Warning: Rank deficient, rank = 4, tol = 7.520684e+01.
When I try to change x vector for smaller numbers, error disappears.
What is the correct way to get the result?
I guess I should somehow normalize the x vector, but I don't know how to do that and not change the system solution.


The condition number of $A$ (the ratio of the largest singular value of A to the smallest) is very big $\left(\approx 10^{16}\right)$ so that Matlab iterprets $A$ as a singular matrix.
Even the Matlab function polyfit (that do the job you want) shows that the problem is badly conditioned. Indeed, notice that the graph lying the points $(x,y)$ is almost an horizontal line.
With your data, we have for a quadratic fit
which is approximately a constant value.