Write a script that includes (at bottom) any functions you w…

Write a script that includes (at bottom) any functions you write (if any) and that uses Linear Regression to  fit a line onto the given data fit a cubic (degree 3) polynomial onto the given data report results as discussed below plot results as discussed below Description of data:  the x variable is displacement.  The y variable is force for a “stiffening spring” that stiffens as it displaces.  It is not exactly linear in the force vs. displacement.  Let’s find out. Things to report.  Sum of squares of residuals (from mean) Sum of squares of residuals (from line fit) Sum of squares of residuals (from cubic fit) coefficient of determination (line) coefficient of determination (cubic) Things to plot Raw data, use ‘o’ Show y average, use ‘r’ Show the linear fit line, use ‘g’ Show the cubic fit line, use ‘b’ Data  (cut and paste this data) x data (independent) 56789101112131415161718192021222324252627282930 y data (dependent) 812.07968.251128.11305.21459.71625.81825.520592212.92414.62569.62903.23035.63319.23436.43904.24168.84241.64635.24809.45336.15592.55950.46067.964437411.3            

What is the following code doing?   global DEBUG;DEBUG=true;…

What is the following code doing?   global DEBUG;DEBUG=true;A=;b=;P = ;A = P*A;b = P*b;n = 3;debug_mat(“A: “, A);debug_mat(“b: “, b);C = A;for k=1:n    C(k,k) = 0;    x(k,1) = 0;    epsilon_a(k,1) = 1;endfor k=1:n    C(k,1:n) = C(k,1:n)/A(k,k);        d(k) = b(k)/A(k,k);enddebug_mat(“x: “, x);debug_mat(“C: “, C);debug_mat(“d: “, d);show = ;% from book, Fig 12.2, es=0.00001% is 0.0000001% called the ‘stop criterion’book_es = 0.0000001;for iter=1:50    % an nx1 column vector; should b zeros!    e = A*x – b;      % Griffis Method:  a little looser bound; cheat a little here    % this is also nx1 column vector of “err” bounds    err = ((n+1)*abs(A)*abs(x)+abs(b))*eps;    err_subm = (norm(A,1)*norm(x,1)+norm(b,1))*eps;        % important tests!  UNDERSTAND what these say.    x_is_floating_pt_valid = norm(e,1) ‘, repmat(‘%8.16f ‘, 1, n), ‘\n’];    fprintf(“%s\n”, entry);     fprintf(fmt1, A’);     fprintf(“\n”);end