SlideShare uma empresa Scribd logo
1 de 7
Last modified:January 1, 1970 GMT
An Introduction to Matlab(tm): Lesson 7
SOLVING SIMULTANEOUS LINEAR EQUATIONS
One of the most common applications of matrix algebra occurs
in the solution of linear simultaneous equations. Consider a set of
n equations for which the unknowns are x1, x2, ....... xn.
a11x1 + a12x2 + a13x3 + ............... a1nxn = b1
a21x1 + a22x2 + a23x3 + ............... a2nxn = b2
a31x1 + a32x2 + a33x3 + ............... a3nxn = b3
.
.
.
. .
.
.
.
. .
.
.
.
. .
.
.
.
. .
an1x1 + an2x2 + an3x3 + ............... annxn = bn
The matrix format for these equations is
[a][x] = [b]
where
a11 a12 a13 .... a1n

x1

b1

a21 a22 a23 .....a2n

x2

b2

[a] = a31 a32 a33 .... a3n
. . .
.
.
. . .
.
.
. . .
.
.
. . .
.
.
an1 an2 an3 .... ann

[x] = x3
.
.
.
.
xn

[b] = b3

bn

Note that only when the equations are linear in the unknown xi's is
the matrix formulation possible.
The classical matrix solution to this equation is based on the
definition of the inverse of a matrix. The inverse of a matrix is
that matrix which when multiplied by the original matrix, results
in the identity matrix. Then
a-1 a = I
where a-1 denotes the 'inverse of matrix a' and I denotes the
identity matrix of the same order as matrix 'a'. If 'a' is a known
coefficient matrix and if 'b' is a column vector of known terms,
the problem is one of finding the n vales of x1, x2, .... xn that
satisfy these simultaneous equations. Pre-multiplying both sides of
the equation by the inverse of 'a' gives
[a-1][a][x] = [a-1][b]
or
[x] = [a-1][b]
Thus if we find the inverse of the coefficient matrix, the product
of the inverse times the matrix of non-homogeneous terms, b, yields
the unknown matrix, x. To observe the simple property of the
inverse, define the 4x4 matrix, C
C = [1 -4 3 2; 3 1 -2 1; 2 1 1 -1; 2 -1 3 1]
calculate the inverse using the 'matlab' command, inv().
C_inverse = inv(C)
and note that
C_inverse * C = [1 0 0 0;0 1 0 0;0 0 1 0;0 0 0 1]
where the right hand side is the 4x4 identity matrix.
We leave to a study of linear algebra, the method and steps
required to calculate the inverse of a matrix. Suffice it to say
here that for systems of equations numbering in the hundreds or
thousands, which often occur in complex engineering problems, the
calculation of the matrix inverse is a time consuming operation
even for modern computers.
As an example of solving a system of equations using the
matrix inverse, consider the following system of three equations.
x1 - 4x2 + 3x3 = -7
3x1 + x2 - 2x3 = 14
2x1 + x2 + x3 = 5
Using 'matlab', define the two matrices for [a] and [b].
a = [ 1 -4 3; 3 1 -2; 2 1 1];
b = [ -7; 14; 5];
Find the solution vector, x, by
x = inv(a)*b
giving
x=[3
1
-2 ]
LEFT AND RIGHT MATRIX 'DIVISION' IN MATLAB
In contrast to matrix inversion, the preferred methods of
solution for large-scale systems of simultaneous equations are
methods of back substitution whereby the equations can be
rearranged so that first xn is solved, then xn-1 and so on until
finally x1 is obtained in order. Thus in back substitution we never
solve the equations simultaneously, rather we solve them
sequentially. For example, the above set of equations can be
rearranged through appropriate combination into the below
equations. (You should carry out this algebra to ensure you
understand the steps matlab takes in solving with back
substitution. In the general case, the steps or algorithm is much
more complex than that required for 3 equations.)
x1 - 4x2 + 3x3 = -7
13x2 - 11x3 = 35
(34/13)x3 = (68/13)
In this format, we see from the third equation the solution for x3
= 2 and knowing this, the second equation yields x2 = 1, and
knowing both x3 and x2, the first equation gives x1 = 1. This is an
application of back substitution, whereby each unknown is obtained
by simple sequential solution to a single equation. Methods of back
substitution are employed by 'matlab' when we invoke the 'right
division' and 'left division' commands.

/

left division
right division

Understand that matrices cannot be divided. The operation is not
defined. The syntax of 'right division' and 'left division' simply
invoke back substitution methods for obtaining a solution vector
from a system of simultaneous equations. Whether 'right division'
(/) or 'left division' () is appropriate depend on how the matrix
equation is posed.
Left Division. If the matrix equation is
[a][x] = [b]
then we have a nxn matrix [a] pre-multiplying a nx1 matrix [x],
resulting in a nx1 matrix [b]. The solution for x is obtained by
using the left division operation.
[x] = [a][b]
If the matrix equation is cast in this format, the use of right
division to obtain the solution vector x will result in an error
message.
Returning to 'matlab', recall we have defined the matrices [a]
and [b] in the format of the matrix equation appropriate for left
division.
a = [ 1 -4 3; 3 1 -2; 2 1 1];
b = [ -7; 14; 5];
Now enter the command
x1 = ab
and obtain the result
x1 = [ 3
1
-2 ]
which i s the same result found earlier for x when solving by
matrix inversion.
Right Division. The matrix format in which right division is
employed is less common but no less successful in solving the
problem of simultaneous equations. Right Division is invoked when
the equations are written in the form
[x][A] = [B]
Note that in this form [x] and [B] are row vectors rather than
column vectors as above. This form represent a 1xn matrix (x) premultiplying a nxn matrix (A), resulting an a 1xn matrix (B). Again,
recalling the set of equations,
x1 - 4x2 + 3x3 = -7
3x1 + x2 - 2x3 = 14
2x1 + x2 + x3 = 5
These equations can be written in matrix format
[x][A] =[B]
if
x = [x1 x2 x3]

B = [ -7 14 5]

and
1 3 2
[A] = -4 1 1
3 -2 1
Note that [A] is equal to the transpose of [a].
A = a'
Having so defined A and B, the solution for x can be obtained by
right division.
x = B/A
results in
x=[3
1
-2 ]

PRACTICE PROBLEMS
1. Find the solution to
r + s + t + w = 4
2r - s

+ w = 2

3r + s - t - w = 2
r - 2s - 3t + w = -3
using the matrix inverse and left and right division.
2. Find the solution to
2x1 + x2 - 4x3 + 6x4 + 3x5 - 2x6 = 16
-x1 + 2x2 + 3x3 + 5x4 - 2x5

= -7

x1 - 2x2 - 5x3 + 3x4 + 2x5 + x6 = 1
4x1 + 3x2 - 2x3 + 2x4

+ x6 = -1

