Ecuaciones Algebraicas lineales

Transcription

Ecuaciones Algebraicas lineales
Ecuaciones Algebraicas lineales
• An equation of the form ax+by+c=0 or equivalently ax+by=c is called a linear equation in x and y variables.
• ax+by+cz=d
b
d is
i a linear
li
equation
i in
i three
h variables,
i bl x, y, andd
z.
• Thus,
Th a linear
li
equation
ti in
i n variables
i bl is
i
a1x1+a2x2+ … +anxn = b
• A solution
l ti off suchh an equation
ti consists
i t off reall numbers
b c1, c2,
c3, … , cn. If you need to work more than one linear
equations a system of linear equations must be solved
equations,
simultaneously.
Matrices
aij = elementos de una matriz
i=número del renglón
j=número de la columna
Vector columna
Vector columna
Vector renglón
Matriz cuadrada m=n
Matriz cuadrada m=n
Diagonal principal
Número de incóngnitas
Número de
ecuaciones
Reglas de operaciones con matrices
Representación de ecuaciones algebraicas lineales en forma matricial
Solving for X
Noncomputer Methods for Solving
Systems of Equations
• For small number of equations (n ≤ 3) linear
q
can be solved readilyy byy simple
p
equations
techniques such as “method of elimination.”
• Linear algebra provides the tools to solve such
systems of linear equations.
• Nowadays, easy access to computers makes
the solution of large sets of linear algebraic
equations possible and practical.
Part 3
10
Gauss Elimination
Chapter 9
Solving Small Numbers of Equations
• There are many ways to solve a system of
linear equations:
– Graphical
G hi l method
th d
– Cramer’s rule
– Method of elimination
– Computer methods
Part 3
For n ≤ 3
11
Graphical Method
• For two equations:
a11 x1 + a12 x2 = b1
a21 x1 + a22 x2 = b2
• Solve both equations for x2:
⎛ a11 ⎞
b
⎟⎟ x1 + 1 ⇒ x2 = (slope)x1 + intercept
x2 = −⎜⎜
a12
⎝ a12 ⎠
⎛ a21 ⎞
b2
⎜
⎟
x2 = −⎜
x1 +
⎟
a22
⎝ a22 ⎠
Part 3
12
• Plot x2 vs. x1
on rectilinear
paper, the
intersection of
the lines
present the
solution.
Fig. 9.1
Part 3
13
Graphical Method
• Or equate and solve for x1
⎛ a11 ⎞
⎛ a21 ⎞
b1
b2
⎟⎟ x1 +
⎟⎟ x1 +
x2 = −⎜⎜
= −⎜⎜
a12
a22
⎝ a12 ⎠
⎝ a22 ⎠
⎛ a21 a11 ⎞
b1 b2
⎟⎟ x1 +
⇒ ⎜⎜
−
−
=0
a12 a22
⎝ a22 a12 ⎠
⎛ b1 b2 ⎞ ⎛ b2
b1 ⎞
⎟⎟ ⎜⎜
⎜⎜
⎟⎟
−
−
a12 a22 ⎠ ⎝ a22 a12 ⎠
⎝
⇒ x1 = −
=
⎛ a21 a11 ⎞ ⎛ a21 a11 ⎞
⎟⎟ ⎜⎜
⎟⎟
⎜⎜
−
−
⎝ a22 a12 ⎠ ⎝ a22 a12 ⎠
Part 3
14
Figure 9.2
No solution Infinite solutions Part 3
Ill‐conditioned
(Slopes are too close)
15
Determinants and Cramer’s
Cramer s Rule
• Determinant can be illustrated for a set of three
equations:
Ax = b
• Where A is the coefficient matrix:
⎡a11 a12 a13 ⎤
⎢
⎥
A = ⎢a21 a22 a23 ⎥
⎢⎣a31 a32 a33 ⎥⎦
Part 3
16
• Assuming all matrices are square matrices, there
is a number associated with each square matrix A
called the determinant, D, of A. (D=det (A)). If
[A] iis order
d 11, then
h [A] hhas one element:
l
A=[a11]
D=a11
• For a square matrix of order 2,
2 A
A=
th determinant
the
d t
i t is
i D=
D a11 a22-a21 a12
Part 3
a11 a12
a21 a22
17
• For a square matrix of order 3, the minor of
an element aij is the determinant of the matrix
of order 2 by deleting row i and column j of A.
Part 3
18
a11 a12 a13
D = a 21 a 22 a 23
a 31 a 32 a 33
D11 =
a 22 a 23
a 32 a 33
D12 =
a 21 a 23
D13 =
a 21 a 22
a 31 a 33
a 31 a 32
= a 22 a 33 − a 32 a 23
= a 21 a 33 − a 31 a 23
= a 21 a 32 − a 31 a 22
Part 3
19
D = a11
a22 a23
a32 a33
− a12
a21 a23
a31 a33
+ a13
a21 a22
a31 a32
• Cramer’s rule expresses the solution of a
systems off li
linear equations
i
in
i terms off ratios
i
of determinants of the array of coefficients of
the equations. For example, x1 would be
computed as:
b1 a12 a13
b2 a22 a23
x1 =
b3 a32 a33
D
Part 3
20
Method of Elimination
• The basic strategy is to successively solve one
q
of the set for one of the
of the equations
unknowns and to eliminate that variable from
the remaining equations by substitution
substitution.
• The elimination of unknowns can be extended
to systems with more than two or three
q
however, the method becomes
equations;
extremely tedious to solve by hand.
Part 3
23
Relación con Cramer
Naive Gauss Elimination
• Extension
i off method
h d off elimination
l
to large
l
sets of equations by developing a systematic
scheme or algorithm to eliminate unknowns
and to back substitute.
• As in the case of the solution of two equations,
ec que for
o n equ
equations
o s co
consists
s s s oof two
wo
thee technique
phases:
– Forward elimination of unknowns
– Back substitution
Part 3
25
Fig. 9.3
Part 3
26
Generalizando
Elemento pivote
Multiplicando ec 1
a32’/a22’ = nuevo elemento pivote
Restando ec2 de la nueva ec1
Reescribiendo ec anterior
Pitfalls of Elimination Methods
• Di
Division
i i by
b zero. It iis possible
ibl that
th t during
d i both
b th
elimination and back-substitution phases a division
by zero can occur.
• Round-off errors.
• Ill
Ill-conditioned
conditioned systems. Systems where small changes
in coefficients result in large changes in the solution.
Alternatively, it happens when two or more equations
are nearly
l identical,
id ti l resulting
lti a wide
id ranges off
answers to approximately satisfy the equations. Since
round off errors can induce small changes in the
coefficients, these changes can lead to large solution
errors.
Part 3
31
• Singular systems. When two equations are
g of
identical, we would loose one degree
freedom and be dealing with the impossible
q
for n unknowns. For
case of n-1 equations
large sets of equations, it may not be obvious
however. The fact that the determinant of a
singular system is zero can be used and tested
byy computer
p
algorithm
g
after the elimination
stage. If a zero diagonal element is created,
ccalculation
cu o iss terminated.
e
ed.
Part 3
32
Techniques for Improving Solutions
• U
Use off more significant
i ifi t figures.
fi
• Pivoting. If a pivot element is zero,
normalization
li i step leads
l d to division
di i i by
b zero.
The same problem may arise, when the pivot
element is close to zero.
zero Problem can be
avoided:
– Partial pivoting
pivoting. Switching the rows so that the
largest element is the pivot element.
– Complete pivoting.
pivoting Searching for the largest
element in all rows and columns then switching.
Part 3
33
Cramer o sustituciòn
Determinant Evaluation Using Gauss Elimination
Casi cero !!!
Depende del numero de cifras p
significativas
SCALING
Gauss Jordan
Gauss-Jordan
• It is
i a variation
i i off Gauss elimination.
li i i The
h
major differences are:
– When an unknown is eliminated, it is eliminated
from all other equations rather than just the
subsequent ones.
– All rows are normalized by dividing them by their
pivot
i
elements.
l
– Elimination step results in an identity matrix.
– Consequently, it is not necessary to employ back
substitution to obtain solution.
Part 3
44
Descomposición LU e inversión de M ti
Matrices [A]{X}={B}
[A]{X}-{B}=0
[U]{X}-{D}=0
[U]{X}-{D}
0
Gauss Elimination
De la eliminación hacia delante de Gauss tenemos : Finalmente
Encontrando ‘d’ aplicando la eliminación
hacia adelante pero solo sobre el vector ‘B’
Encontrando ‘X’ aplicando la sustitución
hacia atrás Matriz Inversa
Matriz Inversa
Homework