(Solved) : Exercise 3 4 Points Difficulty Moderate Exercise Work Span Set Vectors Theory Let Vi V V S Q44116907 . . .

Continuation of the same problem:

EXERCISE 3 (4 points) Difficulty: Moderate In this exercise you will work with the Span of a set of vectors. Theory: Let (vi, V…, v.} be a set of vectors in R”. The Span{v, V.,…, V,} is defined as the set of all linear combinations of vectors V, V2…., V, with weights C.C…,C,ER, that is, the set {GV+C,V, +…+,}, where each cc, …,C, runs through the set of real numbers. We say that be Span{V, V 2…., } if b can be written as b=CV, +c, V, +…+0.. for some weights 4.C…,C,ER. Suppose A = [v, V … v.]. Then, b eSpan{v, V2,…, v.} if and only if the matrix equation Ax=b has a solution; moreover, a solution x=c is a vector of weights on the columns of A to produce b. **Create a function that begins with function c=span (A,b) format m=size (A, 1); fprintf(‘matrix A has si rowsn’,m) c= ; The inputs are a matrix A and a column vector b. The output c is a vector of weights which can be an empty vector an empty vector does not need to be displayed). **First, your function has to check if b is in R”. If not, there is a mismatch in dimensions. If b is not in R”, output the corresponding message and terminate the program (an empty output has been assigned to c already). An example of the output message with sprintf is below (you could use fprintf instead): sprintf(‘the dimensions mismatch: vector bis not in R i ‘,m) **If bis in R”, output the message fprintf(‘the dimensions match: vector bis in R and your program will continue with a few more tasks: i n’,m) First, you will need to verify whether b is in the Span of the columns of A. If b is not in the Span of the columns of A, output the corresponding message and terminate the program (the output c will be an empty vector). If b is in the Span of the columns of A, first, check if it is the case that the columns of A span the whole R” and, if so, output a message that would indicate it. Otherwise, output the message “the columns of A do not span the whole R’m, but the vector b is in the Span of the columns of A” (m has to be specified). Then, calculate a vector e using MATLAB “backslash” operator, : c=Ab; Next, verify that is indeed a solution of the equation Ax=b. If it is the case, output a message that “a vector of weights on the columns of A to produce b is:” and display e. You will need to use a conditional statement and function closetozeroroundoff with p=7. Suggested built-in MATLAB functions: rank, fprintf, sprintf, disp. **Type the function span and closetozeroroundoff in your Live Script. **Run the function c=span (A,b) on the following sets of variables (display the input variables in your Live Script): (a) A= magic(5), b=ones(5,1) (b) A= magic(4), b=ones(5,1) (c) A= randi(10,5,3), b=ones(5,1) (d) A=randi(10,5.3), b=A(:, end) (e) A=randi(10,5,3), b=zeros(5,1) Show transcribed image text EXERCISE 3 (4 points) Difficulty: Moderate In this exercise you will work with the Span of a set of vectors. Theory: Let (vi, V…, v.} be a set of vectors in R”. The Span{v, V.,…, V,} is defined as the set of all linear combinations of vectors V, V2…., V, with weights C.C…,C,ER, that is, the set {GV+C,V, +…+,}, where each cc, …,C, runs through the set of real numbers. We say that be Span{V, V 2…., } if b can be written as b=CV, +c, V, +…+0.. for some weights 4.C…,C,ER. Suppose A = [v, V … v.]. Then, b eSpan{v, V2,…, v.} if and only if the matrix equation Ax=b has a solution; moreover, a solution x=c is a vector of weights on the columns of A to produce b. **Create a function that begins with function c=span (A,b) format m=size (A, 1); fprintf(‘matrix A has si rowsn’,m) c= ; The inputs are a matrix A and a column vector b. The output c is a vector of weights which can be an empty vector an empty vector does not need to be displayed). **First, your function has to check if b is in R”. If not, there is a mismatch in dimensions. If b is not in R”, output the corresponding message and terminate the program (an empty output has been assigned to c already). An example of the output message with sprintf is below (you could use fprintf instead): sprintf(‘the dimensions mismatch: vector bis not in R i ‘,m) **If bis in R”, output the message fprintf(‘the dimensions match: vector bis in R and your program will continue with a few more tasks: i n’,m) First, you will need to verify whether b is in the Span of the columns of A. If b is not in the Span of the columns of A, output the corresponding message and terminate the program (the output c will be an empty vector).
If b is in the Span of the columns of A, first, check if it is the case that the columns of A span the whole R” and, if so, output a message that would indicate it. Otherwise, output the message “the columns of A do not span the whole R’m, but the vector b is in the Span of the columns of A” (m has to be specified). Then, calculate a vector e using MATLAB “backslash” operator, : c=Ab; Next, verify that is indeed a solution of the equation Ax=b. If it is the case, output a message that “a vector of weights on the columns of A to produce b is:” and display e. You will need to use a conditional statement and function closetozeroroundoff with p=7. Suggested built-in MATLAB functions: rank, fprintf, sprintf, disp. **Type the function span and closetozeroroundoff in your Live Script. **Run the function c=span (A,b) on the following sets of variables (display the input variables in your Live Script): (a) A= magic(5), b=ones(5,1) (b) A= magic(4), b=ones(5,1) (c) A= randi(10,5,3), b=ones(5,1) (d) A=randi(10,5.3), b=A(:, end) (e) A=randi(10,5,3), b=zeros(5,1)
Expert Answer
Answer to EXERCISE 3 (4 points) Difficulty: Moderate In this exercise you will work with the Span of a set of vectors. Theory: Let…
OR