Question

In: Advanced Math

2. (Solving linear systems) Consider the linear system Ax = b with A =[14 9 14...

2. (Solving linear systems)

Consider the linear system Ax = b

with A =[14 9 14 6 -10;-11 -11 5 8 6;15 -2 -14 8 -15;14 13 11 -3 -7;0 9 13 5 -14], and . b = [-4;8;6;0;10].

a) Verify that the linear system has a unique solution. Hint: use rref, rank, det, or any other Matlab method. Briefly explain the answer please.

You'll now solve Ax = b in three different ways. Store the three different solutions in four different variables (x1,x2,x3,x4, say), we need to compare them in parts c and d.

b1) Using rref, determine the solution x of the system Ax = b, and store it in variable x1. Hint: x1 is the final column of the reduced row echelon form of M = (A|b). Remember horzcat.

b2) Using Matlab's linsolve method, find a solution to the system Ax = b. Store the solution in x2.

b3) Using Matlab's inverse method (^(-1) or inv), solve the system as x = A^(-1)b, store the result in x3.

b4) Use the rref method from class to find an inverse matrix B of A. Use that to calculate x = Bb. Store the result in x4.

c) Compare the solutions x1, x2, x3,x4. Do any two of them agree? Does that contradict a) or not?

d) Try ranking the solutions by quality. To do so, compute Ax-b, for the various values of x, and see which x produces the smallest difference between Ax and b.

Solutions

Expert Solution


%%Matlab code for solving linear system
clear all
close all

%A matrix
A = [14 9 14 6 -10;-11 -11 5 8 6;15 -2 -14 8 -15;14 13 11 -3 -7;0 9 13 5 -14];
b = [-4;8;6;0;10];
%determinant of A
dt=det(A);
fprintf('Determinant of A=%f\n',dt)
fprintf('As determinant of A is nonzero hence linear system has unique solution.\n')

%Augmented matrix
Ag=A;
Ag(:,6)=b;

%Solution using rref
rA=rref(Ag);
fprintf('rref of Ag=\n')
disp(vpa(rA,3))
fprintf('Solution using rref is \n')
disp(rA(:,end))
x1=squeeze((rA(:,end)));

%Solution using linsolve
lA=linsolve(A,b);
fprintf('Solution using linsolve is \n')
disp(lA)
x2=squeeze(lA);

%Solution using inverse
inA=inv(A)*b;
fprintf('Solution using inverse is \n')
disp(inA)
x3=inA;

%Solution using rref inverse
I=eye(5,5);
Arr=[A I];
bb=rref(Arr);
B=squeeze(bb(:,6:end));
fprintf('Solution using rref inverse is \n')
disp(B*b)
x4=B*b;

fprintf('\tError in rref solution =%e\n',norm(A*x1-b));
fprintf('\tError in linsolve solution =%e\n',norm(A*x2-b));
fprintf('\tError in inverse solution =%e\n',norm(A*x3-b));
fprintf('\tError in rref inverse solution =%e\n',norm(A*x4-b));

%%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%


Related Solutions

Make the program(such as matlab) for solving the linear system Ax = b using the Naive-Gaussian...
Make the program(such as matlab) for solving the linear system Ax = b using the Naive-Gaussian elimination & also the Gaussian elimination with partial pivoting.
If an SPL ( LINEAR EQUATION SYSTEM ) is known: Ax = b. A is a...
If an SPL ( LINEAR EQUATION SYSTEM ) is known: Ax = b. A is a matrix sized m × n and b is a vector sized m × 1, with the component values of matrix A and vector b known. The x vector is n × 1 and the component values are unknown. Explain how the possible solution of SPL Ax = b. i want answer for the question , and what he mean by (the component values of...
Question: Describe the various methods of solving linear systems. With which method of solving linear systems...
Question: Describe the various methods of solving linear systems. With which method of solving linear systems are you most comfortable, and why? Hint: First, define a linear system, and give an example. Then, discuss the methods, and show the steps to solve your example. Finally, talk about advantages and drawbacks of each method. "Real-Life" Relationship: Any relationship where we have a fixed cost and variable cost can be represented by a linear equation. For instance, the cost of a rental...
A linear system of equations Ax=b is known, where A is a matrix of m by...
A linear system of equations Ax=b is known, where A is a matrix of m by n size, and the column vectors of A are linearly independent of each other. Please answer the following questions based on this assumption, please explain all questions, thank you~. (1) Please explain why this system has at most one solution. (2) To give an example, Ax=b is no solution. (3) According to the previous question, what kind of inference can be made to the...
Solve the linear system of equations Ax = b, and give the rank of the matrix...
Solve the linear system of equations Ax = b, and give the rank of the matrix A, where A = 1 1 1 -1 0 1 0 2 1 0 1 1 b = 1 2 3
Exercise 3 Part 1. Solving a system Ax = b **Create a function in MATLAB that...
Exercise 3 Part 1. Solving a system Ax = b **Create a function in MATLAB that begins with: function [C,N]=solvesys(A) [~,n]=size(A); b=fix(10*rand(n,1)) format long We are using format long to display a number in exponent format with 15 digit mantissas. If later on, you will need to switch back to the default format, type and run format The input is an matrix A. If A is invertible, the outputs are the matrix C, whose 3 columns x1, x2, x3 are...
Write a function to solve a system of linear equations of the form Ax= b using...
Write a function to solve a system of linear equations of the form Ax= b using the iterative Gauss-Seidel method. You are free to use any basic MATLAB operation to implement the algorithm (i.e. you may use any combination of loops, indexing, math, etc.), but avoid “built-in” solution methods — you would not be allowed to use the GaussSeidel function if such a function existed. The function must also test for a number of possible issues. If an issue is...
Consider the linear transformation T : P1 → R^3 given by T(ax + b) = [a+b...
Consider the linear transformation T : P1 → R^3 given by T(ax + b) = [a+b a−b 2a] a) find the null space of T and a basis for it (b) Is T one-to-one? Explain (c) Determine if w = [−1 4 −6] is in the range of T (d) Find a basis for the range of T and its dimension (e) Is T onto? Explain
Consider the system of linear equations: 3? − 5? + 2? = 2 2? − ?...
Consider the system of linear equations: 3? − 5? + 2? = 2 2? − ? + 3? = 3 ? + 4? + 7? = 4 (a) Write the augmented matrix for the above system. (b) Find the inverse of the coefficient matrix. (c) Find the determinant of the coefficient matrix. (d) Find the LU-factorization of the coefficient matrix. (e) Solve the above system using Gauss-Jordan elimination. (f) Use the inverse of the coefficient matrix from part (b) to...
2.) By Theorem 3.23 of the text, the linear diophantine equation of the form ax +...
2.) By Theorem 3.23 of the text, the linear diophantine equation of the form ax + by = c has no integral solutions if c is not divisible by (a, b), the greatest common divisor of a and b. On the other hand if (a, b) divides c, then we can use the Extended Euclidean Algorithm to find integers s, t such that sa + tb = (a, b); multiplying through by the correct factor gives an integral solution x,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT