Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the inconsistent linear system {x_1 + 3x_2 + 5x_3 = -2 x_1 + 2x_2 - x_3

ID: 2085241 • Letter: C

Question

Consider the inconsistent linear system {x_1 + 3x_2 + 5x_3 = -2 x_1 + 2x_2 - x_3 = 0 x_2 + 4x_3 = -5 -x_1 + x_2 + 10x_3 = -19 3x_1 + 7x_2 + 8x_3 = 6 (a) Enter the coefficient matrix A and the vector b into MATLAB for which this system is Ax = b. Use the command M = [A b] to enter the augmented matrix of the system, and then do a command to verify that the system is inconsistent. (b) We shall find a least-squares solution instead. As in the guide, enter the augmented matrix N of the normal equations A^T Ax = A^Tb. Use to find the least-squares solution v. (c) Compute the distance from Aw to b. This is the quantity that the least-squares solution minimizes. (d) Choose a vector v whose entries are close to those of w, but different. Verify that the distance from Av to b is larger than the quantity from the previous part.

Explanation / Answer

Matlab Code:

clc
clear all
close all


A = [ 1 3 5 ; 1 2 -1 ; 0 1 4; -1 1 10; 3 7 8 ]
B = [-2;0;-5;-19;6]

M = [A B]
Rank_M = rank (M)

X = AB
C = pinv(A)*B

B1 = A*C

Output:

A =

1 3 5
1 2 -1
0 1 4
-1 1 10
3 7 8


B =

-2
0
-5
-19
6


M =

1 3 5 -2
1 2 -1 0
0 1 4 -5
-1 1 10 -19
3 7 8 6


RankM =

4


X =

23.4708
-10.9708
1.5345


C =

23.4708
-10.9708
1.5345


B1 =

-1.7692
-0.0053
-4.8329
-19.0968
5.8926