3x1 + x2 - x3 + 4x4 + 3x5 + 6x6 = -11
5x1 + 2x2 - 2x3 + 3x4 + x5 + x6 = 5
using the matrix inverse and left and right division.
3. Back substitution is facilitated by recognizing that any
nonsingular symmetric matrix can be decomposed or factored into the
product of two matrices, called here L and U.
A=LU
This is called LU factorization. U is an upper triangular matrix
(all 0's below the diagonal). L is called a permutation of a lower
triangular matrix in which 1's occur at every element which is a
permutation of the two numbers defining the size of the matrix.
These matrices can be obtained in 'matlab' using the command
[L,U] = lu(A)
Using the matrix A defined in Prob 2 above, find the upper and
lower triangular factor matrices for the matrix of coefficients, A.
If these matrices are called AU and AL, show that
AL * AU * x = B
where
x [ 2 -1 1 0 3 -4 ]' and B = [16 -7 1 -1 -11 5]'
Back to Matlab In-House Tutorials

Mais conteúdo relacionado

Mais procurados

31 algebraic fractions (1)
31 algebraic fractions (1)31 algebraic fractions (1)
31 algebraic fractions (1)
apecoraro
 
Systems of linear equations and augmented matrices
Systems of linear equations and augmented matricesSystems of linear equations and augmented matrices
Systems of linear equations and augmented matrices
ST ZULAIHA NURHAJARURAHMAH
 
4.3 Determinants and Cramer's Rule
4.3 Determinants and Cramer's Rule4.3 Determinants and Cramer's Rule
4.3 Determinants and Cramer's Rule
hisema01
 
February 18, 2015
February 18, 2015February 18, 2015
February 18, 2015
khyps13
 
Directs Methods
Directs MethodsDirects Methods
Directs Methods
UIS
 
Gauss-Jordan Theory
Gauss-Jordan TheoryGauss-Jordan Theory
Gauss-Jordan Theory
HernanFula
 

Mais procurados (20)

Online Lecture Chapter R Algebraic Expressions
Online Lecture Chapter R Algebraic ExpressionsOnline Lecture Chapter R Algebraic Expressions
Online Lecture Chapter R Algebraic Expressions
 
31 algebraic fractions (1)
31 algebraic fractions (1)31 algebraic fractions (1)
31 algebraic fractions (1)
 
Gauss
GaussGauss
Gauss
 
Systems of linear equations and augmented matrices
Systems of linear equations and augmented matricesSystems of linear equations and augmented matrices
Systems of linear equations and augmented matrices
 
linear equation and gaussian elimination
linear equation and gaussian eliminationlinear equation and gaussian elimination
linear equation and gaussian elimination
 
Aman
AmanAman
Aman
 
Calc02 3 n
Calc02 3 nCalc02 3 n
Calc02 3 n
 
4.3 Determinants and Cramer's Rule
4.3 Determinants and Cramer's Rule4.3 Determinants and Cramer's Rule
4.3 Determinants and Cramer's Rule
 
Nsm
Nsm Nsm
Nsm
 
Cramer's Rule
Cramer's RuleCramer's Rule
Cramer's Rule
 
Matrices and determinants
Matrices and determinantsMatrices and determinants
Matrices and determinants
 
system linear equations and matrices
 system linear equations and matrices system linear equations and matrices
system linear equations and matrices
 
Gaussian elimination method & homogeneous linear equation
Gaussian elimination method & homogeneous linear equationGaussian elimination method & homogeneous linear equation
Gaussian elimination method & homogeneous linear equation
 
Integrated Math 2 Section 8-5
Integrated Math 2 Section 8-5Integrated Math 2 Section 8-5
Integrated Math 2 Section 8-5
 
GATE Engineering Maths : System of Linear Equations
GATE Engineering Maths : System of Linear EquationsGATE Engineering Maths : System of Linear Equations
GATE Engineering Maths : System of Linear Equations
 
February 18, 2015
February 18, 2015February 18, 2015
February 18, 2015
 
Lesson 3 - matrix multiplication
Lesson 3 - matrix multiplicationLesson 3 - matrix multiplication
Lesson 3 - matrix multiplication
 
GATE Preparation : Matrix Algebra
GATE Preparation : Matrix AlgebraGATE Preparation : Matrix Algebra
GATE Preparation : Matrix Algebra
 
Directs Methods
Directs MethodsDirects Methods
Directs Methods
 
Gauss-Jordan Theory
Gauss-Jordan TheoryGauss-Jordan Theory
Gauss-Jordan Theory
 

Destaque (8)

Matlab tut3
Matlab tut3Matlab tut3
Matlab tut3
 
Matlab practical file
Matlab practical fileMatlab practical file
Matlab practical file
 
Disseration M.Tech
Disseration M.TechDisseration M.Tech
Disseration M.Tech
 
List Of Post Graduate Thesis in engineering project management
List Of Post Graduate Thesis in engineering project managementList Of Post Graduate Thesis in engineering project management
List Of Post Graduate Thesis in engineering project management
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
 
Matlab Basic Tutorial
Matlab Basic TutorialMatlab Basic Tutorial
Matlab Basic Tutorial
 
Introduction to Matlab
Introduction to MatlabIntroduction to Matlab
Introduction to Matlab
 
Matlab Introduction
Matlab IntroductionMatlab Introduction
Matlab Introduction
 

Semelhante a Lesson 7

0.3.e,ine,det.
0.3.e,ine,det.0.3.e,ine,det.
0.3.e,ine,det.
m2699
 
Mc ty-cubicequations-2009-1
Mc ty-cubicequations-2009-1Mc ty-cubicequations-2009-1
Mc ty-cubicequations-2009-1
Brit4
 
Mc ty-cubicequations-2009-1
Mc ty-cubicequations-2009-1Mc ty-cubicequations-2009-1
Mc ty-cubicequations-2009-1
Harsh Arora
 
algebra lesson notes (best).pdf
algebra lesson notes (best).pdfalgebra lesson notes (best).pdf
algebra lesson notes (best).pdf
CyprianObota
 
Quotient of polynomial using (Synthetic Division) and Zeros of Polynomial Fu...
Quotient of polynomial using (Synthetic Division) and Zeros of Polynomial  Fu...Quotient of polynomial using (Synthetic Division) and Zeros of Polynomial  Fu...
Quotient of polynomial using (Synthetic Division) and Zeros of Polynomial Fu...
magnesium121
 
Solving Linear Equations
Solving Linear EquationsSolving Linear Equations
Solving Linear Equations
taco40
 
Pair of linear equation in two variables (sparsh singh)
Pair of linear equation in two variables (sparsh singh)Pair of linear equation in two variables (sparsh singh)
Pair of linear equation in two variables (sparsh singh)
Sparsh Singh
 
Final presentation
Final presentationFinal presentation
Final presentation
paezp
 
Module 1 plane coordinate geometry
Module 1   plane coordinate geometryModule 1   plane coordinate geometry
Module 1 plane coordinate geometry
dionesioable
 
Math lecture 6 (System of Linear Equations)
Math lecture 6 (System of Linear Equations)Math lecture 6 (System of Linear Equations)
Math lecture 6 (System of Linear Equations)
Osama Zahid
 
4 pages from matlab an introduction with app.-2
4 pages from matlab an introduction with app.-24 pages from matlab an introduction with app.-2
4 pages from matlab an introduction with app.-2
Malika khalil
 

Semelhante a Lesson 7 (20)

Es272 ch4a
Es272 ch4aEs272 ch4a
Es272 ch4a
 
0.3.e,ine,det.
0.3.e,ine,det.0.3.e,ine,det.
0.3.e,ine,det.
 
chapter1_part2.pdf
chapter1_part2.pdfchapter1_part2.pdf
chapter1_part2.pdf
 
Ch9-Gauss_Elimination4.pdf
Ch9-Gauss_Elimination4.pdfCh9-Gauss_Elimination4.pdf
Ch9-Gauss_Elimination4.pdf
 
Analytic Geometry Period 1
Analytic Geometry Period 1Analytic Geometry Period 1
Analytic Geometry Period 1
 
Mc ty-cubicequations-2009-1
Mc ty-cubicequations-2009-1Mc ty-cubicequations-2009-1
Mc ty-cubicequations-2009-1
 
Mc ty-cubicequations-2009-1
Mc ty-cubicequations-2009-1Mc ty-cubicequations-2009-1
Mc ty-cubicequations-2009-1
 
Maths
MathsMaths
Maths
 
algebra lesson notes (best).pdf
algebra lesson notes (best).pdfalgebra lesson notes (best).pdf
algebra lesson notes (best).pdf
 
Quotient of polynomial using (Synthetic Division) and Zeros of Polynomial Fu...
Quotient of polynomial using (Synthetic Division) and Zeros of Polynomial  Fu...Quotient of polynomial using (Synthetic Division) and Zeros of Polynomial  Fu...
Quotient of polynomial using (Synthetic Division) and Zeros of Polynomial Fu...
 
Solving Linear Equations
Solving Linear EquationsSolving Linear Equations
Solving Linear Equations
 
WCS Specialist Maths An Introduction to Matrices PowerPoint
WCS Specialist Maths An Introduction to Matrices PowerPointWCS Specialist Maths An Introduction to Matrices PowerPoint
WCS Specialist Maths An Introduction to Matrices PowerPoint
 
Pair of linear equation in two variables (sparsh singh)
Pair of linear equation in two variables (sparsh singh)Pair of linear equation in two variables (sparsh singh)
Pair of linear equation in two variables (sparsh singh)
 
Pair of linear equation in two variables (sparsh singh)
Pair of linear equation in two variables (sparsh singh)Pair of linear equation in two variables (sparsh singh)
Pair of linear equation in two variables (sparsh singh)
 
Final presentation
Final presentationFinal presentation
Final presentation
 
system of linear equations
system of linear equationssystem of linear equations
system of linear equations
 
Linear equations
Linear equationsLinear equations
Linear equations
 
Module 1 plane coordinate geometry
Module 1   plane coordinate geometryModule 1   plane coordinate geometry
Module 1 plane coordinate geometry
 
Math lecture 6 (System of Linear Equations)
Math lecture 6 (System of Linear Equations)Math lecture 6 (System of Linear Equations)
Math lecture 6 (System of Linear Equations)
 
4 pages from matlab an introduction with app.-2
4 pages from matlab an introduction with app.-24 pages from matlab an introduction with app.-2
4 pages from matlab an introduction with app.-2
 

Mais de Vinnu Vinay (10)

Matlab tut2
Matlab tut2Matlab tut2
Matlab tut2
 
Matlab summary
Matlab summaryMatlab summary
Matlab summary
 
Lesson 8
Lesson 8Lesson 8
Lesson 8
 
Lesson 6
Lesson 6Lesson 6
Lesson 6
 
Lesson 5
Lesson 5Lesson 5
Lesson 5
 
Lesson 4
Lesson 4Lesson 4
Lesson 4
 
Lesson 3
Lesson 3Lesson 3
Lesson 3
 
Lesson 2
Lesson 2Lesson 2
Lesson 2
 
matlab Lesson 1
matlab Lesson 1matlab Lesson 1
matlab Lesson 1
 
Matlabtut1
Matlabtut1Matlabtut1
Matlabtut1
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Último (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Lesson 7

  • 1. Last modified:January 1, 1970 GMT An Introduction to Matlab(tm): Lesson 7 SOLVING SIMULTANEOUS LINEAR EQUATIONS One of the most common applications of matrix algebra occurs in the solution of linear simultaneous equations. Consider a set of n equations for which the unknowns are x1, x2, ....... xn. a11x1 + a12x2 + a13x3 + ............... a1nxn = b1 a21x1 + a22x2 + a23x3 + ............... a2nxn = b2 a31x1 + a32x2 + a33x3 + ............... a3nxn = b3 . . . . . . . . . . . . . . . . . . . . an1x1 + an2x2 + an3x3 + ............... annxn = bn The matrix format for these equations is [a][x] = [b] where a11 a12 a13 .... a1n x1 b1 a21 a22 a23 .....a2n x2 b2 [a] = a31 a32 a33 .... a3n . . . . . . . . . . . . . . . . . . . . an1 an2 an3 .... ann [x] = x3 . . . . xn [b] = b3 bn Note that only when the equations are linear in the unknown xi's is the matrix formulation possible. The classical matrix solution to this equation is based on the definition of the inverse of a matrix. The inverse of a matrix is that matrix which when multiplied by the original matrix, results in the identity matrix. Then a-1 a = I
  • 2. where a-1 denotes the 'inverse of matrix a' and I denotes the identity matrix of the same order as matrix 'a'. If 'a' is a known coefficient matrix and if 'b' is a column vector of known terms, the problem is one of finding the n vales of x1, x2, .... xn that satisfy these simultaneous equations. Pre-multiplying both sides of the equation by the inverse of 'a' gives [a-1][a][x] = [a-1][b] or [x] = [a-1][b] Thus if we find the inverse of the coefficient matrix, the product of the inverse times the matrix of non-homogeneous terms, b, yields the unknown matrix, x. To observe the simple property of the inverse, define the 4x4 matrix, C C = [1 -4 3 2; 3 1 -2 1; 2 1 1 -1; 2 -1 3 1] calculate the inverse using the 'matlab' command, inv(). C_inverse = inv(C) and note that C_inverse * C = [1 0 0 0;0 1 0 0;0 0 1 0;0 0 0 1] where the right hand side is the 4x4 identity matrix. We leave to a study of linear algebra, the method and steps required to calculate the inverse of a matrix. Suffice it to say here that for systems of equations numbering in the hundreds or thousands, which often occur in complex engineering problems, the calculation of the matrix inverse is a time consuming operation even for modern computers. As an example of solving a system of equations using the matrix inverse, consider the following system of three equations. x1 - 4x2 + 3x3 = -7 3x1 + x2 - 2x3 = 14 2x1 + x2 + x3 = 5 Using 'matlab', define the two matrices for [a] and [b].
  • 3. a = [ 1 -4 3; 3 1 -2; 2 1 1]; b = [ -7; 14; 5]; Find the solution vector, x, by x = inv(a)*b giving x=[3 1 -2 ] LEFT AND RIGHT MATRIX 'DIVISION' IN MATLAB In contrast to matrix inversion, the preferred methods of solution for large-scale systems of simultaneous equations are methods of back substitution whereby the equations can be rearranged so that first xn is solved, then xn-1 and so on until finally x1 is obtained in order. Thus in back substitution we never solve the equations simultaneously, rather we solve them sequentially. For example, the above set of equations can be rearranged through appropriate combination into the below equations. (You should carry out this algebra to ensure you understand the steps matlab takes in solving with back substitution. In the general case, the steps or algorithm is much more complex than that required for 3 equations.) x1 - 4x2 + 3x3 = -7 13x2 - 11x3 = 35 (34/13)x3 = (68/13) In this format, we see from the third equation the solution for x3 = 2 and knowing this, the second equation yields x2 = 1, and knowing both x3 and x2, the first equation gives x1 = 1. This is an application of back substitution, whereby each unknown is obtained by simple sequential solution to a single equation. Methods of back substitution are employed by 'matlab' when we invoke the 'right division' and 'left division' commands. / left division right division Understand that matrices cannot be divided. The operation is not
  • 4. defined. The syntax of 'right division' and 'left division' simply invoke back substitution methods for obtaining a solution vector from a system of simultaneous equations. Whether 'right division' (/) or 'left division' () is appropriate depend on how the matrix equation is posed. Left Division. If the matrix equation is [a][x] = [b] then we have a nxn matrix [a] pre-multiplying a nx1 matrix [x], resulting in a nx1 matrix [b]. The solution for x is obtained by using the left division operation. [x] = [a][b] If the matrix equation is cast in this format, the use of right division to obtain the solution vector x will result in an error message. Returning to 'matlab', recall we have defined the matrices [a] and [b] in the format of the matrix equation appropriate for left division. a = [ 1 -4 3; 3 1 -2; 2 1 1]; b = [ -7; 14; 5]; Now enter the command x1 = ab and obtain the result x1 = [ 3 1 -2 ] which i s the same result found earlier for x when solving by matrix inversion. Right Division. The matrix format in which right division is employed is less common but no less successful in solving the problem of simultaneous equations. Right Division is invoked when the equations are written in the form
  • 5. [x][A] = [B] Note that in this form [x] and [B] are row vectors rather than column vectors as above. This form represent a 1xn matrix (x) premultiplying a nxn matrix (A), resulting an a 1xn matrix (B). Again, recalling the set of equations, x1 - 4x2 + 3x3 = -7 3x1 + x2 - 2x3 = 14 2x1 + x2 + x3 = 5 These equations can be written in matrix format [x][A] =[B] if x = [x1 x2 x3] B = [ -7 14 5] and 1 3 2 [A] = -4 1 1 3 -2 1 Note that [A] is equal to the transpose of [a]. A = a' Having so defined A and B, the solution for x can be obtained by right division. x = B/A results in x=[3 1 -2 ] PRACTICE PROBLEMS
  • 6. 1. Find the solution to r + s + t + w = 4 2r - s + w = 2 3r + s - t - w = 2 r - 2s - 3t + w = -3 using the matrix inverse and left and right division. 2. Find the solution to 2x1 + x2 - 4x3 + 6x4 + 3x5 - 2x6 = 16 -x1 + 2x2 + 3x3 + 5x4 - 2x5 = -7 x1 - 2x2 - 5x3 + 3x4 + 2x5 + x6 = 1 4x1 + 3x2 - 2x3 + 2x4 + x6 = -1 3x1 + x2 - x3 + 4x4 + 3x5 + 6x6 = -11 5x1 + 2x2 - 2x3 + 3x4 + x5 + x6 = 5 using the matrix inverse and left and right division. 3. Back substitution is facilitated by recognizing that any nonsingular symmetric matrix can be decomposed or factored into the product of two matrices, called here L and U. A=LU This is called LU factorization. U is an upper triangular matrix (all 0's below the diagonal). L is called a permutation of a lower triangular matrix in which 1's occur at every element which is a permutation of the two numbers defining the size of the matrix. These matrices can be obtained in 'matlab' using the command [L,U] = lu(A) Using the matrix A defined in Prob 2 above, find the upper and lower triangular factor matrices for the matrix of coefficients, A. If these matrices are called AU and AL, show that
  • 7. AL * AU * x = B where x [ 2 -1 1 0 3 -4 ]' and B = [16 -7 1 -1 -11 5]' Back to Matlab In-House Tutorials