Solve using Matlab/Octave Find the cubic polynomial that best fits the data poin
ID: 3810258 • Letter: S
Question
Solve using Matlab/Octave
Find the cubic polynomial that best fits the data points (z, y) = (-1, 14), (0, -5), (1, -4), (2, 1), (3, 22) Produce a graph showing the polynomial, together with the given data points as discrete points.[15l Find the eigenvalues and eigenvectors of the following matrices, using both eig and power method (for the dominant eigenvalue and eigenvector). lf the power method fails, discuss why. For those matrices that are diagonalizable, give the diagonalization matrix Modify the power method so that if finds the smallest eigenvalue and corresponding eigenvector. You do this by evaluating x_n+1 = A^-1x_n rather than x_n+1 = Ax_n. When convergence occurs, it is to the eigenvector corresponding to the inverse of the smallest eigenvalue. Demonstrate the validity of your code by running it on a number of test cases.Explanation / Answer
7.
% the vector x = [-1,0,1,2,3]
% the vector y = [14,-5,-4,1,22]
% order = 3 ( Cubic Polynomial )
% using Matlab function polyfit(x,y,order)
x = [-1,0,1,2,3]
y = [14,-5,-4,1,22]
x1 = linspace(-25,25)
pv = polyval(p,x1)