Linear Systems What is the Matrix?. Outline Announcements: –Homework III: due Today. by 5, by e-mail –Ideas for Friday? Linear Systems Basics Matlab and.

Slides:



Advertisements
Similar presentations
Parallel Jacobi Algorithm Steven Dong Applied Mathematics.
Advertisements

Linear Algebra Applications in Matlab ME 303. Special Characters and Matlab Functions.
Algebraic, transcendental (i.e., involving trigonometric and exponential functions), ordinary differential equations, or partial differential equations...
Where to Go Next. Outline Announcements: –Homework IV due Wed. 10/8 by 5, by Extra week for projects Absolutely no exceptions! Answers will be.
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 18 Sit in your groups.
Linear Systems COS 323. Linear Systems Solve Ax=b, where A is an n  n matrix and b is an n  1 column vectorSolve Ax=b, where A is an n  n matrix and.
Scientific Computing Linear Systems – Gaussian Elimination.
Solving Linear Systems (Numerical Recipes, Chap 2)
Systems of Linear Equations
SOLVING SYSTEMS OF LINEAR EQUATIONS. Overview A matrix consists of a rectangular array of elements represented by a single symbol (example: [A]). An individual.
Lecture 9: Introduction to Matrix Inversion Gaussian Elimination Sections 2.4, 2.5, 2.6 Sections 2.2.3, 2.3.
Refresher: Vector and Matrix Algebra Mike Kirkpatrick Department of Chemical Engineering FAMU-FSU College of Engineering.
Cojugate Gradient Method Zhengru Zhang ( 张争茹 ) Office: Math. Building 413(West) 2010 年教学实践周
Solution of linear system of equations
Chapter 9 Gauss Elimination The Islamic University of Gaza
Lecture 11 - LU Decomposition
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
Dan Witzner Hansen  Groups?  Improvements – what is missing?
Part 3 Chapter 10 LU Factorization PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The McGraw-Hill Companies,
Linear Systems What is the Matrix?. Outline Announcements: –Homework III: due Wed. by 5, by Office Hours: Today & tomorrow, 11-1 –Ideas for Friday?
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 520 Structural Analysis II Review of Matrix Algebra.
Ordinary least squares regression (OLS)
CS240A: Conjugate Gradients and the Model Problem.
ECIV 301 Programming & Graphics Numerical Methods for Engineers REVIEW II.
Monica Garika Chandana Guduru. METHODS TO SOLVE LINEAR SYSTEMS Direct methods Gaussian elimination method LU method for factorization Simplex method of.
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.
Chapter 8 Objectives Understanding matrix notation.
LU Decomposition 1. Introduction Another way of solving a system of equations is by using a factorization technique for matrices called LU decomposition.
Chapter 10 Review: Matrix Algebra
Engineering Analysis ENG 3420 Fall 2009
Scientific Computing Linear Systems – LU Factorization.
Systems of Linear Equations Iterative Methods
ECON 1150 Matrix Operations Special Matrices
Eigenvalue Problems Solving linear systems Ax = b is one part of numerical linear algebra, and involves manipulating the rows of a matrix. The second main.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Square n-by-n Matrix.
MA2213 Lecture 5 Linear Equations (Direct Solvers)
Using LU Decomposition to Optimize the modconcen.m Routine Matt Tornowske April 1, 2002.
G AUSSIAN E LIMINATION Presented by: Max Le Max Le Justin Lavorgna Data Structures II: Algorithm Design & Analysis Algorithm Design & Analysis.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Scientific Computing Partial Differential Equations Poisson Equation.
CMPS 1371 Introduction to Computing for Engineers MATRICES.
Linear Systems Iterative Solutions CSE 541 Roger Crawfis.
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 21.
Lecture 7 - Systems of Equations CVEN 302 June 17, 2002.
Linear algebra: matrix Eigen-value Problems Eng. Hassan S. Migdadi Part 1.
Lesson 3 CSPP58001.
CS240A: Conjugate Gradients and the Model Problem.
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.
Input Output Garbage In, Garbage Out. Outline Announcements: –Homework III: due Today. by 5, by Discuss on Friday. –Homework IV: on web, due following.
1 Chapter 7 Numerical Methods for the Solution of Systems of Equations.
Outline Announcements –Add/drop today! –HWI due Friday Discrete Approximations Numerical Linear Algebra Solving ODE’s Solving PDE’s.
Lecture 9 Numerical Analysis. Solution of Linear System of Equations Chapter 3.
Numerical Computation Lecture 6: Linear Systems – part II United International College.
ROOTS OF EQUATIONS. Graphical Methods A simple method for obtaining the estimate of the root of the equation f(x)=0 is to make a plot of the function.
Linear Equations.
Linear Algebra Lecture 15.
Chapter 10: Solving Linear Systems of Equations
RECORD. RECORD Gaussian Elimination: derived system back-substitution.
CSE 541 – Numerical Methods
RECORD. RECORD COLLABORATE: Discuss: Is the statement below correct? Try a 2x2 example.
Part 3 Chapter 10 LU Factorization
Numerical Analysis Lecture10.
Linear Systems Numerical Methods.
Presentation transcript:

