Question: Least Square - I need help with only part (b) . I got x_analytical = [ 1 -1 ] . Thank you! Copy/paste code: close

Least Square - I need help with only part (b) . I got x_analytical = [ 1 -1 ] . Thank you!

Least Square - I need help with only part (b) . I

Copy/paste code:

close all; clear; clc; for k=5:8 A = [1 1; 10^(-k) 0; 0 10^(-k)]; b = [-10^(-k); 1 + 10^(-k); 1 - 10^(-k)]; xhat_QR = A\b xhat_normal = (A'*A)\(A'*b) end

(1 1) / -10-) Let k be any positive integer, and A= | 10-k 0 ,b= | 1 + 10-k lo 10-) (1 10k) (a) By hand, analytically compute the least squares solution Tanalytical for the above A, 6 from the normal equation. You may use the formula for the inverse of a 2 x 2 matrix: -1 Show all the steps in your hand calculations. (b) Consider the following MATLAB script that numerically computes the least squares solution for k= 5, 6, 7, 8, in two different ways: close all; clear; clc; format long for k=5:8 A = [1 1; 10^(-k) 0; 0 10^(-k)]; b = (-10^(-k); 1 + 10^(-k); 1 - 10^(-k)]; xhat_QR = A\b xhat_normal = (A'*A) (JA' *b) end Run the above script yourself in MATLAB, and report what you observe. Finally, explain why one among the two numerical least squares solutions xhat_QR and what normal, is more accurate (with respect to the known analytical solution analytical from part (a)). (1 1) / -10-) Let k be any positive integer, and A= | 10-k 0 ,b= | 1 + 10-k lo 10-) (1 10k) (a) By hand, analytically compute the least squares solution Tanalytical for the above A, 6 from the normal equation. You may use the formula for the inverse of a 2 x 2 matrix: -1 Show all the steps in your hand calculations. (b) Consider the following MATLAB script that numerically computes the least squares solution for k= 5, 6, 7, 8, in two different ways: close all; clear; clc; format long for k=5:8 A = [1 1; 10^(-k) 0; 0 10^(-k)]; b = (-10^(-k); 1 + 10^(-k); 1 - 10^(-k)]; xhat_QR = A\b xhat_normal = (A'*A) (JA' *b) end Run the above script yourself in MATLAB, and report what you observe. Finally, explain why one among the two numerical least squares solutions xhat_QR and what normal, is more accurate (with respect to the known analytical solution analytical from part (a))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!