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

Info icon This 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 - 2x 2 = 5 2x 0 + 4x 1 + 3x 2 = 35 0 - 3x 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 3 x 1 1
Image of page 1

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

View Full Document Right 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
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
Image of page 3

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

View Full Document Right 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++) // Calculate pivot ratio { pivot= q.getElement(j,i)/q.getElement(i,i);
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern