Tema Métodos Numéricos
Tema Métodos Numéricos
C D
D. R P
Análisis numérico
Ricardo Prato
Universidad de Antioquia
𝜌(𝐴) ≤ ‖𝐴‖.
Para cada matriz 𝐴 y para cada 𝜀 > 0 existe una norma sobre ℂ𝑛 tal
que
‖𝐴‖ ≤ 𝜌(𝐴) + 𝜀
3 / 31
4 / 31
Lema
Sea 𝐵 ∶ 𝕂 → 𝕂 una transformación linear sobre 𝕂 (𝕂 = ℝ ó 𝕂 = ℂ) con
(𝐼 − 𝐵)x = x − 𝐵x = z
4 / 31
5 / 31
Métodos iterativos
Teorema
Sea 𝐵 ∈ ℂ𝑛×𝑛 . Las sucesivas aproximaciones
x𝜈+1 ∶= 𝐵 x𝜈 + z, 𝜈 ∈ ℕ0
𝜌(𝐵) < 1
5 / 31
6 / 31
Métodos iterativos
x𝜈+1 ∶= 𝐵 x𝜈 + z, 𝜈 ∈ ℕ0
𝜌(𝐵) < 1
Sketch de la prueba
1. Si 𝜌(𝐵) < 1 Existe ‖ ⋅ ‖ en ℂ𝑛 tal que ‖𝐵‖ < 1 , por tanto 𝐴𝑥 ∶= 𝐵𝑥 + 𝑧 define
una contracción. Es decir, Las sucesivas aproximaciones x𝜈+1 ∶= 𝐵 x𝜈 + z, 𝜈 ∈ ℕ0
converge para cada z ∈ ℂ𝑛 y cada x0 ∈ ℂ𝑛
2. Por RAA. Si 𝜌(𝐵) ≥ 1 ∃𝜆 ∈ 𝜎(𝐵) tal que |𝜆| > 1 Con (𝜆, 𝑤) el par
autovalor-autovector respectivo. Tome 𝑧 = 𝑥0 = 𝑤 ¿Qué concluye?
6 / 31
3 / 54
Métodos iterativos
x(𝑘+1) = 𝑃 −1 𝑁 x(𝑘) + 𝑃 −1 𝑏
x(𝑘+1) = x(𝑘) + 𝑃 −1 𝑟(𝑘) , 𝑟(𝑘) = 𝑏 − 𝐴x(𝑘)
3 / 54
4 / 54
Métodos iterativos estacionarios
4 / 54
5 / 54
Ejemplo del Sistema 4x4
En forma matricial:
4 1 −1 0 ⎛𝑥1 ⎞ 7
⎛
⎜ ⎞
⎟ ⎜ ⎟ ⎛⎜ ⎞
⎜
⎜ 1 −3 1 1 ⎟⎟
⎜
⎜𝑥2⎟⎟ ⎜ −6⎟
⎟
⎜ ⎟ ⎜
⎜ ⎟
⎟ =⎜ ⎟
⎜ ⎟
⎜
⎜−1 1 5 −2⎟ ⎟⎜ 𝑥3 ⎟ ⎜⎜ 8⎟⎟
⎜ ⎟
⎝ 0 1 −2 4 ⎠ ⎝𝑥4 ⎠ ⎝ ⎠9
5 / 54
6 / 54
6 / 54
7 / 54
La Matriz de Iteración de Jacobi
𝑥(𝑘+1) = 𝐵𝐽 𝑥(𝑘) + 𝑐𝐽
donde
• 𝐵𝐽 es la matriz de iteración de Jacobi
• 𝑐𝐽 es el vector constante
Descomponemos la matriz 𝐴 en 𝐴 = 𝐷 + 𝐴𝐿 + 𝐴𝑅
4 0 00 0 0 00 0 −1 1 0
⎛
⎜ ⎞
⎟ ⎛
⎜ ⎞
⎟ ⎛
⎜ ⎞
⎜0 −3 0 0⎟ ⎜−1 0 0 0 ⎟ ⎜0 0 −1 −1⎟⎟
𝐷=⎜
⎜ ⎟
⎟ , −𝐴 𝐿 = ⎜
⎜ ⎟
⎟ , −𝐴 𝑅 = ⎜
⎜ ⎟
⎟
⎜
⎜0 0 5 0⎟
⎟ ⎜
⎜ 1 −1 0 0 ⎟
⎟ ⎜
⎜0 0 0 2 ⎟
⎟
⎝0 0 0 4⎠ ⎝ 0 −1 2 0⎠ ⎝0 0 0 0 ⎠
7 / 54
8 / 54
Calculando
La matriz delaiteración
Matriz de
de Jacobi
Iteración
está𝐵dada
𝐽 por:
0 −1 1 0
⎛
⎜ ⎞
⎟
⎜−1 0 −1 −1 ⎟
−(𝐴𝐿 + 𝐴𝑅 ) = ⎜
⎜ ⎟
⎟
⎜
⎜ 1 −1 0 2 ⎟⎟
⎝ 0 −1 2 0 ⎠
8 / 54
9 / 54
La Matriz de Iteración 𝐵𝐽
0 −1/4 1/4 0
⎛
⎜ ⎞
⎟
⎜
⎜1/3 0 1/3 1/3 ⎟
⎟
=⎜
⎜ ⎟
⎟
⎜
⎜1/5 −1/5 0 2/5⎟ ⎟
⎜ ⎟
⎝ 0 −1/4 1/2 0 ⎠
9 / 54
10 / 54
1/4 0 0 0 7 7/4
⎛
⎜ ⎞
⎟ ⎛ ⎞ ⎛ ⎞
⎜ ⎜ ⎟
⎜ 0 −1/3 0 0 ⎟ ⎟ ⎜
⎜−6 ⎟
⎟ ⎜
⎜ 2 ⎟
⎟
−1 ⎜
𝑐𝐽 = 𝐷 𝑏 = ⎜ ⎟
⎟ ⎜
⎜ ⎟
⎟ =⎜ ⎟
⎜
⎜ 0 0 1/5 0 ⎟ ⎜ 8 ⎟ ⎜8/5⎟
⎟ ⎜ ⎟ ⎜ ⎟
⎜ ⎟ ⎜ ⎟
0 0 0 1/4 ⎝ 9⎠ 9/4
⎝ ⎠ ⎝ ⎠
10
/ 54
11 / 54
Paso 1 de la Iteración 0
⎛
⎜ ⎞
0⎟
𝑥(2) = 𝐵𝐽 𝑥(1) + 𝑐𝐽
0 −1/4 1/4 0 1.75 1.75
⎛
⎜ ⎞
⎟ ⎛ ⎞ ⎛ ⎞
⎜
⎜ 1/3 0 1/3 1/3⎟
⎟ ⎜
⎜ 2.00⎟⎟ ⎜
⎜ 2.00⎟⎟
=⎜
⎜ ⎟
⎟ ⎜
⎜ ⎟
⎟ + ⎜
⎜ ⎟
⎟
⎜
⎜ 1/5 −1/5 0 2/5⎟
⎟ ⎜
⎜ 1.60 ⎟
⎟ ⎜
⎜ 1.60 ⎟
⎟
⎜ ⎟
0 −1/4 1/2 0 ⎝ 2.25 ⎠ ⎝ 2.25 ⎠
⎝ ⎠
0(1.75) − 0.25(2.00) + 0.25(1.60) + 0(2.25) 1.75
⎛
⎜ ⎞
⎟ ⎛ ⎞
⎜
⎜ 1/3(1.75) + 0(2.00) + 1/3(1.60) + 1/3(2.25)⎟ ⎟ ⎜
⎜ 2.00⎟⎟
=⎜
⎜ ⎟
⎟ + ⎜
⎜ ⎟
⎟
⎜
⎜ 1/5(1.75) − 1/5(2.00) + 0(1.60) + 2/5(2.25) ⎟
⎟ ⎜
⎜ 1.60 ⎟
⎟
⎜ ⎟
0(1.75) − 0.25(2.00) + 0.5(1.60) + 0(2.25) ⎝ 2.25⎠
⎝ ⎠
12
/ 54
13 / 54
Paso 2 de la Iteración
1.75
𝑥(2) = 𝐵𝐽 𝑥(1) + 𝑐𝐽
0 − 0.5 + 0.4 + 0 1.75
⎛
⎜ ⎞
⎟ ⎛
⎜ ⎞
⎜
⎜ 0.5833 + 0 + 0.5333 + 0.75⎟
⎟ ⎜
⎜ 2.00⎟⎟
⎟
=⎜ ⎟ +⎜ ⎟
⎜
⎜ 0.35 − 0.4 + 0 + 0.9 ⎟ ⎜1.60⎟
⎟ ⎜ ⎟
⎝ 0 − 0.5 + 0.8 + 0 ⎠ ⎝ 2.25 ⎠
−0.1 1.75 1.65
⎛
⎜ ⎞
⎟ ⎛
⎜ ⎞
⎟ ⎛
⎜ ⎞
⎜
⎜ 1.8666⎟
⎟ ⎜
⎜ 2.00⎟
⎟ ⎜
⎜ 3.8666⎟
⎟
⎟
=⎜ ⎟ +⎜ ⎟ =⎜ ⎟
⎜
⎜ 0.85 ⎟ ⎜1.60⎟ ⎜ 2.45 ⎟
⎟ ⎜ ⎟ ⎜ ⎟
⎝ 0.3 ⎠ ⎝2.25⎠ ⎝ 2.55 ⎠
13
/ 54
14 / 54
Paso 3 de la Iteración
1.65
𝑥(3) = 𝐵𝐽 𝑥(2) + 𝑐𝐽
0 −1/4 1/4 0 1.65 1.75
⎛
⎜ ⎞
⎟ ⎛ ⎞ ⎛ ⎞
⎜
⎜1/3 0 1/3 1/3 ⎟
⎟ ⎜
⎜ ⎟
3.8666⎟ ⎜
⎜ 2.00⎟⎟
=⎜
⎜ ⎟
⎟ ⎜
⎜ ⎟
⎟ + ⎜
⎜ ⎟
⎟
⎜
⎜1/5 −1/5 0 2/5 ⎟
⎟ ⎜
⎜ 2.45 ⎟
⎟ ⎜
⎜ 1.60 ⎟
⎟
⎜ ⎟
0 −1/4 1/2 0 ⎝ 2.55 ⎠ ⎝ 2.25 ⎠
⎝ ⎠
0(1.65) − 0.25(3.8666) + 0.25(2.45) + 0(2.55) 1.75
⎛
⎜ ⎞
⎟ ⎛ ⎞
⎜
⎜1/3(1.65) + 0(3.8666) + 1/3(2.45) + 1/3(2.55)⎟ ⎟ ⎜
⎜ 2.00⎟⎟
=⎜
⎜ ⎟
⎟ + ⎜
⎜ ⎟
⎟
⎜
⎜1/5(1.65) − 1/5(3.8666) + 0(2.45) + 2/5(2.55) ⎟
⎟ ⎜
⎜ 1.60 ⎟
⎟
⎜ ⎟
0(1.65) − 0.25(3.8666) + 0.5(2.45) + 0(2.55) ⎝ 2.25⎠
⎝ ⎠
14
/ 54
15 / 54
Paso 3 de la Iteración
1.65
𝑥(3) = 𝐵𝐽 𝑥(2) + 𝑐𝐽
0 − 0.96665 + 0.6125 + 0 1.75
⎛
⎜ ⎞
⎟ ⎛
⎜ ⎞
⎜
⎜ 0.55 + 0 + 0.81665 + 0.85⎟
⎟ ⎜
⎜ 2.00⎟⎟
⎟
=⎜ ⎟ +⎜ ⎟
⎜0.33 − 0.77332 + 0 + 1.02⎟ ⎜1.60⎟
⎜ ⎟ ⎜ ⎟
⎝ 0 − 0.96665 + 1.225 + 0 ⎠ ⎝ 2.25 ⎠
−0.35415 1.75 1.39585
⎛
⎜ ⎞
⎟ ⎛
⎜ ⎞
⎟ ⎛
⎜ ⎞
⎜
⎜ 2.21665 ⎟
⎟ ⎜
⎜ 2.00⎟⎟ ⎜
⎜ 4.21665⎟⎟
⎟
=⎜ ⎟ +⎜ ⎟ =⎜ ⎟
⎜
⎜ 0.57668 ⎟ ⎜1.60⎟ ⎜2.17668⎟
⎟ ⎜ ⎟ ⎜ ⎟
⎝ 0.25835 ⎠ ⎝2.25⎠ ⎝2.50835⎠
15
/ 54
16 / 54
1
0 𝑎12 ⋯ 𝑎1𝑛
⎛ ⎞
𝑎1𝑛
0 𝑎𝑎12 ⋯
⎛
⎜
11 𝑎11 ⎞
⎟
⎜
⎜ 𝑎21 ⎟
⎟
⎜ 𝑎22 0 ⋱ ⋮ ⎟
⎜
= ⎜ ⎟
⎜ 𝑎𝑛−1,𝑛 ⎟⎟
⎜ ⋯ ⋱ 𝑎𝑛−1,𝑛−1 ⎟
⎜
⎜ ⎟
⎟
⎜ 𝑎𝑛1 𝑎𝑛,𝑛−1 ⎟
0
⎝ 𝑎𝑛𝑛 𝑎𝑛𝑛 ⎠
𝑞𝜇𝑛 𝑞𝜇
‖x𝑛 − x‖𝜇 ≤ ‖x − x0 ‖ , ‖x𝑛 − x‖𝜇 ≤ ‖x − x𝑛−1 ‖
1 − 𝑞𝜇 1 1 − 𝑞𝜇 𝑛
17
/ 54
18 / 54
Demostración:
así,
18
/ 54
20 / 54
Ejemplo del Sistema 4x4 (Recordatorio)
Consideramos el sistema con matriz de iteración:
1 1
⎛ 0 4 −4⎞
⎜
⎜ ⎟
⎟
⎜
⎜ ⎟
⎟
⎜ 1 ⎟
𝐵 = −𝐷(𝐴𝐿 + 𝐴𝑅 ) = ⎜
⎜
1
2 0 ⎟,
8 ⎟
⎜
⎜ ⎟
⎟
⎜
⎜ ⎟
⎟
⎜ ⎟
2 1
⎝5 5− 0 ⎠
1 5 3 5
𝑞∞ = ‖𝐵‖∞ = max { , , } =
2 8 5 8
9 9 3 9 ⇒ el método iterativo de Jacobi
𝑞1 = ‖𝐵‖1 = max { , , } =
10 20 8 10 converge.
𝑞 = ‖𝐵‖ ≈ 0.7685
22 / 54
Método iterativo de Jacobi
7 + 𝑦 𝑛 − 𝑧𝑛
𝑥𝑛+1 =
4
21 + 4𝑥𝑛 + 𝑧𝑛
𝑦𝑛+1 =
8
15 + 2𝑥𝑛 − 𝑦𝑛
𝑧𝑛+1 =
5
22
/ 54
23 / 54
Condiciones suficientes - Método de Jacobi
Ejemplo
4 −1 1
⎛
⎜ ⎞
⎟
𝐴=⎜
⎜ 4 −8 1⎟
⎟
⎝−2 1 5⎠
es estrictamente diagonalmente dominante por filas, pues
23
/ 54
24 / 54
import numpy as np
if k == imax+1:
print('numero maximo de iteraciones alcanzado, residuo=',r)
return [x, k, r]
24
/ 54
import numpy as np 25 / 54
def jacobiBasico(A,b,x,tol,imax):
n = len(A[0])
if k == imax+1:
print('numero maximo de iteraciones alcanzado, residuo=',
return
25 [x, k, r]
/ 54
26 / 54
Métodos iterativos
𝑎11
⎛ ⎞
𝐷 ∶= ⎜
⎜
⎜ ⋱
⎟
⎟
⎟ x𝑛+1 = − (𝐷 + 𝐴𝐿 )−1 𝐴𝑅 x𝑛
⎝ 𝑎𝑛𝑛 ⎠ + (𝐷 + 𝐴𝐿 )−1 y
26
/ 54
27 / 54
Forma matricial del método
27
/ 54
28 / 54
Ecuación por componentes
𝑖−1 𝑛
(𝑘+1) 1 (𝑘+1) (𝑘)
𝑥𝑖 = (𝑏𝑖 − ∑ 𝑎𝑖𝑗 𝑥𝑗 − ∑ 𝑎𝑖𝑗 𝑥𝑗 )
𝑎𝑖𝑖 𝑗=1 𝑗=𝑖+1
28
/ 54
29 / 54
Método Iterativo de Gauss-Seidel
𝐵 ∶= −(𝐷 + 𝐴𝐿 )−1 𝐴𝑅
𝑗−1 𝑛
(𝜈+1) 𝑎𝑗𝑘 (𝜈+1) 𝑎𝑗𝑘 (𝜈) 𝑦𝑗
𝑥𝑗 = −∑ 𝑥𝑘 − ∑ 𝑥𝑘 + , 𝑗 = 1, … , 𝑛, 𝜈 ∈ ℕ0
𝑘=1
𝑎𝑗𝑗 𝑎
𝑘=𝑗+1 𝑗𝑗
𝑎𝑗𝑗
𝑗−1 𝑛
1 (𝜈+1) (𝜈)
= ( − ∑ 𝑎𝑗𝑘 𝑥𝑘 − ∑ 𝑎𝑗𝑘 𝑥𝑘 + 𝑦𝑗 )
𝑎𝑗𝑗 𝑘=1 𝑘=𝑗+1
29
/ 54
30 / 54
Ejemplo 4x4
4 1 −1 0 ⎛𝑥1 ⎞ 7
⎛
⎜ ⎞
⎟ ⎜ ⎟ ⎛
⎜ ⎞
⎜
⎜ 1 −3 1 1 ⎟
⎟
⎜
⎜𝑥2 ⎟
⎟ ⎜ −6⎟
⎟
⎜ ⎟ ⎜ ⎟ =⎜ ⎟
⎜
⎜
⎜−1 1 5 −2⎟⎟⎜
⎜𝑥 ⎟ ⎜8⎟ ⎟
⎜ 3⎟⎟ ⎜ ⎟
⎝ 0 1 −2 4 ⎠ ⎝𝑥4 ⎠ ⎝ 9 ⎠
30
/ 54
31 / 54
El Método Iterativo de Gauss-Seidel
31
/ 54
32 / 54
Reescribiendo las Ecuaciones para Gauss-Seidel
32
/ 54
La Matriz de Iteración de Gauss-Seidel
Recordemos la descomposición 𝐴 = 𝐷 + 𝐴𝑅 + 𝐴𝐿 . La matriz de iteración de
4 0 00 0 −1 1 0 7
⎛
⎜ ⎞
⎟ ⎛
⎜ ⎞
⎟ ⎛
⎜ ⎞
⎟
⎜ −1 −3 0 0⎟ ⎜0 0 −1 −1 ⎟ ⎜−6 ⎟
𝐷 + 𝐴𝐿 = ⎜
⎜ ⎟
⎟, −𝐴𝑅 = ⎜
⎜ ⎟
⎟, 𝑏=⎜
⎜ ⎟
⎟
⎜
⎜ 1 −1 5 0⎟⎟ ⎜
⎜0 0 0 2 ⎟ ⎟ ⎜
⎜8⎟ ⎟
⎝ 0 −1 2 4⎠ ⎝0 0 0 0 ⎠ ⎝9⎠
0 − 14 14 0 ⎞ ‖𝐵𝐺𝑆 ‖1 = 0.820833
⎛
⎜ ⎟
⎜ 1 5 1 ⎟ ‖𝐵𝐺𝑆 ‖∞ = 0.833333
⎜
⎜ 0 − 12 12
⎟
3 ⎟
𝐵𝐺𝑆 =⎜
⎜ ⎟
⎟ ‖𝐵𝐺𝑆 ‖𝐹 = 0.742673
⎜
⎜
1
0 − 30 − 301 1 ⎟
⎜ 3 ⎟
⎟ ‖𝐵𝐺𝑆 ‖2 = 0.623721
⎜ ⎟
1 29 1
⎝ 0 240 − 240 12 ⎠ 𝜌(𝐵𝐺𝑆 ) = 0.214087
34 / 54
Primera Iteración (k=0) ( Sol. Exacta ( 79 , 27
7
𝑇
, 2, 16
7
) ≈ (1.28571 3.85714 2. 2.28571) )
𝑇
• Calculamos
7 7
0 ⎛ 4 ⎞
⎜ ⎟ ⎛⎜
4 ⎞
⎟ ⎛ 1.75 ⎞
⎛
⎜ ⎞
⎟ ⎜
⎜ 31 ⎟
⎟ ⎜
⎜ 31 ⎟
⎟ ⎜
⎜ 0 ⎟ ⎜ 12 ⎟ ⎜ 12 ⎟ ⎜2.58333⎟⎟
x(1) = 𝐵𝐺𝑆 𝑥(0) + 𝑐𝐺𝑆 = 𝐵𝐺𝑆 ⋅ ⎜ ⎜ ⎟
⎟ +⎜⎜ ⎟
⎟ =⎜
⎜ ⎟
⎟ ≈⎜
⎜ ⎟
⎟
⎜ 0 ⎟
⎜ ⎟ ⎜ ⎜ 43 ⎟
⎟ ⎜
⎜
43 ⎟
⎟ ⎜
⎜ 1.43333⎟
⎟
⎜ 30 ⎟
⎜ ⎟ ⎜ ⎟ ⎜ 30 ⎟
0
⎝ ⎠ 557 557 ⎝ 2.32083⎠
⎝ 240 ⎠ ⎝ 240 ⎠
𝑇
• Calcular el residuo 𝑟 = 𝐴x(1) − 𝑏 = (1.15 3.75417 −4.64167 0)
• Calcular la norma del residuo ‖𝑟‖2 ≈ 6.07958360461928
34
/ 54
35 / 54
Segunda Iteración (k=1) ( Sol. Exacta ( 9 27
, , 2, 16
7 7 7
)
𝑇
≈ (1.28571 3.85714 2. 2.28571) )
𝑇
⎛ 0 − 14 14 0 ⎞ ⎛ 74 ⎞ ⎛ 74 ⎞
⎜ ⎟⎜ ⎟ ⎜ ⎟
⎜
⎜
⎜
1
0 − 12 5
12
⎟⎜
1 ⎟ ⎜ 31 ⎟
3 ⎟ ⎜ 12 ⎟
⎟ ⎜⎜
⎜
31 ⎟
⎟
12 ⎟
x(2) =⎜
⎜ ⎟
⎟ ⎜
⎜ ⎟
⎟ +⎜
⎜ ⎟
⎟
⎜
⎜ 0 − 30 − 30 3 ⎟
1 1 1
⎟ ⎜
⎜
43 ⎟
⎟ ⎜
⎜
43 ⎟
⎟
⎜
⎜ ⎟
⎟⎜⎜ ⎟
30
⎟ ⎜⎜ ⎟
30
⎟
1 29 1 557 557
0 −
⎝ 240 240 12 ⎠ ⎝ 240 ⎠ ⎝ 240 ⎠
117
⎛
⎜
80 ⎞
⎟ 1.4625
⎜
⎜ 673 ⎟
⎟ ⎛
⎜ ⎞
⎟
⎜ 180 ⎟ ⎜3.7389 ⎟
=⎜
⎜ ⎟
⎟ ⎜
≈⎜ ⎟
⎟
⎜
⎜
7463 ⎟ ⎜
⎜2.0731 ⎟
⎟
⎜ 3600 ⎟
⎟
⎜ ⎟ 2.3518
16933 ⎝ ⎠
⎝ 7200 ⎠
• Calcular el residuo
𝑇
𝑟 = 𝐴x(2) − 𝑏 = (0.515833 0.670694 −0.0619444 0)
• Calcular la norma del residuo ‖𝑟‖2 ≈ 0.848382095393314
35
/ 54
36 / 54
Tercera Iteración (k=2) ( Sol. Exacta ( 79 , 27
7
𝑇
, 2, 16
7
) ≈ (1.28571 3.85714 2. 2.28571) )
𝑇
⎛ 0 − 41 14 0 ⎞ ⎛
7
4 ⎞
⎜ ⎟ 1.4625 ⎜ ⎟
⎜
⎜ 1 5 1 ⎟ ⎛ ⎞ ⎜
⎜ 31 ⎟
⎟
⎜0 − 12 12 3 ⎟
⎜ ⎟
⎟
⎜
⎜3.7389⎟ ⎟ ⎜ 12 ⎟
x(3) =⎜ ⎟ ⎜
⎜ ⎟
⎟ ⎜
+⎜ ⎟ ⎟
⎜ 1 1 1 ⎟ ⎜2.0731⎟ ⎜ 43 ⎟
⎜ 0 − 30 − 30 3 ⎟ ⎜ ⎟ ⎜ 30 ⎟
⎜
⎜ ⎟
⎟ 2.3518 ⎜
⎜ ⎟ ⎟
0 1
− 29 1 ⎝ ⎠ 557
⎝ 240 240 12 ⎠ ⎝ 240 ⎠
117
⎛
⎜
80 ⎞
⎟ 1.3335
⎜
⎜ 673 ⎟
⎟ ⎛
⎜ ⎞
⎜ 180 ⎟ ⎜3.9195⎟⎟
=⎜
⎜ ⎟ ⎜
⎟ ≈⎜ ⎟
⎟
⎜
⎜
7463 ⎟ ⎜
⎜2.0235 ⎟
⎟
⎜ 3600 ⎟
⎟
⎜ ⎟
16933 ⎝2.2819⎠
⎝ 7200 ⎠
𝑇
• Calcular el residuo 𝑟 = 𝐴x(3) − 𝑏 = (0.230095 −0.1194 0.139801 0)
• Calcular la norma del residuo ‖𝑟‖2 ≈ 0.294524192810059
36
/ 54
(𝑘) (𝑘) (𝑘) (𝑘)
𝑘 𝑥1 𝑥2 𝑥3 𝑥4 𝑟 = 𝐴x(𝑘) 37
−/𝑏54
0 0.00000000 0.00000000 0.00000000 0.00000000 15.16575089
N = length(y);
X=X';
38
/ 54
En python ... (𝐷 + 𝐴𝐿 )x𝑛+1 = −𝐴𝑅 x𝑛 + 𝑏
R = np.tril(A)
U = np.triu(A, 1)
r = tol + 1
i = 0
while (r > tol) and (i < nmax):
y = -np.matmul(U, x0) + b
x = np.linalg.solve(R, y)
r = np.linalg.norm(b - np.matmul(A, x))
x0=x
i = i + 1
if i == nmax:
print('El esquema alcanzo el numero max. de iteraciones, r=', r)
break
return [x, r, i]
3 / 17
Resolución sistemas lineales 𝐴x = y
3 / 17
4 / 17
4 / 17
Modificación Gauss-Seidel
SOR
𝑗−1 𝑛
(𝑛+1) 𝜔 (𝑛+1) (𝑛) (𝑛)
x𝑗 = (y𝑗 − ∑ 𝑎𝑗,𝑘 x𝑘 − ∑ 𝑎𝑗,𝑘 x𝑘 ) + (1 − 𝜔)x𝑗
𝑎𝑗,𝑗 𝑘=1 𝑘=𝑗+1
6 / 17
x𝑛+1 = x𝑛 + 𝜔𝐷−1 (y − 𝐴𝐿 x𝑛+1 − (𝐷 + 𝐴𝑅 )x𝑛 )
x𝑛+1 + 𝜔𝐷−1 𝐴𝐿 x𝑛+1 = x𝑛 + 𝜔𝐷−1 y − 𝜔𝐷−1 (𝐷 + 𝐴𝑅 )x𝑛
donde
−1
𝐵SOR = (𝐼 + 𝜔𝐷−1 𝐴𝐿 ) ((1 − 𝜔)𝐼 − 𝜔𝐷−1 𝐴𝑅 )
−1
= (𝐼 + 𝜔𝐷−1 𝐴𝐿 ) ((1 − 𝜔)𝐷−1 𝐷 − 𝜔𝐷−1 𝐴𝑅 )
−1
= (𝐼 + 𝜔𝐷−1 𝐴𝐿 ) 𝐷−1 ((1 − 𝜔)𝐷 − 𝜔𝐴𝑅 )
−1
= [𝐷 (𝐼 + 𝜔𝐷−1 𝐴𝐿 )] ((1 − 𝜔)𝐷 − 𝜔𝐴𝑅 )
−1
= (𝐷 + 𝜔𝐴𝐿 ) ((1 − 𝜔)𝐷 − 𝜔𝐴𝑅 )
−1 −1
x𝑛+1 = (𝐷 + 𝜔𝐴𝐿 ) ((1 − 𝜔)𝐷 − 𝜔𝐴𝑅 ) x𝑛 + 𝜔 (𝐷 + 𝜔𝐴𝐿 ) y
6 / 17
4𝑥 − 𝑦 + 𝑧 = 7 1
⎛ ⎞
Resolver 4𝑥 − 8𝑦 + 𝑧 = −21 tomando 𝑥0 = ⎜
⎜−1⎟
1
Tomando 𝜔 = 2
4 4
⎛ ⎞ ⎛ ⎞
(𝐷 + 𝜔𝐴𝐿 ) = ⎜
⎜ ⎟ +1⎛
⎜4 ⎞ ⎟ ⎜
⎜ 2 −8 ⎟⎟
⎜ −8 ⎟
⎟ 2⎜⎜ ⎟
⎟= ⎜
⎜ ⎟
⎟
1
⎝ 5⎠ ⎝−2 1 ⎠ ⎝−1 2 5⎠
−40
−1 1 ⎛⎜ ⎞
⎟
(𝐷 + 𝜔𝐴𝐿 ) = − ⎜ −10 20 ⎟
160 ⎜ ⎟
⎝ −7 −2 −32 ⎠
4 1 −1
1⎛⎜ ⎞
((1 − 𝜔)𝐷 − 𝜔𝐴𝑅 ) = ⎜
⎜ 0 −8 −1⎟⎟
⎟
2
⎝ 0 0 5 ⎠
8 / 17
−40 4 1 −1
1 ⎛⎜ ⎞
⎟ 1⎛⎜ ⎞
𝐵SOR =− ⎜
⎜ −10 20 ⎟
⎟ ⋅ ⎜
⎜ −8 −1⎟⎟
⎟
160 2
4 1 −1 0 ⎛𝑥1 ⎞ 7
⎛
⎜ ⎞
⎟ ⎜ ⎟ ⎛
⎜ ⎞
⎜
⎜ 1 −3 1 1 ⎟
⎟
⎜
⎜𝑥2 ⎟
⎟ ⎜ −6⎟
⎟
⎜ ⎟ ⎜ ⎟ =⎜ ⎟
⎜
⎜
⎜−1 1 5 −2⎟⎟⎜
⎜𝑥 ⎟ ⎜8⎟ ⎟
⎜ 3⎟⎟ ⎜ ⎟
⎝ 0 1 −2 4 ⎠ ⎝𝑥4 ⎠ ⎝ 9 ⎠
9 / 17
10 / 17
𝑇 𝑇
Sol. Exacta ( 79 , 27
7
, 2, 16
7
) ≈ (1.28571 3.85714 2. 2.28571)
Gráfico de Error vs ω
10−1
Error=‖x10 − x * ‖
10−2
10−3
10−4
10−5
35
Número de iteraciones
30
25
20
15
10
Sketch de la prueba
1.
𝑛
∏ 𝜆𝑖 = det 𝐵(𝜔) = det(𝐷 + 𝜔𝐴𝐿 )−1 [(1 − 𝜔)𝐷 − 𝜔𝐴𝑅 ]
𝑗=1
13
/ 17
14 / 17
function [x,iter]= JOR(A,b,x0,nmax,tol,omega)
% Resuelve un sistema Ax=b usando el metodo JOR
[n, m]=size(A);