MA/CS 375 Fall 20021 MA/CS 375 Fall 2002 Lecture 18 Sit in your groups.

Slides:



Advertisements
Similar presentations
Chapter 2 Solutions of Systems of Linear Equations / Matrix Inversion
Advertisements

Linear Algebra Applications in Matlab ME 303. Special Characters and Matlab Functions.
Numerical Analysis 1 EE, NCKU Tien-Hao Chang (Darby Chang)
MATH 685/ CSI 700/ OR 682 Lecture Notes
Scientific Computing Linear Systems – Gaussian Elimination.
Solving Linear Systems (Numerical Recipes, Chap 2)
LU Factorization LU-factorization Matrix factorization Forward substitution Back substitution.
Systems of Linear Equations
Lecture 9: Introduction to Matrix Inversion Gaussian Elimination Sections 2.4, 2.5, 2.6 Sections 2.2.3, 2.3.
Chapter 9 Gauss Elimination The Islamic University of Gaza
Lecture 11 - LU Decomposition
Section 2.3 Gauss-Jordan Method for General Systems of Equations
1cs542g-term Notes  Assignment 1 will be out later today (look on the web)
1cs542g-term Notes  Assignment 1 is out (questions?)
Linear Algebraic Equations
Analysis of Triangular Factorization Lecture #8 EEE 574 Dr. Dan Tylavsky.
Solving systems using matrices
Linear Systems What is the Matrix?. Outline Announcements: –Homework III: due Wed. by 5, by Office Hours: Today & tomorrow, 11-1 –Ideas for Friday?
MECH300H Introduction to Finite Element Methods Lecture 2 Review.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 17 Solution of Systems of Equations.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 14 Elimination Methods.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 15 Solution of Systems of Equations.
ECIV 520 Structural Analysis II Review of Matrix Algebra.
Algorithm for Gauss elimination 1) first eliminate for each eq. j, j=1 to n-1 for all eq.s k greater than j a) multiply eq. j by a kj /a jj b) subtract.
ECIV 301 Programming & Graphics Numerical Methods for Engineers REVIEW II.
MOHAMMAD IMRAN DEPARTMENT OF APPLIED SCIENCES JAHANGIRABAD EDUCATIONAL GROUP OF INSTITUTES.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 18 LU Decomposition and Matrix Inversion.
Systems of Linear Equations
Computational Methods in Physics PHYS 3437 Dr Rob Thacker Dept of Astronomy & Physics (MM-301C)
Chapter 10 Review: Matrix Algebra
Scientific Computing Linear Systems – LU Factorization.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Solving Scalar Linear Systems Iterative approach Lecture 15 MA/CS 471 Fall 2003.
Square n-by-n Matrix.
Linear Systems Gaussian Elimination CSE 541 Roger Crawfis.
Using LU Decomposition to Optimize the modconcen.m Routine Matt Tornowske April 1, 2002.
Solving Scale Linear Systems (Example system continued) Lecture 14 MA/CS 471 Fall 2003.
Introduction to Numerical Analysis I MATH/CMPSC 455 PA=LU.
Lesson 13-1: Matrices & Systems Objective: Students will: State the dimensions of a matrix Solve systems using matrices.
Trigonometric Equations M 140 Precalculus V. J. Motto.
MA/CS 375 Fall MA/CS 375 Fall 2003 Lecture 19.
2.5 - Determinants & Multiplicative Inverses of Matrices.
Chapter 3 Solution of Algebraic Equations 1 ChE 401: Computational Techniques for Chemical Engineers Fall 2009/2010 DRAFT SLIDES.
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 31.
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 21.
Lecture 8 Matrix Inverse and LU Decomposition
Lecture 7 - Systems of Equations CVEN 302 June 17, 2002.
Linear algebra: matrix Eigen-value Problems Eng. Hassan S. Migdadi Part 1.
Chapter 5 MATRIX ALGEBRA: DETEMINANT, REVERSE, EIGENVALUES.
Elliptic PDEs and the Finite Difference Method
Lesson 3 CSPP58001.
MA/CS 375 Fall 2002 Lecture Summary Week 1  Week 7.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 7.
Linear Systems What is the Matrix?. Outline Announcements: –Homework III: due Today. by 5, by –Ideas for Friday? Linear Systems Basics Matlab and.
Chapter 9 Gauss Elimination The Islamic University of Gaza
ECE 530 – Analysis Techniques for Large-Scale Electrical Systems Prof. Hao Zhu Dept. of Electrical and Computer Engineering University of Illinois at Urbana-Champaign.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 6.
Problems in solving generic AX = B Case 1: There are errors in data such that data cannot be fit perfectly (analog: simple case of fitting a line while.
Unit #1 Linear Systems Fall Dr. Jehad Al Dallal.
Numerical Computation Lecture 6: Linear Systems – part II United International College.
Simultaneous Linear Equations
Spring Dr. Jehad Al Dallal
Linear Equations.
Linear Algebra Lecture 15.
MA/CS 375 Spring 2002 Lecture 19 MA/CS 375 Fall 2002.
MATLAB EXAMPLES Matrix Solution Methods
Lecture 13 Simultaneous Linear Equations – Gaussian Elimination (2) Partial Pivoting Dr .Qi Ying.
Major: All Engineering Majors Authors: Autar Kaw
Lecture 8 Matrix Inverse and LU Decomposition
Ax = b Methods for Solution of the System of Equations (ReCap):
Presentation transcript:

MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 18 Sit in your groups

MA/CS 375 Fall Projects? Demo from each group

MA/CS 375 Fall Matrices and Systems

MA/CS 375 Fall Recall Given a matrix M then if it exists the inverse of a matrix M-1 is that matrix which satisfies:

MA/CS 375 Fall Examples If what is If A is an NxN matrix how can we calculate its inverse ?

MA/CS 375 Fall More Examples If what is More generally when does an inverse exist

MA/CS 375 Fall Example (Problems Calculating an Inverse) Previously we saw how Matlab can get wrong answers when finite precision effects come into play (monsters) The same type of behavior can be seen when Matlab calculates the inverse of a matrix. Let’s consider the simple matrix:

MA/CS 375 Fall Example cont The exact inverse of A can be calculated as: Now let’s see how well Matlab does:

MA/CS 375 Fall Example cont The inverse of A can be calculated as: Now let’s see how well this exact solution works in Matlab:

MA/CS 375 Fall Example cont With this formulation of the product of A and its inverse only satisfies the definition to 6 decimal places for delta=0.001

MA/CS 375 Fall Example cont Now let us compare the answer Matlab gives us using inv(A):

MA/CS 375 Fall Example cont Now let us compare the answer Matlab gives us using inv(A): Looks pretty good, doesn’t it!

MA/CS 375 Fall Example cont But not so quick. Now try A*inv(A) Now Matlab is only good to 6 decimal places.

MA/CS 375 Fall Example comments So what it is it about this matrix which is causing this odd behaviour?. For small delta it is nearly singular. For those with some background the determinant of A is: i.e. the inverse of A nearly does not exist Matlab is actually solving for a matrix near to A

MA/CS 375 Fall Example team exercise Test the accuracy of Matlab’s inv(A) Team 1 use delta=1e-2 Team 2 use delta = 1e-4 Team 3 use delta = 1e-6 Team 4 use delta= 1e-9 Team 5 use delta = 1e-11 Try both A*inv(A) and inv(A)*A

MA/CS 375 Fall Solving Triangular Systems So let’s go back to basics. There are some systems of equations which are “easy” to solve. One example is a system with a triangular matrix structure.

MA/CS 375 Fall Lower Triangular Systems equationsmatrix form

MA/CS 375 Fall Lower Triangular Systems equations Volunteer to solve this? i.e. find x,y so that these two equations are satisfied

MA/CS 375 Fall Lower Triangular Systems equations 1)note that we can easily figure out x 2)then knowing x we can easily figure out y. 3)i.e. 2x = 1  x = ½ 4)3x+2y = 2  y = ½(2-3x) = ½(2-3/2) = 1/4

