Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using MATLAB write s code that SOLVING HOMOGENEOUS SYSTEMS EXERCISE 5 (5 points) Difficulty: Hard Theory: In this exercise, you will work with the solution

using MATLAB write s code that
image text in transcribed
image text in transcribed
image text in transcribed
SOLVING HOMOGENEOUS SYSTEMS EXERCISE 5 (5 points) Difficulty: Hard Theory: In this exercise, you will work with the solution set of a homogeneous linear system Ax = 0, where A is an mxn matrix and XeR". If the system has only the trivial solution (there are no free variables), the spanning set for the solution set is the zero vector of R". If the system has non-trivial solutions (there is at least one free variable), we can obtain a spanning set for the solution set by solving the system using row reduction algorithm - this spanning set is also linearly independent and therefore, forms a basis for the solution set. Later on, we will call the solution set of a homogeneous system Ax =0 the Null space of the matrix A. Thus, in this exercise, we are creating a basis for the Null space of a matrix A when the Null space contains non-zero vectors. Important: Before you proceed with the coding, you need to solve sample homogeneous systems by hand in order to develop an algorithm: work with the reduced echelon forms of some of the matrices (a)-(k) listed at the end of this exercise and present the solution sets that contain non-zero vectors in a parametric-vector form (as a span of a set of vectors) with the free variables as parameters. **Create a function in MATLAB that begins with the lines: function C - homobasis (A) format (m, n)-size(A); red_ech_formerats (rref(A)); C-01 : Note: We output here (but do not display) the reduced echelon form of A as a character array with rational approximations of the entries. If you wish to use this output for your hand computations, you will need to remove temporarily the semicolon at the end of the command and re-run the code. Please keep this output suppressed for the submission. **First, your function has to check if the system Ax=0 has only the trivial solution, x=0. It happens if and only if there are no free variables (or equivalently, all columns of A are pivot columns). If this is the case, output the message: di sp('the homogeneous system has only the trivial solution) 7 and assign Cezeros in, 21 Display vector Chere and terminate the program. Hint: use a built-in MATLAB command rank in this part **If the system has nontrivial solutions, that is, there are free variables in the system (or equivalently, there are non-pivot columns in A), output a message the bomogeneous system has non-crivial lation, and your code will continue with constructing a basis for the solution set (the Null space of A). In order to proceed with this task, we will need to find the ordered sets of indexes of the pivot and non-pivot columns of A. The command that outputs the ordered set of indexes of the pivot columns is: 1.pivot_c)-rref The set of commands below outputs the ordered set of indexes of the non-pivot columns: nonpivot_cuse diff (3.pivot_e) The next set of commands output messages that list free variables. genomel (nonpivot_c); 3-119 {print free variable is xiiin, nonpivot_0(5) Include into your code all the commands listed above **After you have identified the free variables and non-pivot columns, you can begin to construct a basis for the solution set which will be formed by the columns of an nxq matrix C. Hint: Pre-locate matrix Cas C-zeros in.) and, then, recalculate its rows using matrices rref (x) and eye ig). You will make different assignments to the set of rows of C whose indexes are from the set pivot_c and to the set of rows of C whose indexes are from the set nonpivot_e (analyze your hand calculations!). **Finally, use a conditional statement to check whether the columns of Cindeed form a basis for the solution set of the homogeneous system. Since the number of columns of C is equal to the number of free variables in the system Ax 0, we only need to verify that the following two conditions hold: (1) the set of the columns of C is linearly independent (use the command rank here) (2) the columns of Care solutions of Ax = 0, or equivalently, AC is an mxq zero matrix (use here the function closetozeroroundort with pus). **If both conditions (1) and (2), hold your output will be: dispt'columns of C forma bald for solution set of homogeneous system') otherwise, an output message could be something like: "Mot bani? Impossible in this case, the empty output for C will stay. Receiving the last message should prompt you to look for errors in your code and correct them! This is the end of the function homobasis, 8 **Type the functions closetozeroroundoff and homobasis in your Live Script. **Run the function C-homobasis (A): on the following matrices: A= (1 -1 -1 2;-2 5 4 4] (b) A-11 2 -3) (c) A-magic (3) (d) A=[magic (3), ones (3,1)] (e) A=magic (4) 1(E) A-10 1 2 3;0 2 4 6] (g) A-101 0 2 0 3; 0 2 0 4 0 6; 0 4 0 8 0 6) A-11 0 2 0 3;2 0 5 0 61 (k) A=[1 0 0 2 3;2 0 0 4 6] (1) Arhilb (4) SOLVING HOMOGENEOUS SYSTEMS EXERCISE 5 (5 points) Difficulty: Hard Theory: In this exercise, you will work with the solution set of a homogeneous linear system Ax = 0, where A is an mxn matrix and XeR". If the system has only the trivial solution (there are no free variables), the spanning set for the solution set is the zero vector of R". If the system has non-trivial solutions (there is at least one free variable), we can obtain a spanning set for the solution set by solving the system using row reduction algorithm - this spanning set is also linearly independent and therefore, forms a basis for the solution set. Later on, we will call the solution set of a homogeneous system Ax =0 the Null space of the matrix A. Thus, in this exercise, we are creating a basis for the Null space of a matrix A when the Null space contains non-zero vectors. Important: Before you proceed with the coding, you need to solve sample homogeneous systems by hand in order to develop an algorithm: work with the reduced echelon forms of some of the matrices (a)-(k) listed at the end of this exercise and present the solution sets that contain non-zero vectors in a parametric-vector form (as a span of a set of vectors) with the free variables as parameters. **Create a function in MATLAB that begins with the lines: function C - homobasis (A) format (m, n)-size(A); red_ech_formerats (rref(A)); C-01 : Note: We output here (but do not display) the reduced echelon form of A as a character array with rational approximations of the entries. If you wish to use this output for your hand computations, you will need to remove temporarily the semicolon at the end of the command and re-run the code. Please keep this output suppressed for the submission. **First, your function has to check if the system Ax=0 has only the trivial solution, x=0. It happens if and only if there are no free variables (or equivalently, all columns of A are pivot columns). If this is the case, output the message: di sp('the homogeneous system has only the trivial solution) 7 and assign Cezeros in, 21 Display vector Chere and terminate the program. Hint: use a built-in MATLAB command rank in this part **If the system has nontrivial solutions, that is, there are free variables in the system (or equivalently, there are non-pivot columns in A), output a message the bomogeneous system has non-crivial lation, and your code will continue with constructing a basis for the solution set (the Null space of A). In order to proceed with this task, we will need to find the ordered sets of indexes of the pivot and non-pivot columns of A. The command that outputs the ordered set of indexes of the pivot columns is: 1.pivot_c)-rref The set of commands below outputs the ordered set of indexes of the non-pivot columns: nonpivot_cuse diff (3.pivot_e) The next set of commands output messages that list free variables. genomel (nonpivot_c); 3-119 {print free variable is xiiin, nonpivot_0(5) Include into your code all the commands listed above **After you have identified the free variables and non-pivot columns, you can begin to construct a basis for the solution set which will be formed by the columns of an nxq matrix C. Hint: Pre-locate matrix Cas C-zeros in.) and, then, recalculate its rows using matrices rref (x) and eye ig). You will make different assignments to the set of rows of C whose indexes are from the set pivot_c and to the set of rows of C whose indexes are from the set nonpivot_e (analyze your hand calculations!). **Finally, use a conditional statement to check whether the columns of Cindeed form a basis for the solution set of the homogeneous system. Since the number of columns of C is equal to the number of free variables in the system Ax 0, we only need to verify that the following two conditions hold: (1) the set of the columns of C is linearly independent (use the command rank here) (2) the columns of Care solutions of Ax = 0, or equivalently, AC is an mxq zero matrix (use here the function closetozeroroundort with pus). **If both conditions (1) and (2), hold your output will be: dispt'columns of C forma bald for solution set of homogeneous system') otherwise, an output message could be something like: "Mot bani? Impossible in this case, the empty output for C will stay. Receiving the last message should prompt you to look for errors in your code and correct them! This is the end of the function homobasis, 8 **Type the functions closetozeroroundoff and homobasis in your Live Script. **Run the function C-homobasis (A): on the following matrices: A= (1 -1 -1 2;-2 5 4 4] (b) A-11 2 -3) (c) A-magic (3) (d) A=[magic (3), ones (3,1)] (e) A=magic (4) 1(E) A-10 1 2 3;0 2 4 6] (g) A-101 0 2 0 3; 0 2 0 4 0 6; 0 4 0 8 0 6) A-11 0 2 0 3;2 0 5 0 61 (k) A=[1 0 0 2 3;2 0 0 4 6] (1) Arhilb (4)

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

Essential Data Protection For Estate Agencies In Singapore 2024

Authors: Yang Yen Thaw Yt

1st Edition

B0CQK79WD3, 979-8872095392

More Books

Students also viewed these Databases questions

Question

Sensor networks are a pervasive form of IoT. state true or false

Answered: 1 week ago