Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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!

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions