34. Solving systems of linear equations

34. Solving systems of linear equations - Solving Systems...

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

View Full Document Right Arrow Icon
©2009 by L. Lagerstrom Solving Systems of Linear Equations • For an introduction to the basic concepts, see the associated video clip • Solution by matrix inversion • Solution by matrix division • Checking a solution exists • Intersection of two lines
Background image of page 1

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

View Full DocumentRight Arrow Icon
Matlab code Command window display ©2009 by L. Lagerstrom Solution by Matrix Inversion %Consider the following 3 equations %in 3 unknowns: % 3*x1 + 2*x2 - x3 = 10 % -x1 + 3*x2 + 2*x3 = 5 % x1 - x2 - x3 = -1 %We write this in Ax = b form, where %A is the matrix of coefficients, %x is a column vector with the %elements x1, x2, and x3, and b is %a column vector with 10, 5, -1: A = [3 2 -1; -1 3 2; 1 -1 -1] b = [10; 5; -1] %Find x by getting the inverse of A %and multiplying it by b: x = inv(A)*b %Remember: Before writing down A and %b, all the terms in the 3 equations %must be lined up properly and all %the constants must be on the right %side of the equations. A = 3 2 -1 -1 3 2 1 -1 -1 b = 10 5 -1 x = -2.00 5.00 -6.00
Background image of page 2
Matlab code Command window display ©2009 by L. Lagerstrom Solution by Matrix Division %Alternatively, we can solve for x %by matrix division (the underlying %method uses a technique called %"Gauss elimination"): %Define A and b as before: A = [3 2 -1; -1 3 2; 1 -1 -1] b = [10; 5; -1] %Find x by using the left division %operator: x = A\b %This time we'll also confirm that %the values in x solve the equations %by plugging in x and seeing if %we get b (i.e., A*x should = b): result = A*x A = 3 2 -1 -1 3 2 1 -1 -1 b = 10 5 -1 x = -2.00 5.00 -6.00 result = 10.00 5.00 -1.00
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/23/2010 for the course ENG 42325 taught by Professor Lagerstrom during the Spring '10 term at UC Davis.

Page1 / 11

34. Solving systems of linear equations - Solving Systems...

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

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