Answer the given question with a proper explanation and step-by-step solution.  Please provide solution in MATLAB.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Answer the given question with a proper explanation and step-by-step solution.

 Please provide solution in MATLAB. 

In this problem, you have to implement the Gaussian elimination method with partial pivoting for solving the linear system Ax = b. For the algorithm, please see the lecture notes or the
textbook.
1 function [x, An, bn] =GEpivot (A,b)
2 % This program employs the Gaussian elimination method with partial
3 % pivoting to solve the linear system Ax=b.
4 %
5 % Input
6 % A: coefficient square matrix
7 %
b: right side column vector
%
9 % Output
10 % x: solution vector
11 % An, bn: coefficient matrix and right hand side vector after row operations
12
13 % check the order of the matrix and the size of the vector
14 [m,n]
size (A);
15 if m ~= n
end
16
17 end
18 m = length (b);
19 if m= n
20
21
22
23 % elimination step
24 for k= 1:n-1
25
26
27
28
29
30
31
error('The matrix is not square.')
=
error('The matrix and the vector do not match in size.')
% Pivoting: Find the maximal element in column k, starting from row k, then swap that row with row k:
for ik+1:n
end
if abs (A(i, k)) > abs (A(k,k))
% Swap rows k and i if the leading entry A(k,k) is smaller than A(i,k) in magnitude
% COMPLETE THE ROW SWAPPING. DO NOT FORGET THE RIGHT HAND SIDE AS WELL
end
end
32
33
34
35
36
37
38
39 end
40
41 % Backsubstitution: Solve the upper triangular linear system.
42 x zeros(n,1);
43 x(n) = b(n)/A(n,n);
44 for in-1:-1:1
% Row elimination.
for ik+1:n
% PERFORM ROW OPERATION: multiply row k by -A(i,k) and added to row i to eliminate A(i,k). Note that the leading entry has been normalized to one.
% Do not forget the right hand side vector
% COMPLETE THIS LINE to compute the solution
45
46 end
47
48 An = A; bn = b; % save the echelon form of the coefficient matrix and the corresponding right hand side vector.
49
Code to call your function >
1 A = [4 2 2; 1 -3 1; 2 2 3]; b = [1; 1; 1];
2 [x, An, bn] = GEpivot (A,b)
Transcribed Image Text:In this problem, you have to implement the Gaussian elimination method with partial pivoting for solving the linear system Ax = b. For the algorithm, please see the lecture notes or the textbook. 1 function [x, An, bn] =GEpivot (A,b) 2 % This program employs the Gaussian elimination method with partial 3 % pivoting to solve the linear system Ax=b. 4 % 5 % Input 6 % A: coefficient square matrix 7 % b: right side column vector % 9 % Output 10 % x: solution vector 11 % An, bn: coefficient matrix and right hand side vector after row operations 12 13 % check the order of the matrix and the size of the vector 14 [m,n] size (A); 15 if m ~= n end 16 17 end 18 m = length (b); 19 if m= n 20 21 22 23 % elimination step 24 for k= 1:n-1 25 26 27 28 29 30 31 error('The matrix is not square.') = error('The matrix and the vector do not match in size.') % Pivoting: Find the maximal element in column k, starting from row k, then swap that row with row k: for ik+1:n end if abs (A(i, k)) > abs (A(k,k)) % Swap rows k and i if the leading entry A(k,k) is smaller than A(i,k) in magnitude % COMPLETE THE ROW SWAPPING. DO NOT FORGET THE RIGHT HAND SIDE AS WELL end end 32 33 34 35 36 37 38 39 end 40 41 % Backsubstitution: Solve the upper triangular linear system. 42 x zeros(n,1); 43 x(n) = b(n)/A(n,n); 44 for in-1:-1:1 % Row elimination. for ik+1:n % PERFORM ROW OPERATION: multiply row k by -A(i,k) and added to row i to eliminate A(i,k). Note that the leading entry has been normalized to one. % Do not forget the right hand side vector % COMPLETE THIS LINE to compute the solution 45 46 end 47 48 An = A; bn = b; % save the echelon form of the coefficient matrix and the corresponding right hand side vector. 49 Code to call your function > 1 A = [4 2 2; 1 -3 1; 2 2 3]; b = [1; 1; 1]; 2 [x, An, bn] = GEpivot (A,b)
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Sorting
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education