You need to form a 5 by 3 matrix A whose columns are square of the x values, x-values, and a column of ones. One way to do this is to type
Note: Recall that the operations .* , .^ provide element wise multiplication and raising to a power.
Now in Ax=b the vector x is
and b is the vector of y-values. So you can enter b=D(:,2).
Now you could form the system AX=b, and least square solution id the solution of the normal system .
To solve this system you may find by typing
For the rest of this problem you need to redefine the matrix A > Make sure first clear yur old variables. For example for part (ii) first column of A is the third powers of x-value, and so on.
2cm ii) Find a polynomial of degree three, that best fits the points given above.
2cm
iii) Find a polynomial of degree four, that best fits the points given above.
iv) Find a polynomial of degree five that best fits the points given above.