Answer the given question with a proper explanation and step-by-step solution. Please provide solution in MATLAB.
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
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)](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ff7cb6215-048b-47a5-b28f-7c86abf1a0e4%2Fcd67eabe-317b-4e4c-8d35-b3e138eb7a58%2Fmkui8mu_processed.png&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
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](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education