MATLAB Answers

Hilbert Matrix in least squares polynomial regression

3 views (last 30 days)
Ali Kiral
Ali Kiral on 23 Apr 2021
Edited: Ali Kiral on 24 Apr 2021
When approximating the polynomial x^2+3x+2 with a least squares polynomial of degree two in [0 1], the coefficient matrix of the resultant linear system is a 3x3 Hilbert Matrix. Vector b is as follows as generated by the approximation problem. I should get an approximating polynomial almost like the original one, but the coefficients are quite afar from 2, 3 and 1. I know Hilbert Matrices are ill-conditioned. What can I do? (I am using where n is the degree of the approximating polynomial, is the function to be approximated and )
A=[1 1/2 1/3;1/2 1/3 1/4;1/3 1/4 1/5];
b=[16/3; 9/4; 97/60];
A\b
ans =
15.5000
-51.000
46.000

Answers (1)

John D'Errico
John D'Errico on 23 Apr 2021
Edited: John D'Errico on 23 Apr 2021
Is A really a hilbert matrix? LOOK CAREFULLY AT WHAT YOU WRITE!!!!!!!!!
In fact, A is not even a valid 3x3 matrix. If you fail to show valid syntax, is there a way we can realistically help you? How do we know what you tried?
A=[1 1/2 1/3;1/2 1/3 1/4;1/^1/4 1/5]
Invalid use of operator.

Error in connector.internal.fevalMatlab

Error in connector.internal.fevalJSON
This is a 3x3 hilbert matrix.
hilb(3)
ans =
1 0.5 0.33333
0.5 0.33333 0.25
0.33333 0.25 0.2
Is a 3x3 hilbert matrix truly ill-conditioned?
cond(hilb(3))
ans =
524.06
No.
  1 Comment
Ali Kiral
Ali Kiral on 24 Apr 2021
I am so sorry, I'm editing the matrix A in a few seconds..

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!