[Content_Types].xml
_rels/.rels
matlab/document.xml
matlab/output.xml
metadata/coreProperties.xml
metadata/mwcoreProperties.xml
metadata/mwcorePropertiesExtension.xml
metadata/mwcorePropertiesReleaseInfo.xml
Direct Methods: Gaussian Elimination In this livescript, you will learn how To use Gaussian elimination to reduce a matrix to row-echelon form Write a piece of code that implements the method. In Linear Algebra, Gaussian elimination is a method of solving systems of linear equations. The idea behind the method is that for a linear system, for example 2x-3y+5z=10 4x+7y-2z=-5 2x-4y+25z=31 Equation 1. We are allowed to: Swap the order of the equation Multiply each equation by a constant Add and subtract equations to one another So, putting this into practice. The augmented matrix \pmatrix{a_{11} & a_{12} & a_{13} & c_{1} \cr a_{21} & a_{22} & a_{23} & c_{2} \cr a_{31} & a_{32} & a_{33} & c_{3}} Equation 2. is given by A = [2 -3 5;4 7 -2;2 -4 25];
c = [10;-5;31];
aug = [A c] Our aim is to reduce this matrix into upper triangular form \pmatrix{a_{0} & a_{1} & a_{2} & a_{3} \cr 0 & a_{4} & a_{5} & a_{6} \cr 0 & 0 & a_{7} & a_{8}} Equation 3. So that we can back substitute to obtain the solution. Part 1: (a) Use back substitution to find the solution of the general system defined by Eq. (3). Let’s try this out with Eq. (1). aug Now, to get rid of the leading first entry of the second row, we can subtract it by 2 times the first row aug(2,:) = aug(2,:)-(aug(2,1)/aug(1,1))*aug(1,:) And similarly with the third row aug(3,:) = aug(3,:)-(aug(3,1)/aug(1,1))*aug(1,:) For the final row, getting rid of the leading entry gives aug(3,:) = aug(3,:)-(aug(3,2)/aug(2,2))*aug(2,:) Now that the matrix is in row-echelon form, we can perform back substitution to solve the system. Using your solution to part (a), we find x3 = aug(3,4)/aug(3,3)
x2 = (-aug(2,3)*x3+aug(2,4))/aug(2,2)
x1 = (-aug(1,2)*x2-aug(1,3)*x3+aug(1,4))/aug(1,1) (b) Redo this example by hand. Numerical Implementation The following code implements Gaussian elimination to Eq. (1). Part 2: (a) Run the code and understand what each line does. A = [2 -3 5;4 7 -2;2 -4 25];
c = [10;-5;31];
AC = [A c];
[nrow ncol] = size(AC);
for k = 1:nrow
for i = 1:nrow
if i > k
const = AC(i,k)/AC(k,k);
for j =1:ncol
AC(i,j) = AC(i,j) – const*AC(k,j);
end
end
end
end
AC (b) Rerun the code for the system of equations \pmatrix{1 & 7 & 9\cr 1 & 7 & 3 \cr 4 & 3 & 2}
\pmatrix{x_{1} \cr x_{2} \cr x_{3}}
=
\pmatrix{1 \cr 1 \cr 1} What’s happening? How could his be remedied?
manual code ready 0.4 true false A = [2 -3 5;4 7 -2;2 -4 25]; 0 21 21 false false c = [10;-5;31]; 1 22 22 false true aug = [A c] 2 24 24 true true aug 3 37 37 true true aug(2,:) = aug(2,:)-(aug(2,1)/aug(1,1))*aug(1,:) 4 40 40 true true aug(3,:) = aug(3,:)-(aug(3,1)/aug(1,1))*aug(1,:) 5 43 43 true true aug(3,:) = aug(3,:)-(aug(3,2)/aug(2,2))*aug(2,:) 6 46 46 true false x3 = aug(3,4)/aug(3,3) 7 49 49 false false x2 = (-aug(2,3)*x3+aug(2,4))/aug(2,2) 8 50 50 false true x1 = (-aug(1,2)*x2-aug(1,3)*x3+aug(1,4))/aug(1,1) 9 51 51 true false A = [2 -3 5;4 7 -2;2 -4 25]; 10 59 59 false false c = [10;-5;31]; 11 60 60 false false AC = [A c]; 12 61 61 false false [nrow ncol] = size(AC); 13 62 62 false false for k = 1:nrow
for i = 1:nrow
if i > k
const = AC(i,k)/AC(k,k);
for j =1:ncol
AC(i,j) = AC(i,j) – const*AC(k,j);
end
end
end
end 14 64 73 false true AC 15 75 75 true false Ak = [2 -3 5;4 7 -2;2 -4 25]; 16 80 80 false false c = [10;-5;31]; 17 80 80 false false Ak\c 18 80 80 false false Ab = [Ak c]; 19 80 80 false false Ab(2,:) = Ab(2,:) – 2*Ab(1,:); 20 80 80 false false Ab(3,:) = Ab(3,:) – Ab(1,:); 21 80 80 false false Ab(3,:) = Ab(3,:) + 1/13*Ab(2,:); 22 80 80 false true Ab 23 80 80
2020-03-20T03:36:29Z 2020-03-20T10:41:12Z
application/vnd.mathworks.matlab.code MATLAB Code R2019b
9.7.0.1183724 837d93d7-ce4c-4dc3-95a0-a4474a0f0f37
9.7.0.1296695
R2019b
Update 4
Jan 20 2020
3546228467