Linear Systems What is the Matrix?

Outline Announcements: –Homework III: due Today. by 5, by –Ideas for Friday? Linear Systems Basics Matlab and Linear Algebra

Ecology of Linear Systems Linear Systems are found in every habitat: –simple algebra –solutions to ODEs & PDEs –statistics (especially, least squares) If you can formulate your problem as linear system, it will be easy to solve on a computer

“Standard Linear System” Simplest linear system: finding the equation of a line: –y=m*x + b The goal is to find m and b from observations of (x,y) pairs 2 points form a line, so we need two observations (x1, y1) & (x2,y2)

The 8th Grade Solution Solve for b in the first equation: Substitute this for b in 2nd equation & solve for m: Put this into the equation for b above

The Sophomoric Solution Write the equations as a matrix problem Perform Gaussian Elimination on Matrix:

Comparing methods Gaussian Elimination is a simpler algorithm –Easily generalizes to systems with more unknowns Gaussian Elimination is the starting point of much of numerical linear algebra

A Closer Look at GE (optional) For Am=y –GE reduces A to an upper triangular matrix U –y is modified--call it b = Umb

A Closer Look at GE (optional) –last row corresponds to U n,n *m n =b n --- can solve for m n –row above is U n-1,n-1 *m n-1 + U n-1,n *m n =b n can solve for m n- 1 –So, can work our way up rows to get m Called “Back Substitution” = Umb

A Closer Look at GE (optional) –but what is b? b is solution to equation –So, can work our way down rows to get b Called “Forward Substitution” = Lby

A Closer Look at GE (optional) GE is equivalent to –LUm=y Implies that A=LU! So, GE works by finding lower & upper triangular matrices –triangular matrices are easy to work with Forward/Backward substitution

Other Algorithms for Solving Linear Systems GE aka LU decomposition -- any A Cholesky Factorization -- symmetric, positive definite A Iterative solvers (conjugate gradients, GMRES)

Linear Systems in Matlab Linear systems are easy in Matlab –To solve Ax=b, type x=A\b –To solve x’A’=b’, type x’=b’/A’ (transposed)

Matrix multiplication (*) is easy, fast Matrix “division” (\) is hard and computationally intensive –In general, performs GE with partial pivoting –But, \ is smart & looks closely at A for opportunities to speed up If A is LT, just does back substitution If A is over-determined, A\b is the least-squares solution More About \

Factorization Can explicitly factor A using LU: –[L,U]=lu(A) –useful if you have to solve A\b many times (different b each time) To solve LUx=b: first solve Ly=b, then solve Ux=y In Matlab: y=L\b; x=U\y; Other factorizations: chol, svd

What about A -1 ? Matlab can compute A -1 using inv(A), but … –inv(A) is slower than lu(A) –There are numerical problems with inv(A) Rarely needed, use lu(A) or another factorization

Key Points on Linear Systems They’re everywhere Easy to solve in Matlab (\) If possible, reuse factors from LU- decomposition Never use inv(A) for anything important Linear algebra (analytical and numerical) are highly recommended

Advection-Diffusion Model concentration of “contaminant” C Similar equations occur in –fluid dynamics –developmental biology –ecology

Numerical Solution We start with an initial distribution of C over the interval [0 1] Divide [0 1] into discrete points separated by dx C(x,t+dt) will depend on C(x), C(x-dx), & C(x+dx) x C(x,t) C(x,t+dt)

Numerical Solution replace partial derivatives with differences: The solution of C(x,t+dt) depends on neighboring points

Numerical Solution This is a matrix problem –A*C t+dt =f(C t ) Each grid point will have a row in matrix A All rows are the same except for first and last –We need to specify what happens at end points –Boundary conditions are a big problem –We’ll use periodic BC’s C(0)=C(1), so first and last rows are:

Numerical Solution Algorithm: –build A –for j=1:n build RHS=f(C t ) C t+dt =A\RHS very time consuming! –end

Numerical Solution Same A used in each iteration Factor once: –build A –[L,U]=lu(A);%chol would be better.. –for j=1:n build RHS=f(C t ) y=L\RHS; ---forward substitution C t+dt =U\y; ---back substitution –end

Sparse Matrices A is sparse –the only non-zero elements are immediately above, below, and on the diagonal –corners for periodic BC’s Matlab has special sparse matrices –much less memory (don’t need space for 0’s) –faster to process –A=sparse(I,J,S) forms A s.t. A(I(j),J(j))=S(j)

AdvDiff1D.m Uses slightly more complicated procedure for advection known as “Lax-Wendroff” method Must specify –Initial concentration C0 –parameters (u, k) –size of domain L –length of time T, –dx, dt Returns x, t, and C(x,t)