lecture22

lecture22 - 1.00 Lecture 22 November 1 2005 Systems of...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
1.00 Lecture 22 November 1, 2005 Systems of Linear Equations Systems of Linear Equations x 3x 0 + x 1 -2 x 2 = 5 2x 0 + 4x 1 + 3x 2 = 35 0 -3 x 1 = -5 3 1 -2 5 x 0 2 4 3 35 x 1 = 1 -3 0 -5 x 2 A x = b 3 x 3 3 x 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Algorithm to Solve Linear System x 0 x 1 x 2 x 0 x 1 x 2 x 0 x 1 x 2 = = = b 0 b 1 b 2 b’ 0 b’ 1 b’ 2 b’ 0 b’ 1 b’ 2 0 0 0 0 0 0 A’ x A’ x x 2 x 1 x 0 =a ij A x b Create matrix Forward solve Back solve b’ b’ Gaussian Elimination: Forward Solve Form Q for convenience 3 1 -2 5 Do elementary row ops: 2 4 3 35 Q= Multiply rows 1 -3 0 -5 Add/subtract rows A b Make column 0 have zeros below diagonal Pivot= 2/3 3 1 -2 5 Pivot= 1/3 0 10/3 13/3 Row 1’= row 1 - (2/3) row 0 0 -10/3 2/3 95/3 Row 2’= row 2 - (1/3) row 0 -20/3 Make column 1 have zeros below diagonal 3 1 -2 5 Pivot= 1 0 10/3 13/3 95/3 0 0 15/3 Row 2’’= row 2’ + 1 * row 1 75/3 2
Background image of page 2
Gaussian Elimination: Back Solve 3 1 -2 5 0 10/3 13/3 95/3 0 0 15/3 75/3 3 1 -2 5 0 10/3 13/3 95/3 0 0 15/3 75/3 3 1 -2 5 0 10/3 13/3 95/3 0 0 15/3 75/3 (15/3)x 2 =(75/3) x 2 = 5 (10/3)x 1 + (13/3)*5= (95/3) x 1 = 3 3x 0 x 0 = 4 + 1*3 - 2*5 = 5 A Complication 0 1 -2 5 2 4 3 35 Row 1’= row 1 - (2/0) row 0 1 -3 0 -5 Exchange rows: put largest pivot element in row: 2 4 3 35 1 -3 0 -5 0 1 -2 5 Do this as we process each column. If there is no nonzero element in a column, matrix is not full rank. 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Gaussian Elimination public static void gaussian(Matrix a, Matrix b, Matrix x) { int i, j, n; n= a.getNumRows(); // Number of unknowns Matrix q= new Matrix(n, n+1); for (i=0; i < n; i++) { for (j=0; j < n; j++) // Form q matrix // q(i,j)= a(i,j) q.setElement(i, j, a.getElement(i, j)); // q(i,n)= b(i,0) q.setElement(i, n, b.getElement(i, 0)); } forward_solve(q); // Do Gaussian elimination back_solve(q); // Perform back substitution for (i=0; i<n; i++) // x(i,0)= q(i,n) x.setElement(i, 0, q.getElement(i, n)); } private static void forward_solve(Matrix q) { int i, j, k, maxr, n; double t, pivot; n= q.getNumRows(); for (i=0; i < n; i++) { // Find row w/max element in this maxr= i; // column, at or below diagonal for (j= i+1; j < n; j++) if (Math.abs(q.getElement(j,i)) > Math.abs(q.getElement(maxr,i))) maxr= j; if (maxr != i) // If row not current row, swap for (k=i; k <= n; k++) { t= q.getElement(i,k); // t= q(i,k) // q(i,k)= q(maxr, k) q.setElement(i,k, q.getElement(maxr, k)); q.setElement(maxr, k, t); // q(maxr, k)= t } for (j= i+1; j <n; j++)
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/29/2011 for the course CIVIL 1.00 taught by Professor Georgekocur during the Spring '05 term at MIT.

Page1 / 12

lecture22 - 1.00 Lecture 22 November 1 2005 Systems of...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online