MA/CS 375 Fall Larger Problem Volunteers?. 1)on the board 2)using Matlab

MA/CS 375 Fall General Triangular System (matrix form)

MA/CS 375 Fall General Triangular System We can write down an algorithm to solve this problem using the “Forward substitution algorithm”:

MA/CS 375 Fall Forward Substitution Algorithm 1) Solve the 1 st equation 2) Use the value from step 1 to solve the 2 nd equation 3) Use the values from steps 1 and 2 to solve the 3 rd equation 4) keep going until you solve the whole system.

MA/CS 375 Fall Solving Triangular Systems in Matlab Given a lower triangular matrix L Given a vector b Solve Lx = b for the unknown vector x

MA/CS 375 Fall Solving Triangular Systems in Matlab In action: Given a lower triangular matrix L Given a vector b Solve Lx = b for the unknown vector x

MA/CS 375 Fall Solving Triangular Systems in Matlab Observations Given a lower triangular matrix L Given a vector b Solve Lx = b for the unknown vector x The algorithm scales as O(N 2 ) We relied on the diagonal terms of L to be non-zero What happens if there is a zero diagonal term ?

MA/CS 375 Fall Class Exercise Write the lower triangular system solver using only one loop i.e. vectorize the inner loop Test your algorithm against the built in Matlab matrix division routine. You have 10 minutes from when I say go – hard limit (no hand in required) replace

MA/CS 375 Fall Upper Triangular Systems

MA/CS 375 Fall Upper Triangular Systems Volunteer: tell us how to solve this? (hint: this is not difficult)

MA/CS 375 Fall Example: Upper Triangular Systems

MA/CS 375 Fall Upper Triangular Systems 1) Solve the N th equation 2) Use the value from step 1 to solve the (N-1) th equation 3) Use the values from steps 1 and 2 to solve the (N-2) th equation 4) keep going until you solve the whole system.

MA/CS 375 Fall Matlab Code for Backward Substitution

MA/CS 375 Fall Testing Backwards Substitution

MA/CS 375 Fall Finite Precision Effects Notice that x(1) depends on the values of x(2),x(3),…,x(N) Remembering that round off rears its ugly head when we deal with (small+large) numbers Volunteer to design a U matrix and b vector, which do not give good answers when used in this algorithm. (goal is to give you some intuition for cases which will break an algorithm)

MA/CS 375 Fall Summary of Lecture 18 We have seen how finite precision can effect the calculation of an inverse matrix, by example. We have discussed algorithms to solve Lx=b and Ux=b We have seen how to vectorize part of the forward/backward substitution algorithms We tried to break the forward/backward substitution algorithms

MA/CS 375 Fall Next Lecture Ok – so we know how to solve L or U matrices We will see how to write fairly general matrices as a product of a lower and upper matrix. E.g. A = LU We will investigate LU factorization, including sensitivity to the structure of A Introduce the idea of pivoting