The method used to fit a straight line to data pointsin example 1 can be easily generalized to a polynomial of a given degree.
find equation of a polynomial of degree 3, that best fits the following data.
Solution :
Note that we want to find the coefficients of a third degree polynomial
Therefore the linear system Ax=b would be
To form your matrix A first enter the data in MATLAB as
D3=[ 2 1 0 -2 5 -1 ; 1 1 1 1 1 1 ; 7 -2 -7 -27 110 -20 ]'
Enter your coefficient matrix A3
Enter your matrix b as
b3= D(:,3)
Solve the linear system .
To find the augmented matrix type
AG3= [ (A3)'*(A3) (A3)'*b3 ]
Then find the rref of the augmented matrix by typing
RAG3=rref(AG3)
This should give you .