Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Sistemas de Ecuaciones
Lineales
2 x1 4 x2 3x3 3 2 4 3 x1 3
2.5 x1 x2 3x3 5 2.5 1 3 x2 5
x1 6 x3 7 1 0 6 x3 7
Standard form M atrix form
[A]{x} {b}
Review of Matrices
a11 a12 a1m
a a 22 a 2m 2nd row Elements are indicated by a i j
[ A]
21
an1 a n2 anm n m row column
mth column
Square matrix:
c m m 1
- [A]nxm is a square matrix if n=m.
- A system of n equations with n unknonws has a square coefficient
matrix.
Special Types of Square Matrices
5 1 2 16 a11 1
1 3 7 39 1
[ A] [ D]
a22 [I ]
2 7 9 6 1
16 39 6 88 ann 1
a11 b1
column vector B 1
b a12
is
b 2 a 21 a 22 b2
• Determinant of a matrix:
A single number. Determinant of [A] is shown as |A|.
Methods to solve Systems of Linear
Equations
1. Graphical Method.
2. Cramer’s Rule. For n ≤ 3
3. Method of Elimination.
4. Gauss Elimination.
5. Gauss-Jordan Elimination.
1. Graphical Method
• For small sets of simultaneous equations, graphing
them and determining the location of the intercept
provides a solution.
• Solve:
3x1 2 x2 18
x1 2 x2 2
• Plot x2 vs. x1, the
intersection of the lines
presents the solution.
j i 1
xi ( i 1)
for i n-1, n-2, ..., 1
a ii
Summary of Naive Gauss Elimination Method
Naive Gauss Elimination Method
Example 1
6 –2 2 4 | 16
12 –8 6 10 | 26 R2-2R1
3 –13 9 3 | -19 R3-0.5R1
-6 4 1 -18 | -34 R4-(-R1)
Naive Gauss Elimination Method
Example 1 (cont’d)
Step 1: Forward elimination
Find x4 x4 =(-3)/(-3) = 1
Find x3 x3 =(-9+5*1)/2 = -2
Find x2 x2 =(-6-2*(-2)-2*1)/(-4) = 1
Find x1 x1 =(16+2*1-2*(-2)-4*1)/6 = 3
Naive Gauss Elimination Method Example 2
(Using 6 Significant Figures)
3.0 x1 - 0.1 x2 - 0.2 x3 = 7.85
0.1 x1 + 7.0 x2 - 0.3 x3 = -19.3 R2-(0.1/3)R1
0.3 x1 - 0.2 x2 + 10.0 x3 = 71.4 R3-(0.3/3)R1
x3 = 7.00003
x2 = -2.50000
x1 = 3.00000
Exact solution:
x3 = 7.0
x2 = -2.5
x1 = 3.0
Pseudo-code of Naive Gauss Elimination Method
k,j
function x = GaussNaive(A,b)
% GaussNaive: naive Gauss elimination
% x = GaussNaive(A,b): Gauss elimination without pivoting.
% input:
% A = coefficient matrix
% b = right hand side vector
% output:
% x = solution vector
[m,n] = size(A);
if m~=n
error('Matrix A must be square');
end
nb = n+1;
Aug = [A b]; % back substitution
% forward elimination x = zeros(n,1);
for k = 1:n-1 x(n) = Aug(n,nb)/Aug(n,n);
for i = k+1:n for i = n-1:-1:1
factor = Aug(i,k)/Aug(k,k); x(i) = (Aug(i,nb)-
Aug(i,k:nb) = Aug(i,k:nb)-factor*Aug(k,k:nb); Aug(i,i+1:n)*x(i+1:n))/Aug(i,i);
end end
end end
Pitfalls of Gauss Elimination Methods
1. Division by zero
2 x2 + 3 x3 = 8
a11 = 0
4 x1 + 6 x2 + 7 x3 = -3 (the pivot element)
2 x1 + x2 + 6 x3 = 5
2. Round-off errors
In the previous example where up to 6 digits were kept during
the calculations and still we end up with close to the real
solution.
x3 = 7.00003, instead of x3 = 7.0
Pitfalls of Gauss Elimination (cont’d)
3. Ill-conditioned systems
x1 + 2x2 = 10
x1 = 4.0 & x2 = 3.0
1.1x1 + 2x2 = 10.4
x1 + 2x2 = 10
x1 = 8.0 & x2 = 1.0
1.05x1 + 2x2 = 10.4
a) Forward Elimination
0 2 0 1 0 6 1 6 5 6
2 2 3 2 2 2 2 3 2 2
R 4
R 1
4 3 0 1 7 4 3 0 1 7
6 1 6 5 6 0 2 0 1 0
Example: Gauss Elimination (cont’d)
6 1 6 5 6
2 2 3 2 2 R 2 0.33333 R 1
4 3 0 1 7 R 3 0.66667 R 1
0 2 0 1 0
6 1 6 5 6
0 1.6667 5 3.6667 4
R3
R 2
0 3.6667 4 4.3333 11
0 2 0 1 0
6 1 6 5 6
0 3.6667 4 4.3333 11
0 1.6667 5 3.6667 4
0 2 0 1 0
Example: Gauss Elimination (cont’d)
6 1 6 5 6
0 3.6667 4 4.3333 11
0 1.6667 5 3.6667 4 R 3 0.45455 R 2
0 2 0 1 0 R 4 0.54545 R 2
6 1 6 5 6
0 3.6667 4 4.3333 11
0 0 6.8182 5.6364 9.0001
0 0 2.1818 3.3636 5.9999 R 4 0.32000 R 3
6 1 6 5 6
0 3.6667 4 4.3333 11
0 0 6.8182 5.6364 9.0001
0 0 0 1.5600 3.1199
Example: Gauss Elimination (cont’d)
6 1 6 5 6
0 3.6667 4 4.3333 11
0 0 6.8182 5.6364 9.0001
0 0 0 1.5600 3.1199
b) Back Substitution
3.1199
x4 1.9999
1.5600
9.0001 5.6364 1.9999
x3 0.33325
6.8182
11 4.3333 1.9999 4 0.33325
x2 1.0000
3.6667
6 5 1.9999 6 0.33325 11.0000
x1 0.50000
6
Use of more significant figures to solve for the
round-off error : Example.
2 2.0001 3(2 / 3)
x2 x1
3 0.0003
Significant
x2 x1
Figures
3 0.667 -3.33
4 0.6667 0.000
5 0.66667 0.3000
6 0.666667 0.33000
7 0.6666667 0.333000
Pivoting: Example to solve for the round-off error
Now, solving the pervious example using the partial pivoting technique:
Original
0.0003 x1 + 3.0000 x2 = 2.0001
1.0000 x1 + 1.0000 x2 = 1.000
x1 + x2 = 2.0
100,000 x2 = 100,000
Solve: x2 = 1.00 & x1 = 1.00
0 2 0 1 0 1 0.16667 1 0.83335 1
R 4
2 2 3 2 2 R 1
2 2 3 2 2
4 3 0 1 7 R 4 / 6.0 4 3 0 1 7
6 1 6 5 6 0 2 0 1 0
1 0.16667 1 0.83335 1
2 2 3 2 2 R 2 2 R 1
4 3 0 1 7 R 3 4 R 1
0 2 0 1 0
1 0.16667 1 0.83335 1
0 1.6667 5 3.6667 2
0 3.6667 4 4.3334 7
0 2 0 1 0
Dividing the 2nd row by 1.6667 and reducing the second column. (operating
above the diagonal as well as below) gives:
Divide the 3rd row by 15.000 and make the elements in the 3rd Column
zero.
1 0 0 0.04000 0.58000
0 1 0 0.27993 1.5599
0 0 1 0.82667 1.3200
0 0 0 1.5599 3.1197
Divide the 4th row by 1.5599 and create zero above the diagonal in the fourth column.
1 0 0 0 0.49999
0 1 0 0 1.0001
0 0 1 0 0.33326
0 0 0 1 1.9999