1 / 31

Matrices MM1 module 3, lecture 3

Matrices MM1 module 3, lecture 3. David Godfrey. Matrices lecture 3 objectives. After this lecture you should have a clear understanding of: Solving linear equations in 2 variables; Solving linear equations in 3 variables; Gaussian elimination for solving linear equations in n variables;

sveta
Download Presentation

Matrices MM1 module 3, lecture 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MatricesMM1 module 3, lecture 3 David Godfrey

  2. Matrices lecture 3 objectives • After this lecture you should have a clear understanding of: • Solving linear equations in 2 variables; • Solving linear equations in 3 variables; • Gaussian elimination for solving linear equations in n variables; • Ill-conditioning; • The nature of solutions for linear equations.

  3. Linear equations… • A set of n linear equations in n variables, xican be written in matrix form, Ax = b:

  4. …Linear equations • e.g. the 2  2 system of linear equations • can be written in matrix form, Ax = b: • To solve, we premultiply the equation by A–1, A–1Ax = A–1b, giving x = A–1b:

  5. Matrix equations… • We can use this method for matrix equations of the form AX = B: e.g. find the matrix X if • We can get rid of the matrix to the left of X by premultiplying each side of the equation by the inverse • Thus

  6. …Matrix equations • Similarly for XA = B: e.g. find the matrix X if • We can remove matrix A by postmultiplying each side of the equation by its inverse, A–1 • Thus

  7. Solving n nlinear equations • We can solve a general system of n nlinear equations by writing it in matrix form, AX = B, and premultiplying the matrix equation by the inverse of the matrix of coefficients, A–1. • i.e. if AX = Bthen A–1AX = A–1B, but A–1A = Iso X = A–1B • However, this method is almost never used because it is inefficient and prone to rounding errors. • We shall investigate Gaussian elimination, a more efficient and accurate method for solving linear equations.

  8. Visualising n nlinear equations • 3 variables • Solution is at the intersection of 3 planes • 2 variables • Solution is at the intersection of 2 lines

  9. Gaussian elimination… • Consider a system of 3  3 linear equations in matrix form, Ax = b: • To make book-keeping simpler, we represent the system by an augmented matrix:

  10. …Gaussian elimination… • We can zero the first column by subtracting a21/a11 times the first row from the second row, and subtracting a31/a11 times the first row from the third row (primes indicate changed values) • Similarly, we can now zero the second column by subtracting a’32/a’22 times the first row from the third row (double primes indicate changed values), forming an upper triangular matrix:

  11. …Gaussian elimination… • The last row represents an equation in a single variablea”33x3 = b”3which can be solved as x3 = b”3 / a”33 • The second row represents an equation in two variablesa’22x2 + a’23x3 = b’2 • Since the variable x3 has already been found in the previous step, x2 can be solved asx2 = (b’2 – a’23x3) / a’22

  12. …Gaussian elimination • The first row represents an equation in three variablesa11x1 + a12x2 + a13x3 = b1 • Since the variables x2 and x3 have already been found in the previous steps, x1 can be solved asx1 = (b1 –  a12x2 – a13x3) / a11 • This process of solving an upper triangular matrix equation is called back substitution.

  13. Gaussian elimination: example 1… • Solve the system of equations • Represent the system as an augmented matrix: • We introduce a lower triangular matrix, L, to record row multipliers in the • positions

  14. …Gaussian elimination: example 1… • Calculate the row multipliers and record them in the L matrix, l21 = a21/a11 and l31 = a31/a11 • Zero the first column by subtracting l21 = a21/a11 times the first row from the second row, and subtracting l31 = a31/a11 times the first row from the third row

  15. …Gaussian elimination: example 1… • Calculate the row multiplier and record it in the L matrix, l32 = a’32/a’22 • Zero the second column by subtracting l32 = a’32/a’22 times the second row from the third row, forming an upper triangular matrix

  16. …Gaussian elimination: example 1 • Back substitute • The last row represents an equation in a single variable, a”33z = b”3, which can be solved as z = b”3 / a”33 = –7 / –7 = 1 • The second row represents an equation in two variables, a’22y + a’23z = b’2, which can be solved asy = (b’2 – a’23z) / a’22 = (–6 + 2) / (–2) = 2 • The first row represents an equation in three variablesa11x + a12y + a13z = b1, which can be solved asx1 = (b1 –  a12y – a13z) / a11 = (4 – 2 – 1) / 1 = 1 • The solution is thus x = 1, y = 2, z = 1.

  17. Gaussian elimination: example 2… • Solve the system of equations • Represent the system as an augmented matrix:

  18. …Gaussian elimination: example 2… • Calculate the row multipliers and record them in the L matrix, l21 = a21/a11 and l31 = a31/a11 • Zero the first column by subtracting l21 = a21/a11 times the first row from the second row, and subtracting l31 = a31/a11 times the first row from the third row

  19. …Gaussian elimination: example 2… • Calculate the row multiplier and record it in the L matrix, l32 = a’32/a’22 • Zero the second column by subtracting l32 = a’32/a’22 times the second row from the third row, forming an upper triangular matrix

  20. …Gaussian elimination: example 2 • Back substitute • The last row can be solved as z = b”3 / a”33 = 0.6 / 0.3 = 2 • The second row can be solved asy = (b’2 – a’23z) / a’22 = (–11 + 6) / (–5) = 1 • The first row can be solved asx = (b1 – a12y – a13z) / a11 = (7 – 5 – 6) / 2 = –2 • The solution is thus x = –2, y = 1, z = 2.

  21. Gaussian elimination: example 3… • Solve the system of equations • Work to 4 significant figures and give the answer to 3. Check the answer by substituting into the original equation. • Represent the system as an augmented matrix:

  22. …Gaussian elimination: example 3… • Calculate the row multipliers and record them in the L matrix, l21 = a21/a11 and l31 = a31/a11 • Zero the first column by subtracting l21 times the first row from the second row, and subtracting l31 times the first row from the third

  23. …Gaussian elimination: example 3… • Calculate the row multiplier and record it in the L matrix, l32 = a’32/a’22 • Zero the second column by subtracting l32 = a’32/a’22 times the second row from the third row, forming an upper triangular matrix

  24. …Gaussian elimination: example 3… • Back substitute • The last row can be solved as z = –39,880,000 / –200,400,000 = 5.025 • The second row can be solved asy = (–200,000 + 199,995) / (0.001) = –5,000 • The first row can be solved asx = (b1 – a12y – a13z) / a11 = (10 + 0.5 – 9.99975) / 0.0001 = 5,003 • The computed solution is thus x = 5,003, y = –5,000, z = 5.03

  25. …Gaussian elimination: example 3 • Check the computed solution against the original equations • Numerical rounding has caused these errors. • Working to more significant figures givesx = –7.939 c.f. 5,000y = 5.922 c.f. –5,000z = 5.025 c.f. 5.03

  26. Geometric interpretation • Ill-conditioning, as seen in example 3, can be interpreted geometrically: • The shaded red area represents uncertainty in the lines’ positions due to rounding errors. • The solid red area represents where the intersection may be found due to these errors. • The closer to parallel the lines are, the larger the possible error.

  27. Geometric interpretation: 1 solution • Gaussian elimination to the formwhere none of the diagonal elements are zero • We get the usual form of the augmented matrix and can fine a unique solution by back substitution

  28. Geometric interpretation: 0 solution • Gaussian elimination to the formwhere b3 is not zero • We end up with 0 z = non-zeroi.e. no solution can exist because at least 2 planes, or 3 lines of intersection, are parallel

  29. Geometric interpretation: ∞ solution • Gaussian elimination to the formi.e. b3 is zero • We end up with 0 z = zeroi.e. an infinite number of solutions exist because this is always true for any value of z

  30. Examples • Performing Gaussian elimination brings us to the augmented matrices shown. Discuss the nature of the solutions • 1 z = 1  z = 1Unique solution • 0 z = 1 ???No solution • 0 z = 0 !!!Infinite solutions

  31. Matrices lecture 3 objectives • After this lecture you should have a clear understanding of: • Solving linear equations in 2 variables; • Solving linear equations in 3 variables; • Gaussian elimination for solving linear equations in n variables; • Ill-conditioning; • The nature of solutions for linear equations.

More Related