Write a program in Matlab that solves linear systems of equations using Gauss elimination with partial pivoting. Make sure that you use variables that are explicit, and make sure to include comment lines (each subroutine should have at least a sentence stating what it does). Make sure that your program checks for valid inputs in matrix and vectors dimensionality.
• Using your code, solve the systems of equations in problems 9.11, 9.12, and 9.13
9.11
9.12
9.13
Consider the following system of linear equations:
A1x + B1y + C1z = D1 . . . . . . . ( 1 )
A2x + B2y + C2z = D2 . . . . . . . . ( 2 )
A3x + B3y + C3z = D3 . . . . . . . . . . ( 3)
In order to apply Gauss elimination method, we need to express the above three linear equations in matrix form as given below:
A = | A1 B1 C1 |
|A2
B2 C2 |
| A3
B3 C3 |
B= D1
D2
D3
Arrange matrices A and B in the following form (augmented
matrix):
|
A1 B1 C1 D1|
|A2
B2 C2 D2|
| A3
B3 C3 D3|
As per that given matrix is
9.11)
2 -6
-1
-3 -1 7
-8 1 -2
-38
-34
-20
9.12)
2
1 -1
5
2 2
3
1 1
1
-4
5
9.13)
1
1 -1
6
2 2
-3
4 1
-3
2
1
program:
function C = gauss_elimination(A,B) % defining the
function
A= [ 2 -6 -1; -3 -1 7; -8 1 -2] % Inputting the value of
coefficient matrix 9.11
B = [-38; -34; -20] % % Inputting the value of coefficient matrix
9.11
i = 1; % loop variable
X = [ A B ];
[ nX mX ] = size( X); % determining the size of
matrix
while i <= nX % start of loop
if X(i,i) == 0 %
checking if the diagonal elements are zero or not
disp('Diagonal element zero') % displaying the result if there
exists zero
return
end
X = elimination(X,i,i);
% proceeding forward if diagonal elements are non-zero
i = i +1;
end
C = X(:,mX);
function X = elimination(X,i,j)
% Pivoting (i,j) element of matrix X and eliminating other
column
% elements to zero
[ nX mX ] = size( X);
a = X(i,j);
X(i,:) = X(i,:)/a;
for k = 1:nX % loop to find triangular form
if k == i
continue
end
X(k,:) = X(k,:) - X(i,:)*X(k,j); % final
result
end
Write a program in Matlab that solves linear systems of equations using Gauss elimination with pa...
Use the Gaussian elimination method to solve each of the following systems of linear equations. In each case, indicate whether the system is consistent or inconsistent. Give the complete solution set, and if the solution set is infinite, specify three particular solutions. 1-5x1 – 2x2 + 2x3 = 14 *(a) 3x1 + x2 – x3 = -8 2x1 + 2x2 – x3 = -3 3x1 – 3x2 – 2x3 = (b) -6x1 + 4x2 + 3x3 = -38 1-2x1 +...
Solve the following system of equations using LU decomposition with partial pivoting:2x1−6x2–x3=−38,−3x1–x2+6x3=−34,−Solve the following system of equations using LU decomposition with partial pivoting:2x1−6x2–x3=−38,−3x1–x2+6x3=−34,−8x1+x2−2x3=−40
Solve the system of linear equations using the Gauss-Jordan elimination method. 3x1 2x2X316 x1 + 2x2 + 2x3 = 12 (X1, X2, X3) =
Using the Gauss-Seidel Method to solve the equations in the same order listed below with an initial guess of x1 = X2 = X3 = 1, what is the estimated value of x2 after 1 iteration? -8x1 + x2 - 2x3 = -20 2x1 - 6x2 - x3 = -38 -3x1 - x2 + 7x3 = -34 0 6.50 O 6.96 0 100 0 2.38
3 Linear systems 18. Solve the linear system of equations using the Naive Gauss elimination method x,+x: + x) = 1 +2x, +4x1 x 19. Solve the linear system of equations using the Gauss elimination method with partial pivoting 12x1 +10x2-7x3=15 6x, + 5x2 + 3x3 =14 24x,-x2 + 5x, = 28 20. Find the LU decomposition for the following system of linear equations 6x, +2x, +2, 2 21. Find an approximate solution for the following linear system of equations...
4. Solve the following system of linear equations using Gauss-Jordan elimination: X1 + 32 - 2x3 + 24 + 3x5 = 1 2x 1 - X2 + 2x3 + 2x4 + 6x5 = 2 3x1 + 2x2 - 4x3 - 3.24 - 9.25 = 3
2. Solve the following linear systems of equations by writing the system as a matrix equation Ax = b and using the inverse of the matrix A. (You may use a calculator or computer software to find A-1. Or you can find A-1 by row-reduction.) 3x1 – 2x2 + 4x3 = 1 x1 + x2 – 2x3 = 3 2x1 + x2 + x3 = 8 321 – 2x2 + 4x3 = 10 X1 + x2 – 2x3 = 30...
need help on number 13
Exercises 11-16. Represent each linear system in marrix form. Solve by Gauss elimination when the system is consistent and cross-check by substituting your solution set back into all equations. Interpret the solution geometrically in terms planes in R3. of 2x1 +3x2 x3 = 1 4x1 7x2+ 3 3 11. 7x1 +10x2 4x3 = 4 3x1 +3x2+x3 =-4.5 12. x1+ x2+x3 = 0.5 2x-2x2 5.0 x+2x2 3x3 1 3x1+6x2 + x3 = 13 13. 4x1 +8x2...
Solve the given system of equations using either Gaussian or Gauss-Jordan elimination x1 + 2x2-3x3 = 19 2x1 -X2+ X3 - 4X1- x2 + x3= 8
3. Solve the following systems of equations using Gaussian elimination. (a) 2x 3x2 + 2x3 = 0 (d) 2x + 4x2 2.xz 4 *- x2 + x3 = 7 X; - 2x2 · 4x3 = -1 -X, + 5x2 + 4x3 = 4 - 2x - X2 3x3 = -4